Skip to content

Commit ce03dae

Browse files
committed
Tidy, improve naming
1 parent 2d2960c commit ce03dae

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

modules/repository-gcs/src/test/java/org/elasticsearch/repositories/gcs/GoogleCloudStorageBlobContainerRetriesTests.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -584,12 +584,13 @@ public void testCompareAndExchangeWhenThrottled() throws IOException {
584584
public void testContentsChangeWhileStreaming() throws IOException {
585585
GoogleCloudStorageHttpHandler handler = new GoogleCloudStorageHttpHandler("bucket");
586586
httpServer.createContext("/", handler);
587-
final int enoughBytesToTriggerChunkedDownload = Math.toIntExact(ByteSizeValue.ofMb(30).getBytes());
587+
// The blob needs to be large enough that it won't be entirely buffered on the first request
588+
final int enoughBytesToNotBeEntirelyBuffered = Math.toIntExact(ByteSizeValue.ofMb(30).getBytes());
588589

589590
final BlobContainer container = createBlobContainer(1, null, null, null, null, null, null);
590591

591592
final String key = randomIdentifier();
592-
byte[] initialValue = randomByteArrayOfLength(enoughBytesToTriggerChunkedDownload);
593+
byte[] initialValue = randomByteArrayOfLength(enoughBytesToNotBeEntirelyBuffered);
593594
container.writeBlob(randomPurpose(), key, new BytesArray(initialValue), true);
594595

595596
BytesReference reference = readFully(container.readBlob(randomPurpose(), key));
@@ -605,7 +606,7 @@ public void testContentsChangeWhileStreaming() throws IOException {
605606
httpServer.createContext("/", handler);
606607

607608
// Update the file
608-
byte[] updatedValue = randomByteArrayOfLength(enoughBytesToTriggerChunkedDownload);
609+
byte[] updatedValue = randomByteArrayOfLength(enoughBytesToNotBeEntirelyBuffered);
609610
container.writeBlob(randomPurpose(), key, new BytesArray(updatedValue), false);
610611

611612
// Read the rest of the stream, it should throw because the contents changed

modules/repository-gcs/src/test/java/org/elasticsearch/repositories/gcs/GoogleCloudStorageRetryingInputStreamTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public LowLevelHttpResponse execute() throws IOException {
170170
result.setContent(content);
171171
result.setContentLength(contentLength);
172172
result.setContentType("application/octet-stream");
173-
result.addHeader("x-goog-generation", String.valueOf(randomIntBetween(0, Integer.MAX_VALUE)));
173+
result.addHeader("x-goog-generation", String.valueOf(randomNonNegativeInt()));
174174
result.setStatusCode(RestStatus.OK.getStatus());
175175
return result;
176176
}

0 commit comments

Comments
 (0)