Skip to content

Commit

Permalink
Merge branch 'New-Storage-SDK-V10-Preview-dev' into New-Storage-SDK-V…
Browse files Browse the repository at this point in the history
…10-Preview-dev
  • Loading branch information
rickle-msft authored Jul 3, 2018
2 parents eafda0a + db3f3f7 commit f72ada5
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 1 deletion.
2 changes: 1 addition & 1 deletion BreakingChanges.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
* Changed RequestRetryOptions maxTries and tryTimeout fields to be Integer instead of int. 0 is no longer allowed.
* Changed the return type of BlobURL.download to be a DownloadResponse instead of BlobsDownloadResponse for integration with RetryReader.
* Changed CommonRestResponse.lastModifiedTime to be lastModified.
* Changed the dateProperty field in all auto-generated files to be date.
* Changed the dateProperty field in all auto-generated files to be date.
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.microsoft.azure.storage

import com.microsoft.azure.storage.blob.BlockBlobURL
import com.microsoft.azure.storage.blob.CommonRestResponse
import com.microsoft.azure.storage.blob.ContainerURL
import com.microsoft.azure.storage.blob.PipelineOptions
import com.microsoft.azure.storage.blob.RequestRetryOptions
import com.microsoft.azure.storage.blob.ServiceURL
import com.microsoft.azure.storage.blob.StorageURL
import com.microsoft.azure.storage.blob.TransferManager
import com.microsoft.rest.v2.http.HttpClient
import com.microsoft.rest.v2.http.HttpClientConfiguration
import com.microsoft.rest.v2.http.HttpPipeline
import io.reactivex.Observable
import io.reactivex.ObservableSource
import io.reactivex.annotations.NonNull
import io.reactivex.functions.Function

import java.nio.ReadOnlyBufferException
import java.nio.channels.FileChannel

class TransferManagerTest extends APISpec {
def "https parallel file upload"() {
setup:
PipelineOptions po = new PipelineOptions()
RequestRetryOptions retryOptions = new RequestRetryOptions(null, null, 300,
null, null, null)
po.requestRetryOptions = retryOptions
HttpClientConfiguration configuration = new HttpClientConfiguration(
new Proxy(Proxy.Type.HTTP, new InetSocketAddress("localhost", 8888)))
po.client = HttpClient.createDefault(configuration)

HttpPipeline pipeline = StorageURL.createPipeline(primaryCreds, po)

// This test requires https.
ServiceURL surl = new ServiceURL(new URL("https://" + primaryCreds.getAccountName() + ".blob.core.windows.net"),
pipeline)

ContainerURL containerURL = surl.createContainerURL(generateContainerName())
containerURL.create(null, null).blockingGet()

when:
/*
We are simply testing for no errors here. There has historically been a problem with Netty that caused it to
crash when uploading multiple medium size files in parallel over https. Here we validate that behavior is
fixed. We will test for correctness of the parallel upload elsewhere.
*/
Observable.range(0, 4000)
.flatMap(new Function<Integer, ObservableSource>() {
@Override
ObservableSource apply(@NonNull Integer i) throws Exception {
BlockBlobURL asyncblob = containerURL.createBlockBlobURL("asyncblob" + i)
TransferManager.UploadToBlockBlobOptions asyncOptions = new TransferManager.UploadToBlockBlobOptions(
null, null, null, null, 1)

return TransferManager.uploadFileToBlockBlob(
FileChannel.open(new File(getClass().getClassLoader().getResource("15mb.txt").getFile())
.toPath()), asyncblob,BlockBlobURL.MAX_PUT_BLOCK_BYTES, asyncOptions).toObservable()
}
}, 2000)
.onErrorReturn((new Function<Throwable, Object>() {
@Override
public Object apply(Throwable throwable) throws Exception {
/*
We only care about the ReadOnlyBufferException as an indication of the netty failure with memory mapped
files. Everything else, like throttling, is fine here.
*/
if (throwable instanceof ReadOnlyBufferException) {
throw throwable
}
// This value is not meaningful. We just want the observable to continue.
return new Object()
}
})).blockingSubscribe()
containerURL.delete(null).blockingGet()

then:
notThrown(ReadOnlyBufferException)
}
}

0 comments on commit f72ada5

Please sign in to comment.