Skip to content

Commit 1b6bfa7

Browse files
committed
Fix remaining S3BlobStoreRepositoryTests
1 parent 96a04a3 commit 1b6bfa7

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

modules/repository-s3/src/internalClusterTest/java/org/elasticsearch/repositories/s3/S3BlobStoreRepositoryTests.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
import java.util.Objects;
8282
import java.util.Set;
8383
import java.util.concurrent.CountDownLatch;
84+
import java.util.concurrent.Semaphore;
8485
import java.util.concurrent.atomic.AtomicBoolean;
8586
import java.util.concurrent.atomic.AtomicLong;
8687
import java.util.stream.Collectors;
@@ -675,10 +676,24 @@ private void validateAuthHeader(HttpExchange exchange) {
675676
@SuppressForbidden(reason = "this test uses a HttpServer to emulate an S3 endpoint")
676677
protected static class S3ErroneousHttpHandler extends ErroneousHttpHandler {
677678

679+
// S3 SDK stops retrying after TOKEN_BUCKET_SIZE/DEFAULT_EXCEPTION_TOKEN_COST == 500/5 == 100 failures in quick succession
680+
// see software.amazon.awssdk.retries.DefaultRetryStrategy.Legacy.TOKEN_BUCKET_SIZE
681+
// see software.amazon.awssdk.retries.DefaultRetryStrategy.Legacy.DEFAULT_EXCEPTION_TOKEN_COST
682+
private final Semaphore failurePermits = new Semaphore(100);
683+
678684
S3ErroneousHttpHandler(final HttpHandler delegate, final int maxErrorsPerRequest) {
679685
super(delegate, maxErrorsPerRequest);
680686
}
681687

688+
@Override
689+
public void handle(HttpExchange exchange) throws IOException {
690+
if (failurePermits.tryAcquire()) {
691+
super.handle(exchange);
692+
} else {
693+
delegate.handle(exchange);
694+
}
695+
}
696+
682697
@Override
683698
protected String requestUniqueId(final HttpExchange exchange) {
684699
// Amazon SDK client provides a unique ID per request

test/framework/src/main/java/org/elasticsearch/repositories/blobstore/ESBlobStoreRepositoryIntegTestCase.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,6 @@ protected void testSnapshotAndRestore(boolean recreateRepositoryBeforeRestore) t
396396
);
397397
}
398398

399-
@AwaitsFix(bugUrl = "TODO NOMERGE")
400399
public void testMultipleSnapshotAndRollback() throws Exception {
401400
final String repoName = createRepository(randomRepositoryName());
402401
int iterationCount = randomIntBetween(2, 5);
@@ -461,7 +460,6 @@ private void deleteRandomDocs(String indexName, int existingDocCount) {
461460
client().admin().indices().prepareRefresh(indexName).get();
462461
}
463462

464-
@AwaitsFix(bugUrl = "TODO NOMERGE")
465463
public void testIndicesDeletedFromRepository() throws Exception {
466464
final String repoName = createRepository(randomRepositoryName());
467465
Client client = client();

test/framework/src/main/java/org/elasticsearch/repositories/blobstore/ESMockAPIBasedRepositoryIntegTestCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ protected abstract static class ErroneousHttpHandler implements DelegatingHttpHa
282282
// value is the number of times the request has been seen
283283
private final Map<String, AtomicInteger> requests;
284284

285-
private final HttpHandler delegate;
285+
protected final HttpHandler delegate;
286286
private final int maxErrorsPerRequest;
287287

288288
@SuppressForbidden(reason = "this test uses a HttpServer to emulate a cloud-based storage service")

0 commit comments

Comments
 (0)