@@ -164,7 +164,8 @@ protected BlobContainer createBlobContainer(
164164 final @ Nullable TimeValue readTimeout ,
165165 final @ Nullable Boolean disableChunkedEncoding ,
166166 final @ Nullable ByteSizeValue bufferSize ,
167- final @ Nullable Integer maxBulkDeletes
167+ final @ Nullable Integer maxBulkDeletes ,
168+ final @ Nullable BlobPath blobContainerPath
168169 ) {
169170 final Settings .Builder clientSettings = Settings .builder ();
170171 final String clientName = randomAlphaOfLength (5 ).toLowerCase (Locale .ROOT );
@@ -216,7 +217,10 @@ protected BlobContainer createBlobContainer(
216217 new S3RepositoriesMetrics (new RepositoriesMetrics (recordingMeterRegistry )),
217218 BackoffPolicy .constantBackoff (TimeValue .timeValueMillis (1 ), MAX_NUMBER_SNAPSHOT_DELETE_RETRIES )
218219 );
219- return new S3BlobContainer (randomBoolean () ? BlobPath .EMPTY : BlobPath .EMPTY .add ("foo" ), s3BlobStore ) {
220+ return new S3BlobContainer (
221+ Objects .requireNonNullElse (blobContainerPath , randomBoolean () ? BlobPath .EMPTY : BlobPath .EMPTY .add ("foo" )),
222+ s3BlobStore
223+ ) {
220224 @ Override
221225 public InputStream readBlob (OperationPurpose purpose , String blobName ) throws IOException {
222226 return new AssertingInputStream (new S3RetryingInputStream (purpose , s3BlobStore , buildKey (blobName )) {
@@ -261,7 +265,7 @@ public void testWriteBlobWithRetries() throws Exception {
261265 final int maxRetries = randomInt (5 );
262266 final CountDown countDown = new CountDown (maxRetries + 1 );
263267
264- final BlobContainer blobContainer = createBlobContainer (maxRetries , null , true , null , null );
268+ final BlobContainer blobContainer = createBlobContainer (maxRetries , null , true , null , null , null );
265269
266270 final byte [] bytes = randomBlobContent ();
267271 httpServer .createContext (downloadStorageEndpoint (blobContainer , "write_blob_max_retries" ), exchange -> {
@@ -309,7 +313,7 @@ public void testWriteBlobWithRetries() throws Exception {
309313 public void testWriteBlobWithReadTimeouts () {
310314 final byte [] bytes = randomByteArrayOfLength (randomIntBetween (10 , 128 ));
311315 final TimeValue readTimeout = TimeValue .timeValueMillis (randomIntBetween (100 , 500 ));
312- final BlobContainer blobContainer = createBlobContainer (1 , readTimeout , true , null , null );
316+ final BlobContainer blobContainer = createBlobContainer (1 , readTimeout , true , null , null , null );
313317
314318 // HTTP server does not send a response
315319 httpServer .createContext (downloadStorageEndpoint (blobContainer , "write_blob_timeout" ), exchange -> {
@@ -343,7 +347,7 @@ public void testWriteLargeBlob() throws Exception {
343347 final boolean useTimeout = rarely ();
344348 final TimeValue readTimeout = useTimeout ? TimeValue .timeValueMillis (randomIntBetween (100 , 500 )) : null ;
345349 final ByteSizeValue bufferSize = ByteSizeValue .of (5 , ByteSizeUnit .MB );
346- final BlobContainer blobContainer = createBlobContainer (null , readTimeout , true , bufferSize , null );
350+ final BlobContainer blobContainer = createBlobContainer (null , readTimeout , true , bufferSize , null , null );
347351
348352 final int parts = randomIntBetween (1 , 5 );
349353 final long lastPartSize = randomLongBetween (10 , 512 );
@@ -439,7 +443,7 @@ public void testWriteLargeBlobStreaming() throws Exception {
439443 final boolean useTimeout = rarely ();
440444 final TimeValue readTimeout = useTimeout ? TimeValue .timeValueMillis (randomIntBetween (100 , 500 )) : null ;
441445 final ByteSizeValue bufferSize = ByteSizeValue .of (5 , ByteSizeUnit .MB );
442- final BlobContainer blobContainer = createBlobContainer (null , readTimeout , true , bufferSize , null );
446+ final BlobContainer blobContainer = createBlobContainer (null , readTimeout , true , bufferSize , null , null );
443447
444448 final int parts = randomIntBetween (1 , 5 );
445449 final long lastPartSize = randomLongBetween (10 , 512 );
@@ -548,7 +552,7 @@ public void testReadRetriesAfterMeaningfulProgress() throws Exception {
548552 0 ,
549553 randomFrom (1000 , Math .toIntExact (S3Repository .BUFFER_SIZE_SETTING .get (Settings .EMPTY ).getBytes ()))
550554 );
551- final BlobContainer blobContainer = createBlobContainer (maxRetries , null , true , ByteSizeValue .ofBytes (bufferSizeBytes ), null );
555+ final BlobContainer blobContainer = createBlobContainer (maxRetries , null , true , ByteSizeValue .ofBytes (bufferSizeBytes ), null , null );
552556 final int meaningfulProgressBytes = Math .max (1 , bufferSizeBytes / 100 );
553557
554558 final byte [] bytes = randomBlobContent ();
@@ -621,7 +625,7 @@ public void testReadDoesNotRetryForRepositoryAnalysis() {
621625 0 ,
622626 randomFrom (1000 , Math .toIntExact (S3Repository .BUFFER_SIZE_SETTING .get (Settings .EMPTY ).getBytes ()))
623627 );
624- final BlobContainer blobContainer = createBlobContainer (maxRetries , null , true , ByteSizeValue .ofBytes (bufferSizeBytes ), null );
628+ final BlobContainer blobContainer = createBlobContainer (maxRetries , null , true , ByteSizeValue .ofBytes (bufferSizeBytes ), null , null );
625629
626630 final byte [] bytes = randomBlobContent ();
627631
@@ -659,7 +663,7 @@ public void testReadWithIndicesPurposeRetriesForever() throws IOException {
659663 0 ,
660664 randomFrom (1000 , Math .toIntExact (S3Repository .BUFFER_SIZE_SETTING .get (Settings .EMPTY ).getBytes ()))
661665 );
662- final BlobContainer blobContainer = createBlobContainer (maxRetries , null , true , ByteSizeValue .ofBytes (bufferSizeBytes ), null );
666+ final BlobContainer blobContainer = createBlobContainer (maxRetries , null , true , ByteSizeValue .ofBytes (bufferSizeBytes ), null , null );
663667 final int meaningfulProgressBytes = Math .max (1 , bufferSizeBytes / 100 );
664668
665669 final byte [] bytes = randomBlobContent (512 );
@@ -752,7 +756,7 @@ public void handle(HttpExchange exchange) throws IOException {
752756
753757 public void testDoesNotRetryOnNotFound () {
754758 final int maxRetries = between (3 , 5 );
755- final BlobContainer blobContainer = createBlobContainer (maxRetries , null , true , null , null );
759+ final BlobContainer blobContainer = createBlobContainer (maxRetries , null , true , null , null , null );
756760
757761 final AtomicInteger numberOfReads = new AtomicInteger (0 );
758762 @ SuppressForbidden (reason = "use a http server" )
@@ -784,7 +788,7 @@ public void handle(HttpExchange exchange) throws IOException {
784788
785789 public void testSnapshotDeletesRetryOnThrottlingError () throws IOException {
786790 // disable AWS-client retries
787- final BlobContainer blobContainer = createBlobContainer (0 , null , true , null , null );
791+ final BlobContainer blobContainer = createBlobContainer (0 , null , true , null , null , null );
788792
789793 int numBlobsToDelete = randomIntBetween (500 , 3000 );
790794 List <String > blobsToDelete = new ArrayList <>();
@@ -804,7 +808,7 @@ public void testSnapshotDeletesRetryOnThrottlingError() throws IOException {
804808
805809 public void testSnapshotDeletesAbortRetriesWhenThreadIsInterrupted () {
806810 // disable AWS-client retries
807- final BlobContainer blobContainer = createBlobContainer (0 , null , true , null , null );
811+ final BlobContainer blobContainer = createBlobContainer (0 , null , true , null , null , null );
808812
809813 int numBlobsToDelete = randomIntBetween (500 , 3000 );
810814 List <String > blobsToDelete = new ArrayList <>();
@@ -841,7 +845,7 @@ public void testSnapshotDeletesAbortRetriesWhenThreadIsInterrupted() {
841845
842846 public void testNonSnapshotDeletesAreNotRetried () {
843847 // disable AWS-client retries
844- final BlobContainer blobContainer = createBlobContainer (0 , null , true , null , null );
848+ final BlobContainer blobContainer = createBlobContainer (0 , null , true , null , null , null );
845849
846850 int numBlobsToDelete = randomIntBetween (500 , 3000 );
847851 List <String > blobsToDelete = new ArrayList <>();
@@ -870,7 +874,7 @@ public void testNonSnapshotDeletesAreNotRetried() {
870874
871875 public void testNonThrottlingErrorsAreNotRetried () {
872876 // disable AWS-client retries
873- final BlobContainer blobContainer = createBlobContainer (0 , null , true , null , null );
877+ final BlobContainer blobContainer = createBlobContainer (0 , null , true , null , null , null );
874878
875879 int numBlobsToDelete = randomIntBetween (500 , 3000 );
876880 List <String > blobsToDelete = new ArrayList <>();
@@ -949,7 +953,7 @@ private Set<OperationPurpose> operationPurposesThatRetryOnDelete() {
949953
950954 public void testGetRegisterRetries () {
951955 final var maxRetries = between (0 , 3 );
952- final BlobContainer blobContainer = createBlobContainer (maxRetries , null , null , null , null );
956+ final BlobContainer blobContainer = createBlobContainer (maxRetries , null , null , null , null , null );
953957
954958 interface FailingHandlerFactory {
955959 void addHandler (String blobName , Integer ... responseCodes );
@@ -1019,7 +1023,7 @@ interface FailingHandlerFactory {
10191023 public void testSuppressedDeletionErrorsAreCapped () {
10201024 final TimeValue readTimeout = TimeValue .timeValueMillis (randomIntBetween (100 , 500 ));
10211025 int maxBulkDeleteSize = randomIntBetween (1 , 10 );
1022- final BlobContainer blobContainer = createBlobContainer (1 , readTimeout , true , null , maxBulkDeleteSize );
1026+ final BlobContainer blobContainer = createBlobContainer (1 , readTimeout , true , null , maxBulkDeleteSize , null );
10231027 httpServer .createContext ("/" , exchange -> {
10241028 if (isMultiDeleteRequest (exchange )) {
10251029 exchange .sendResponseHeaders (
@@ -1051,7 +1055,7 @@ public void testSuppressedDeletionErrorsAreCapped() {
10511055 public void testTrimmedLogAndCappedSuppressedErrorOnMultiObjectDeletionException () {
10521056 final TimeValue readTimeout = TimeValue .timeValueMillis (randomIntBetween (100 , 500 ));
10531057 int maxBulkDeleteSize = randomIntBetween (10 , 30 );
1054- final BlobContainer blobContainer = createBlobContainer (1 , readTimeout , true , null , maxBulkDeleteSize );
1058+ final BlobContainer blobContainer = createBlobContainer (1 , readTimeout , true , null , maxBulkDeleteSize , null );
10551059
10561060 final Pattern pattern = Pattern .compile ("<Key>(.+?)</Key>" );
10571061 httpServer .createContext ("/" , exchange -> {
0 commit comments