Skip to content
This repository was archived by the owner on Jul 19, 2024. It is now read-only.

Commit 42e015f

Browse files
committed
CR feedback and updated Contributing doc
1 parent d8d0477 commit 42e015f

File tree

8 files changed

+26
-15
lines changed

8 files changed

+26
-15
lines changed

CONTRIBUTING.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ The Azure Storage development team uses Intellij. However, any preferred IDE or
2020
## Tests
2121

2222
### Configuration
23-
The only step to configure testing is to set the appropriate environment variable. Create environment variables named "ACCOUNT_NAME", "ACCOUNT_KEY", "SECONDARY_ACCOUNT_NAME", and "SECONDARY_ACCOUNT_KEY". The first two will be used for most requests. The second two will only be used for tests requiring two accounts.
23+
The only step to configure testing is to set the appropriate environment variables. Create environment variables named "ACCOUNT_NAME" and "ACCOUNT_KEY", holding your Azure storage account name and key respectively. This will satisfy most tests.
24+
To run any tests requiring two accounts (generally those testing copy-related apis), set environment variables "SECONDARY_ACCOUNT_NAME", and "SECONDARY_ACCOUNT_KEY".
25+
To run any tests related to setting blob tiers on block blobs, set environment variables "BLOB_STORAGE_ACCOUNT_NAME" and "BLOB_STORAGE_ACCOUNT_KEY". Note that a GPV2 account is also sufficient here.
26+
To run any tests related to setting blob tiers on page blobs, set environment variables "PREMIUM_ACCOUNT_NAME" and "PREMIUM_ACCOUNT_KEY".
27+
It is valid to use a single account for multiple scenarios; a GPV2 account would work for both the primary account and the blob storage account, for instance. The only restriction is that the primary and secondary accounts must be distinct.
2428

2529
### Running
2630
To actually run tests, right click on the test class in the Package Explorer or the individual test in the Outline and select Run As->GroovyTest. Alternatively, run mvn test from the command line.

ChangeLog.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ XXXX.XX.XX Version XX.X.X
55
* Added support for IProgressReceiver in TransferManager operations. This parameter was previously ignored but is now supported.
66
* Removed internal dependency on javafx to be compatible with openjdk.
77
* Fixed a bug that would cause downloading large files with the TransferManager to fail and a bug in BlobURL.download() logic for setting up reliable download.
8+
* Fixed a bug that would cause downloading large files with the TransferManager to fail.
9+
* Fixed a bug in BlobURL.download() logic for setting up reliable download. This had the potential to download the wrong range when a download stream was retried.
810

911
2018.09.11 Version 10.1.0
1012
* Interfaces for helper types updated to be more consistent throughout the library. All types, with the exception of the options for pipeline factories, use a fluent pattern.

src/main/java/com/microsoft/azure/storage/blob/DownloadResponse.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ private Flowable<ByteBuffer> tryContinueFlowable(Throwable t, int retryCount, Re
8686
if (retryCount > options.maxRetryRequests() || !(t instanceof IOException)) {
8787
return Flowable.error(t);
8888
} else {
89+
/*
90+
We wrap this in a try catch because we don't know the behavior of the getter. Most errors would probably
91+
come from an unsuccessful request, which would be propagated through the onError methods. However, it is
92+
possible the method call that returns a Single is what throws (like how our apis throw some exceptions at
93+
call time rather than at subscription time.
94+
*/
8995
try {
9096
// Get a new response and try reading from it.
9197
return getter.apply(this.info)

src/main/java/com/microsoft/azure/storage/blob/HTTPGetterInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public Long count() {
5555
*/
5656
public HTTPGetterInfo withCount(Long count) {
5757
if (count != null) {
58-
Utility.assertInBounds("count", count, 0, Integer.MAX_VALUE);
58+
Utility.assertInBounds("count", count, 0, Long.MAX_VALUE);
5959
}
6060
this.count = count;
6161
return this;

src/main/java/com/microsoft/azure/storage/blob/RequestRetryOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public RequestRetryOptions(RetryPolicyType retryPolicyType, Integer maxTries, In
8484
}
8585

8686
if (tryTimeout != null) {
87-
Utility.assertInBounds("tryTimeoutInMs", tryTimeout, 1, Long.MAX_VALUE);
87+
Utility.assertInBounds("tryTimeout", tryTimeout, 1, Integer.MAX_VALUE);
8888
this.tryTimeout = tryTimeout;
8989
} else {
9090
this.tryTimeout = 60;

src/test/java/com/microsoft/azure/storage/APISpec.groovy

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -229,25 +229,24 @@ class APISpec extends Specification {
229229
}
230230
}
231231

232+
/*
233+
Size must be an int because ByteBuffer sizes can only be an int. Long is not supported.
234+
*/
232235
static ByteBuffer getRandomData(int size) {
233236
Random rand = new Random(getRandomSeed())
234237
byte[] data = new byte[size]
235238
rand.nextBytes(data)
236239
return ByteBuffer.wrap(data)
237240
}
238241

239-
static File getRandomFile(long size) {
242+
/*
243+
We only allow int because anything larger than 2GB (which would require a long) is left to stress/perf.
244+
*/
245+
static File getRandomFile(int size) {
240246
File file = File.createTempFile(UUID.randomUUID().toString(), ".txt")
241247
file.deleteOnExit()
242248
FileOutputStream fos = new FileOutputStream(file)
243-
Random rand = new Random(getRandomSeed())
244-
while (size > 0) {
245-
int sizeToWrite = (int) Math.min((long)(Integer.MAX_VALUE.longValue()/10L), size)
246-
byte[] data = new byte[sizeToWrite]
247-
rand.nextBytes(data)
248-
fos.write(data)
249-
size -= sizeToWrite
250-
}
249+
fos.write(getRandomData(size).array())
251250
fos.close()
252251
return file
253252
}

src/test/java/com/microsoft/azure/storage/BlobAPITest.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class BlobAPITest extends APISpec {
8989
setup:
9090
def mockPolicy = Mock(RequestPolicy) {
9191
sendAsync(_) >> { HttpRequest request ->
92-
if (request.headers().value("x-ms-range") != "bytes=2-") {
92+
if (request.headers().value("x-ms-range") != "bytes=2-6") {
9393
return Single.error(new IllegalArgumentException("The range header was not set correctly on retry."))
9494
}
9595
else {
@@ -102,7 +102,7 @@ class BlobAPITest extends APISpec {
102102
bu = bu.withPipeline(pipeline)
103103

104104
when:
105-
def range = new BlobRange().withOffset(2)
105+
def range = new BlobRange().withOffset(2).withCount(5)
106106
bu.download(range, null, false, null).blockingGet().body(new ReliableDownloadOptions().withMaxRetryRequests(3))
107107
.blockingSubscribe()
108108

src/test/java/com/microsoft/azure/storage/TransferManagerTest.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ class TransferManagerTest extends APISpec {
424424
file | _
425425
getRandomFile(20) | _ // small file
426426
getRandomFile(16 * 1024 * 1024) | _ // medium file in several chunks
427-
getRandomFile(8L * 1026 * 1024 + 10) | _ // medium file not aligned to block
427+
getRandomFile(8 * 1026 * 1024 + 10) | _ // medium file not aligned to block
428428
getRandomFile(0) | _ // empty file
429429
// Files larger than 2GB to test no integer overflow are left to stress/perf tests to keep test passes short.
430430
}

0 commit comments

Comments
 (0)