Allow overriding blob container path in tests (#126391)

Some `AbstractBlobContainerRetriesTestCase#createBlobContainer`
implementations choose a path for the container randomly, but we have a
need for a test which re-creates the same container against a different
`S3Service` and `BlobStore` and must therefore specify the same path
each time. This commit exposes a parameter that lets callers specify a
container path.
This commit is contained in:
David Turner 2025-04-07 18:54:37 +01:00 committed by GitHub
parent 5dc7ab77b3
commit fbbbdd7eec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 47 additions and 35 deletions

View file

@ -29,6 +29,7 @@ import java.net.InetSocketAddress;
import java.net.MalformedURLException;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.util.Objects;
import static org.hamcrest.Matchers.either;
import static org.hamcrest.Matchers.instanceOf;
@ -77,7 +78,8 @@ public class URLBlobContainerRetriesTests extends AbstractBlobContainerRetriesTe
TimeValue readTimeout,
Boolean disableChunkedEncoding,
ByteSizeValue bufferSize,
Integer maxBulkDeletes
Integer maxBulkDeletes,
BlobPath blobContainerPath
) {
Settings.Builder settingsBuilder = Settings.builder();
@ -98,7 +100,7 @@ public class URLBlobContainerRetriesTests extends AbstractBlobContainerRetriesTe
factory.create(httpClientSettings),
httpClientSettings
);
return urlBlobStore.blobContainer(BlobPath.EMPTY);
return urlBlobStore.blobContainer(Objects.requireNonNullElse(blobContainerPath, BlobPath.EMPTY));
} catch (MalformedURLException e) {
throw new RuntimeException("Unable to create URLBlobStore", e);
}