Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated File Progress Receiver Tests #7961

Merged
merged 1 commit into from
Feb 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1209,8 +1209,14 @@ class EncyptedBlockBlobAPITest extends APISpec {
new DownloadRetryOptions().setMaxRetryRequests(3), null, false, null, null)

then:
// We should receive exactly one notification of the completed progress.
1 * mockReceiver.reportProgress(fileSize)
/*
* Should receive at least one notification indicating completed progress, multiple notifications may be
* received if there are empty buffers in the stream.
*/
(1.._) * mockReceiver.reportProgress(fileSize)

// There should be NO notification with a larger than expected size.
0 * mockReceiver.reportProgress({ it > fileSize })

/*
We should receive at least one notification reporting an intermediary value per block, but possibly more
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package com.azure.storage.blob

import com.azure.core.exception.UnexpectedLengthException

import com.azure.core.http.RequestConditions
import com.azure.core.util.CoreUtils
import com.azure.core.util.polling.LongRunningOperationStatus
Expand Down Expand Up @@ -32,7 +32,6 @@ import com.azure.storage.blob.sas.BlobServiceSasSignatureValues
import com.azure.storage.blob.specialized.BlobClientBase
import com.azure.storage.blob.specialized.SpecializedBlobClientBuilder
import com.azure.storage.common.implementation.Constants
import com.ctc.wstx.shaded.msv_core.verifier.jarv.Const
import reactor.core.Exceptions
import reactor.core.publisher.Hooks
import reactor.test.StepVerifier
Expand Down Expand Up @@ -693,16 +692,22 @@ class BlobAPITest extends APISpec {
new DownloadRetryOptions().setMaxRetryRequests(3), null, false, null, null)

then:
// We should receive exactly one notification of the completed progress.
1 * mockReceiver.reportProgress(fileSize)
/*
* Should receive at least one notification indicating completed progress, multiple notifications may be
* received if there are empty buffers in the stream.
*/
(1.._) * mockReceiver.reportProgress(fileSize)

// There should be NO notification with a larger than expected size.
0 * mockReceiver.reportProgress({ it > fileSize })

/*
We should receive at least one notification reporting an intermediary value per block, but possibly more
notifications will be received depending on the implementation. We specify numBlocks - 1 because the last block
will be the total size as above. Finally, we assert that the number reported monotonically increases.
*/
(numBlocks - 1.._) * mockReceiver.reportProgress(!file.size()) >> { long bytesTransferred ->
if (!(bytesTransferred > prevCount)) {
if (!(bytesTransferred >= prevCount)) {
throw new IllegalArgumentException("Reported progress should monotonically increase")
} else {
prevCount = bytesTransferred
Expand Down