Longer Timeout in S3 Retries Test (#53841) (#53847)

The lower end of the timeout range of 100ms is prone to time out
on CI before the mock REST server gets to sending a response that
is not supposed to be a timeout.
Using 1-3s here should make this safe at the cost of randomly making
this test take a few seconds.

Closes #53506
This commit is contained in:
Armin Braun 2020-03-20 12:23:40 +01:00 committed by GitHub
parent be3090138e
commit a70ebef366
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -170,7 +170,7 @@ public class S3BlobContainerRetriesTests extends ESTestCase {
} }
}); });
final TimeValue readTimeout = TimeValue.timeValueMillis(between(100, 500)); final TimeValue readTimeout = TimeValue.timeValueSeconds(between(1, 3));
final BlobContainer blobContainer = createBlobContainer(maxRetries, readTimeout, null, null); final BlobContainer blobContainer = createBlobContainer(maxRetries, readTimeout, null, null);
try (InputStream inputStream = blobContainer.readBlob("read_blob_max_retries")) { try (InputStream inputStream = blobContainer.readBlob("read_blob_max_retries")) {
assertArrayEquals(bytes, BytesReference.toBytes(Streams.readFully(inputStream))); assertArrayEquals(bytes, BytesReference.toBytes(Streams.readFully(inputStream)));
@ -397,13 +397,15 @@ public class S3BlobContainerRetriesTests extends ESTestCase {
return randomByteArrayOfLength(randomIntBetween(1, frequently() ? 512 : 1 << 20)); // rarely up to 1mb return randomByteArrayOfLength(randomIntBetween(1, frequently() ? 512 : 1 << 20)); // rarely up to 1mb
} }
private static final Pattern RANGE_PATTERN = Pattern.compile("^bytes=([0-9]+)-9223372036854775806$");
private static int getRangeStart(HttpExchange exchange) { private static int getRangeStart(HttpExchange exchange) {
final String rangeHeader = exchange.getRequestHeaders().getFirst("Range"); final String rangeHeader = exchange.getRequestHeaders().getFirst("Range");
if (rangeHeader == null) { if (rangeHeader == null) {
return 0; return 0;
} }
final Matcher matcher = Pattern.compile("^bytes=([0-9]+)-9223372036854775806$").matcher(rangeHeader); final Matcher matcher = RANGE_PATTERN.matcher(rangeHeader);
assertTrue(rangeHeader + " matches expected pattern", matcher.matches()); assertTrue(rangeHeader + " matches expected pattern", matcher.matches());
return Math.toIntExact(Long.parseLong(matcher.group(1))); return Math.toIntExact(Long.parseLong(matcher.group(1)));
} }