Skip to content

Commit

Permalink
Always specify a region.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock committed Jun 9, 2023
1 parent d3a757f commit 6b8dcae
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,12 @@
@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST)
public class S3BlobStoreRepositoryTests extends OpenSearchMockAPIBasedRepositoryIntegTestCase {

private String region;
private final String region = "test-region";
private String signerOverride;
private String previousOpenSearchPathConf;

@Override
public void setUp() throws Exception {
if (randomBoolean()) {
region = "test-region";
}
signerOverride = AwsRequestSigner.VERSION_FOUR_SIGNER.getName();
previousOpenSearchPathConf = SocketAccess.doPrivileged(() -> System.setProperty("opensearch.path.conf", "config"));
super.setUp();
Expand Down Expand Up @@ -147,9 +144,8 @@ protected Settings nodeSettings(int nodeOrdinal) {
if (signerOverride != null) {
builder.put(S3ClientSettings.SIGNER_OVERRIDE.getConcreteSettingForNamespace("test").getKey(), signerOverride);
}
if (region != null) {
builder.put(S3ClientSettings.REGION.getConcreteSettingForNamespace("test").getKey(), region);
}

builder.put(S3ClientSettings.REGION.getConcreteSettingForNamespace("test").getKey(), region);
return builder.build();
}

Expand Down Expand Up @@ -218,7 +214,7 @@ private void validateAuthHeader(HttpExchange exchange) {
if ("AWS4SignerType".equals(signerOverride)) {
assertThat(authorizationHeaderV4, containsString("aws4_request"));
}
if (region != null && authorizationHeaderV4 != null) {
if (authorizationHeaderV4 != null) {
assertThat(authorizationHeaderV4, containsString("/" + region + "/s3/"));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
import static org.hamcrest.Matchers.is;
import static org.opensearch.repositories.s3.S3ClientSettings.DISABLE_CHUNKED_ENCODING;
import static org.opensearch.repositories.s3.S3ClientSettings.ENDPOINT_SETTING;
import static org.opensearch.repositories.s3.S3ClientSettings.REGION;
import static org.opensearch.repositories.s3.S3ClientSettings.MAX_RETRIES_SETTING;
import static org.opensearch.repositories.s3.S3ClientSettings.READ_TIMEOUT_SETTING;

Expand Down Expand Up @@ -133,6 +134,7 @@ protected BlobContainer createBlobContainer(
final InetSocketAddress address = httpServer.getAddress();
final String endpoint = "http://" + InetAddresses.toUriString(address.getAddress()) + ":" + address.getPort();
clientSettings.put(ENDPOINT_SETTING.getConcreteSettingForNamespace(clientName).getKey(), endpoint);
clientSettings.put(REGION.getConcreteSettingForNamespace(clientName).getKey(), "region");

if (maxRetries != null) {
clientSettings.put(MAX_RETRIES_SETTING.getConcreteSettingForNamespace(clientName).getKey(), maxRetries);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
public class S3ServiceTests extends AbstractS3RepositoryTestCase {
public void testCachedClientsAreReleased() {
final S3Service s3Service = new S3Service(configPath());
final Settings settings = Settings.builder().put("endpoint", "http://first").build();
final Settings settings = Settings.builder().put("endpoint", "http://first").put("region", "region").build();
final RepositoryMetadata metadata1 = new RepositoryMetadata("first", "s3", settings);
final RepositoryMetadata metadata2 = new RepositoryMetadata("second", "s3", settings);
final S3ClientSettings clientSettings = s3Service.settings(metadata2);
Expand Down

0 comments on commit 6b8dcae

Please sign in to comment.