@@ -155,7 +155,8 @@ protected BlobContainer createBlobContainer(
155155 final @ Nullable TimeValue readTimeout ,
156156 final @ Nullable Boolean disableChunkedEncoding ,
157157 final @ Nullable ByteSizeValue bufferSize ,
158- final @ Nullable Integer maxBulkDeletes
158+ final @ Nullable Integer maxBulkDeletes ,
159+ final @ Nullable BlobPath blobContainerPath
159160 ) {
160161 final Settings .Builder clientSettings = Settings .builder ();
161162 final String clientName = randomAlphaOfLength (5 ).toLowerCase (Locale .ROOT );
@@ -204,7 +205,10 @@ protected BlobContainer createBlobContainer(
204205 new DeterministicTaskQueue ().getThreadPool (),
205206 new S3RepositoriesMetrics (new RepositoriesMetrics (recordingMeterRegistry ))
206207 );
207- return new S3BlobContainer (randomBoolean () ? BlobPath .EMPTY : BlobPath .EMPTY .add ("foo" ), s3BlobStore ) {
208+ return new S3BlobContainer (
209+ Objects .requireNonNullElse (blobContainerPath , randomBoolean () ? BlobPath .EMPTY : BlobPath .EMPTY .add ("foo" )),
210+ s3BlobStore
211+ ) {
208212 @ Override
209213 public InputStream readBlob (OperationPurpose purpose , String blobName ) throws IOException {
210214 return new AssertingInputStream (new S3RetryingInputStream (purpose , s3BlobStore , buildKey (blobName )) {
@@ -249,7 +253,7 @@ public void testWriteBlobWithRetries() throws Exception {
249253 final int maxRetries = randomInt (5 );
250254 final CountDown countDown = new CountDown (maxRetries + 1 );
251255
252- final BlobContainer blobContainer = createBlobContainer (maxRetries , null , true , null , null );
256+ final BlobContainer blobContainer = createBlobContainer (maxRetries , null , true , null , null , null );
253257
254258 final byte [] bytes = randomBlobContent ();
255259 httpServer .createContext (downloadStorageEndpoint (blobContainer , "write_blob_max_retries" ), exchange -> {
@@ -297,7 +301,7 @@ public void testWriteBlobWithRetries() throws Exception {
297301 public void testWriteBlobWithReadTimeouts () {
298302 final byte [] bytes = randomByteArrayOfLength (randomIntBetween (10 , 128 ));
299303 final TimeValue readTimeout = TimeValue .timeValueMillis (randomIntBetween (100 , 500 ));
300- final BlobContainer blobContainer = createBlobContainer (1 , readTimeout , true , null , null );
304+ final BlobContainer blobContainer = createBlobContainer (1 , readTimeout , true , null , null , null );
301305
302306 // HTTP server does not send a response
303307 httpServer .createContext (downloadStorageEndpoint (blobContainer , "write_blob_timeout" ), exchange -> {
@@ -331,7 +335,7 @@ public void testWriteLargeBlob() throws Exception {
331335 final boolean useTimeout = rarely ();
332336 final TimeValue readTimeout = useTimeout ? TimeValue .timeValueMillis (randomIntBetween (100 , 500 )) : null ;
333337 final ByteSizeValue bufferSize = new ByteSizeValue (5 , ByteSizeUnit .MB );
334- final BlobContainer blobContainer = createBlobContainer (null , readTimeout , true , bufferSize , null );
338+ final BlobContainer blobContainer = createBlobContainer (null , readTimeout , true , bufferSize , null , null );
335339
336340 final int parts = randomIntBetween (1 , 5 );
337341 final long lastPartSize = randomLongBetween (10 , 512 );
@@ -427,7 +431,7 @@ public void testWriteLargeBlobStreaming() throws Exception {
427431 final boolean useTimeout = rarely ();
428432 final TimeValue readTimeout = useTimeout ? TimeValue .timeValueMillis (randomIntBetween (100 , 500 )) : null ;
429433 final ByteSizeValue bufferSize = new ByteSizeValue (5 , ByteSizeUnit .MB );
430- final BlobContainer blobContainer = createBlobContainer (null , readTimeout , true , bufferSize , null );
434+ final BlobContainer blobContainer = createBlobContainer (null , readTimeout , true , bufferSize , null , null );
431435
432436 final int parts = randomIntBetween (1 , 5 );
433437 final long lastPartSize = randomLongBetween (10 , 512 );
@@ -536,7 +540,7 @@ public void testReadRetriesAfterMeaningfulProgress() throws Exception {
536540 0 ,
537541 randomFrom (1000 , Math .toIntExact (S3Repository .BUFFER_SIZE_SETTING .get (Settings .EMPTY ).getBytes ()))
538542 );
539- final BlobContainer blobContainer = createBlobContainer (maxRetries , null , true , ByteSizeValue .ofBytes (bufferSizeBytes ), null );
543+ final BlobContainer blobContainer = createBlobContainer (maxRetries , null , true , ByteSizeValue .ofBytes (bufferSizeBytes ), null , null );
540544 final int meaningfulProgressBytes = Math .max (1 , bufferSizeBytes / 100 );
541545
542546 final byte [] bytes = randomBlobContent ();
@@ -609,7 +613,7 @@ public void testReadDoesNotRetryForRepositoryAnalysis() {
609613 0 ,
610614 randomFrom (1000 , Math .toIntExact (S3Repository .BUFFER_SIZE_SETTING .get (Settings .EMPTY ).getBytes ()))
611615 );
612- final BlobContainer blobContainer = createBlobContainer (maxRetries , null , true , ByteSizeValue .ofBytes (bufferSizeBytes ), null );
616+ final BlobContainer blobContainer = createBlobContainer (maxRetries , null , true , ByteSizeValue .ofBytes (bufferSizeBytes ), null , null );
613617
614618 final byte [] bytes = randomBlobContent ();
615619
@@ -647,7 +651,7 @@ public void testReadWithIndicesPurposeRetriesForever() throws IOException {
647651 0 ,
648652 randomFrom (1000 , Math .toIntExact (S3Repository .BUFFER_SIZE_SETTING .get (Settings .EMPTY ).getBytes ()))
649653 );
650- final BlobContainer blobContainer = createBlobContainer (maxRetries , null , true , ByteSizeValue .ofBytes (bufferSizeBytes ), null );
654+ final BlobContainer blobContainer = createBlobContainer (maxRetries , null , true , ByteSizeValue .ofBytes (bufferSizeBytes ), null , null );
651655 final int meaningfulProgressBytes = Math .max (1 , bufferSizeBytes / 100 );
652656
653657 final byte [] bytes = randomBlobContent (512 );
@@ -740,7 +744,7 @@ public void handle(HttpExchange exchange) throws IOException {
740744
741745 public void testDoesNotRetryOnNotFound () {
742746 final int maxRetries = between (3 , 5 );
743- final BlobContainer blobContainer = createBlobContainer (maxRetries , null , true , null , null );
747+ final BlobContainer blobContainer = createBlobContainer (maxRetries , null , true , null , null , null );
744748
745749 final AtomicInteger numberOfReads = new AtomicInteger (0 );
746750 @ SuppressForbidden (reason = "use a http server" )
@@ -773,7 +777,7 @@ public void handle(HttpExchange exchange) throws IOException {
773777 public void testSuppressedDeletionErrorsAreCapped () {
774778 final TimeValue readTimeout = TimeValue .timeValueMillis (randomIntBetween (100 , 500 ));
775779 int maxBulkDeleteSize = randomIntBetween (1 , 10 );
776- final BlobContainer blobContainer = createBlobContainer (1 , readTimeout , true , null , maxBulkDeleteSize );
780+ final BlobContainer blobContainer = createBlobContainer (1 , readTimeout , true , null , maxBulkDeleteSize , null );
777781 httpServer .createContext ("/" , exchange -> {
778782 if (isMultiDeleteRequest (exchange )) {
779783 exchange .sendResponseHeaders (
@@ -805,7 +809,7 @@ public void testSuppressedDeletionErrorsAreCapped() {
805809 public void testTrimmedLogAndCappedSuppressedErrorOnMultiObjectDeletionException () {
806810 final TimeValue readTimeout = TimeValue .timeValueMillis (randomIntBetween (100 , 500 ));
807811 int maxBulkDeleteSize = randomIntBetween (10 , 30 );
808- final BlobContainer blobContainer = createBlobContainer (1 , readTimeout , true , null , maxBulkDeleteSize );
812+ final BlobContainer blobContainer = createBlobContainer (1 , readTimeout , true , null , maxBulkDeleteSize , null );
809813
810814 final Pattern pattern = Pattern .compile ("<Key>(.+?)</Key>" );
811815 httpServer .createContext ("/" , exchange -> {
0 commit comments