Skip to content

Commit 5a7db0c

Browse files
Fix GCS Test testReadLargeBlobWithRetries (#52619) (#52624)
The countdown didn't work well here because it only returns `true` once the countdown reaches `0` but can on subsequent executions return `false` again if a countdown at `0` is counted down again, leading to more than the expected number of simulated failures. Closes #52607
1 parent 5017bb0 commit 5a7db0c

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,9 @@ public void testReadBlobWithRetries() throws Exception {
200200
}
201201
}
202202

203-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/52607")
204203
public void testReadLargeBlobWithRetries() throws Exception {
205204
final int maxRetries = randomIntBetween(2, 10);
206-
final CountDown countDown = new CountDown(maxRetries);
205+
final AtomicInteger countDown = new AtomicInteger(maxRetries);
207206

208207
// SDK reads in 2 MB chunks so we use twice that to simulate 2 chunks
209208
final byte[] bytes = randomBytes(1 << 22);
@@ -215,7 +214,7 @@ public void testReadLargeBlobWithRetries() throws Exception {
215214
final int end = Integer.parseInt(range[1]);
216215
final byte[] chunk = Arrays.copyOfRange(bytes, offset, Math.min(end + 1, bytes.length));
217216
exchange.sendResponseHeaders(RestStatus.OK.getStatus(), chunk.length);
218-
if (randomBoolean() && countDown.countDown() == false) {
217+
if (randomBoolean() && countDown.decrementAndGet() >= 0) {
219218
exchange.getResponseBody().write(chunk, 0, chunk.length - 1);
220219
exchange.close();
221220
return;

0 commit comments

Comments
 (0)