8989import static org .elasticsearch .repositories .blobstore .BlobStoreTestUtil .randomPurpose ;
9090import static org .elasticsearch .repositories .s3 .S3ClientSettings .DISABLE_CHUNKED_ENCODING ;
9191import static org .elasticsearch .repositories .s3 .S3ClientSettings .ENDPOINT_SETTING ;
92+ import static org .elasticsearch .repositories .s3 .S3ClientSettings .MAX_CONNECTIONS_SETTING ;
9293import static org .elasticsearch .repositories .s3 .S3ClientSettings .MAX_RETRIES_SETTING ;
9394import static org .elasticsearch .repositories .s3 .S3ClientSettings .READ_TIMEOUT_SETTING ;
9495import static org .hamcrest .Matchers .allOf ;
@@ -163,6 +164,7 @@ protected BlobContainer createBlobContainer(
163164 final @ Nullable Integer maxRetries ,
164165 final @ Nullable TimeValue readTimeout ,
165166 final @ Nullable Boolean disableChunkedEncoding ,
167+ final @ Nullable Integer maxConnections ,
166168 final @ Nullable ByteSizeValue bufferSize ,
167169 final @ Nullable Integer maxBulkDeletes ,
168170 final @ Nullable BlobPath blobContainerPath
@@ -183,6 +185,9 @@ protected BlobContainer createBlobContainer(
183185 if (disableChunkedEncoding != null ) {
184186 clientSettings .put (DISABLE_CHUNKED_ENCODING .getConcreteSettingForNamespace (clientName ).getKey (), disableChunkedEncoding );
185187 }
188+ if (maxConnections != null ) {
189+ clientSettings .put (MAX_CONNECTIONS_SETTING .getConcreteSettingForNamespace (clientName ).getKey (), maxConnections );
190+ }
186191
187192 final MockSecureSettings secureSettings = new MockSecureSettings ();
188193 secureSettings .setString (
@@ -265,7 +270,7 @@ public void testWriteBlobWithRetries() throws Exception {
265270 final int maxRetries = randomInt (5 );
266271 final CountDown countDown = new CountDown (maxRetries + 1 );
267272
268- final BlobContainer blobContainer = createBlobContainer (maxRetries , null , true , null , null , null );
273+ final BlobContainer blobContainer = createBlobContainer (maxRetries , null , true , null , null , null , null );
269274
270275 final byte [] bytes = randomBlobContent ();
271276 httpServer .createContext (downloadStorageEndpoint (blobContainer , "write_blob_max_retries" ), exchange -> {
@@ -313,7 +318,7 @@ public void testWriteBlobWithRetries() throws Exception {
313318 public void testWriteBlobWithReadTimeouts () {
314319 final byte [] bytes = randomByteArrayOfLength (randomIntBetween (10 , 128 ));
315320 final TimeValue readTimeout = TimeValue .timeValueMillis (randomIntBetween (100 , 500 ));
316- final BlobContainer blobContainer = createBlobContainer (1 , readTimeout , true , null , null , null );
321+ final BlobContainer blobContainer = createBlobContainer (1 , readTimeout , true , null , null , null , null );
317322
318323 // HTTP server does not send a response
319324 httpServer .createContext (downloadStorageEndpoint (blobContainer , "write_blob_timeout" ), exchange -> {
@@ -347,7 +352,7 @@ public void testWriteLargeBlob() throws Exception {
347352 final boolean useTimeout = rarely ();
348353 final TimeValue readTimeout = useTimeout ? TimeValue .timeValueMillis (randomIntBetween (100 , 500 )) : null ;
349354 final ByteSizeValue bufferSize = ByteSizeValue .of (5 , ByteSizeUnit .MB );
350- final BlobContainer blobContainer = createBlobContainer (null , readTimeout , true , bufferSize , null , null );
355+ final BlobContainer blobContainer = createBlobContainer (null , readTimeout , true , null , bufferSize , null , null );
351356
352357 final int parts = randomIntBetween (1 , 5 );
353358 final long lastPartSize = randomLongBetween (10 , 512 );
@@ -443,7 +448,7 @@ public void testWriteLargeBlobStreaming() throws Exception {
443448 final boolean useTimeout = rarely ();
444449 final TimeValue readTimeout = useTimeout ? TimeValue .timeValueMillis (randomIntBetween (100 , 500 )) : null ;
445450 final ByteSizeValue bufferSize = ByteSizeValue .of (5 , ByteSizeUnit .MB );
446- final BlobContainer blobContainer = createBlobContainer (null , readTimeout , true , bufferSize , null , null );
451+ final BlobContainer blobContainer = createBlobContainer (null , readTimeout , true , null , bufferSize , null , null );
447452
448453 final int parts = randomIntBetween (1 , 5 );
449454 final long lastPartSize = randomLongBetween (10 , 512 );
@@ -552,7 +557,15 @@ public void testReadRetriesAfterMeaningfulProgress() throws Exception {
552557 0 ,
553558 randomFrom (1000 , Math .toIntExact (S3Repository .BUFFER_SIZE_SETTING .get (Settings .EMPTY ).getBytes ()))
554559 );
555- final BlobContainer blobContainer = createBlobContainer (maxRetries , null , true , ByteSizeValue .ofBytes (bufferSizeBytes ), null , null );
560+ final BlobContainer blobContainer = createBlobContainer (
561+ maxRetries ,
562+ null ,
563+ true ,
564+ null ,
565+ ByteSizeValue .ofBytes (bufferSizeBytes ),
566+ null ,
567+ null
568+ );
556569 final int meaningfulProgressBytes = Math .max (1 , bufferSizeBytes / 100 );
557570
558571 final byte [] bytes = randomBlobContent ();
@@ -625,7 +638,15 @@ public void testReadDoesNotRetryForRepositoryAnalysis() {
625638 0 ,
626639 randomFrom (1000 , Math .toIntExact (S3Repository .BUFFER_SIZE_SETTING .get (Settings .EMPTY ).getBytes ()))
627640 );
628- final BlobContainer blobContainer = createBlobContainer (maxRetries , null , true , ByteSizeValue .ofBytes (bufferSizeBytes ), null , null );
641+ final BlobContainer blobContainer = createBlobContainer (
642+ maxRetries ,
643+ null ,
644+ true ,
645+ null ,
646+ ByteSizeValue .ofBytes (bufferSizeBytes ),
647+ null ,
648+ null
649+ );
629650
630651 final byte [] bytes = randomBlobContent ();
631652
@@ -663,7 +684,15 @@ public void testReadWithIndicesPurposeRetriesForever() throws IOException {
663684 0 ,
664685 randomFrom (1000 , Math .toIntExact (S3Repository .BUFFER_SIZE_SETTING .get (Settings .EMPTY ).getBytes ()))
665686 );
666- final BlobContainer blobContainer = createBlobContainer (maxRetries , null , true , ByteSizeValue .ofBytes (bufferSizeBytes ), null , null );
687+ final BlobContainer blobContainer = createBlobContainer (
688+ maxRetries ,
689+ null ,
690+ true ,
691+ null ,
692+ ByteSizeValue .ofBytes (bufferSizeBytes ),
693+ null ,
694+ null
695+ );
667696 final int meaningfulProgressBytes = Math .max (1 , bufferSizeBytes / 100 );
668697
669698 final byte [] bytes = randomBlobContent (512 );
@@ -756,7 +785,7 @@ public void handle(HttpExchange exchange) throws IOException {
756785
757786 public void testDoesNotRetryOnNotFound () {
758787 final int maxRetries = between (3 , 5 );
759- final BlobContainer blobContainer = createBlobContainer (maxRetries , null , true , null , null , null );
788+ final BlobContainer blobContainer = createBlobContainer (maxRetries , null , true , null , null , null , null );
760789
761790 final AtomicInteger numberOfReads = new AtomicInteger (0 );
762791 @ SuppressForbidden (reason = "use a http server" )
@@ -788,7 +817,7 @@ public void handle(HttpExchange exchange) throws IOException {
788817
789818 public void testSnapshotDeletesRetryOnThrottlingError () throws IOException {
790819 // disable AWS-client retries
791- final BlobContainer blobContainer = createBlobContainer (0 , null , true , null , null , null );
820+ final BlobContainer blobContainer = createBlobContainer (0 , null , true , null , null , null , null );
792821
793822 int numBlobsToDelete = randomIntBetween (500 , 3000 );
794823 List <String > blobsToDelete = new ArrayList <>();
@@ -808,7 +837,7 @@ public void testSnapshotDeletesRetryOnThrottlingError() throws IOException {
808837
809838 public void testSnapshotDeletesAbortRetriesWhenThreadIsInterrupted () {
810839 // disable AWS-client retries
811- final BlobContainer blobContainer = createBlobContainer (0 , null , true , null , null , null );
840+ final BlobContainer blobContainer = createBlobContainer (0 , null , true , null , null , null , null );
812841
813842 int numBlobsToDelete = randomIntBetween (500 , 3000 );
814843 List <String > blobsToDelete = new ArrayList <>();
@@ -845,7 +874,7 @@ public void testSnapshotDeletesAbortRetriesWhenThreadIsInterrupted() {
845874
846875 public void testNonSnapshotDeletesAreNotRetried () {
847876 // disable AWS-client retries
848- final BlobContainer blobContainer = createBlobContainer (0 , null , true , null , null , null );
877+ final BlobContainer blobContainer = createBlobContainer (0 , null , true , null , null , null , null );
849878
850879 int numBlobsToDelete = randomIntBetween (500 , 3000 );
851880 List <String > blobsToDelete = new ArrayList <>();
@@ -874,7 +903,7 @@ public void testNonSnapshotDeletesAreNotRetried() {
874903
875904 public void testNonThrottlingErrorsAreNotRetried () {
876905 // disable AWS-client retries
877- final BlobContainer blobContainer = createBlobContainer (0 , null , true , null , null , null );
906+ final BlobContainer blobContainer = createBlobContainer (0 , null , true , null , null , null , null );
878907
879908 int numBlobsToDelete = randomIntBetween (500 , 3000 );
880909 List <String > blobsToDelete = new ArrayList <>();
@@ -953,7 +982,7 @@ private Set<OperationPurpose> operationPurposesThatRetryOnDelete() {
953982
954983 public void testGetRegisterRetries () {
955984 final var maxRetries = between (0 , 3 );
956- final BlobContainer blobContainer = createBlobContainer (maxRetries , null , null , null , null , null );
985+ final BlobContainer blobContainer = createBlobContainer (maxRetries , null , null , null , null , null , null );
957986
958987 interface FailingHandlerFactory {
959988 void addHandler (String blobName , Integer ... responseCodes );
@@ -1023,7 +1052,7 @@ interface FailingHandlerFactory {
10231052 public void testSuppressedDeletionErrorsAreCapped () {
10241053 final TimeValue readTimeout = TimeValue .timeValueMillis (randomIntBetween (100 , 500 ));
10251054 int maxBulkDeleteSize = randomIntBetween (1 , 10 );
1026- final BlobContainer blobContainer = createBlobContainer (1 , readTimeout , true , null , maxBulkDeleteSize , null );
1055+ final BlobContainer blobContainer = createBlobContainer (1 , readTimeout , true , null , null , maxBulkDeleteSize , null );
10271056 httpServer .createContext ("/" , exchange -> {
10281057 if (isMultiDeleteRequest (exchange )) {
10291058 exchange .sendResponseHeaders (
@@ -1055,7 +1084,7 @@ public void testSuppressedDeletionErrorsAreCapped() {
10551084 public void testTrimmedLogAndCappedSuppressedErrorOnMultiObjectDeletionException () {
10561085 final TimeValue readTimeout = TimeValue .timeValueMillis (randomIntBetween (100 , 500 ));
10571086 int maxBulkDeleteSize = randomIntBetween (10 , 30 );
1058- final BlobContainer blobContainer = createBlobContainer (1 , readTimeout , true , null , maxBulkDeleteSize , null );
1087+ final BlobContainer blobContainer = createBlobContainer (1 , readTimeout , true , null , null , maxBulkDeleteSize , null );
10591088
10601089 final Pattern pattern = Pattern .compile ("<Key>(.+?)</Key>" );
10611090 httpServer .createContext ("/" , exchange -> {
0 commit comments