Skip to content

Commit 2f5f843

Browse files
Tests: Remove AWS region derivation in REST container and clean up catalog properties
1 parent 4a74c68 commit 2f5f843

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

testing/trino-testing-containers/src/main/java/io/trino/testing/containers/IcebergRestCatalogBackendContainer.java

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
import com.google.common.collect.ImmutableSet;
1818
import org.testcontainers.containers.Network;
1919

20+
import java.util.Locale;
21+
import java.util.Map;
2022
import java.util.Optional;
2123

2224
import static io.trino.testing.containers.Minio.MINIO_REGION;
@@ -36,16 +38,16 @@ public IcebergRestCatalogBackendContainer(
3638
"iceberg-rest",
3739
ImmutableSet.of(8181),
3840
ImmutableMap.of(),
39-
ImmutableMap.of(
40-
"CATALOG_INCLUDE__CREDENTIALS", "true",
41-
"CATALOG_WAREHOUSE", warehouseLocation,
42-
"CATALOG_IO__IMPL", "org.apache.iceberg.aws.s3.S3FileIO",
43-
"AWS_REGION", MINIO_REGION,
44-
"CATALOG_S3_ACCESS__KEY__ID", minioAccessKey,
45-
"CATALOG_S3_SECRET__ACCESS__KEY", minioSecretKey,
46-
"CATALOG_S3_SESSION__TOKEN", minioSessionToken,
47-
"CATALOG_S3_ENDPOINT", "http://minio:4566",
48-
"CATALOG_S3_PATH__STYLE__ACCESS", "true"),
41+
toCatalogEnvVars(ImmutableMap.of(
42+
"include-credentials", "true",
43+
"warehouse", warehouseLocation,
44+
"io-impl", "org.apache.iceberg.aws.s3.S3FileIO",
45+
"s3.access-key-id", minioAccessKey,
46+
"s3.secret-access-key", minioSecretKey,
47+
"s3.session-token", minioSessionToken,
48+
"s3.endpoint", "http://minio:4566",
49+
"s3.path-style-access", "true",
50+
"client.region", MINIO_REGION)),
4951
network,
5052
5);
5153
}
@@ -54,4 +56,18 @@ public String getRestCatalogEndpoint()
5456
{
5557
return getMappedHostAndPortForExposedPort(8181).toString();
5658
}
59+
60+
private static Map<String, String> toCatalogEnvVars(Map<String, String> properties)
61+
{
62+
ImmutableMap.Builder<String, String> envVars = ImmutableMap.builder();
63+
properties.forEach((key, value) -> {
64+
String envVarName = "CATALOG_" +
65+
key.toUpperCase(Locale.ROOT)
66+
.replaceAll("-", "__")
67+
.replaceAll("\\.", "_");
68+
69+
envVars.put(envVarName, value);
70+
});
71+
return envVars.buildOrThrow();
72+
}
5773
}

0 commit comments

Comments
 (0)