Skip to content

Commit

Permalink
fix: Get container host addresses from testcontainers (java) (#4125)
Browse files Browse the repository at this point in the history
  • Loading branch information
tokoko authored Apr 21, 2024
1 parent 2b6f1d0 commit 9184dde
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ static void globalSetup() {
.withExposedService(
"feast", 8080, Wait.forListeningPort().withStartupTimeout(Duration.ofSeconds(180)))
.withTailChildContainers(true);

if (System.getenv("FEAST_TESTCONTAINERS_LOCAL_COMPOSE") != null) {
environment = environment.withLocalCompose(true);
}

environment.start();
}

Expand Down Expand Up @@ -136,7 +141,7 @@ ApplicationProperties applicationProperties() {
server = injector.getInstance(Server.class);
server.start();

channel = ManagedChannelBuilder.forAddress("localhost", serverPort).usePlaintext().build();
channel = ManagedChannelBuilder.forAddress("127.0.0.1", serverPort).usePlaintext().build();

servingStub =
ServingServiceGrpc.newBlockingStub(channel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ private static BlobServiceClient createClient() {
return new BlobServiceClientBuilder()
.endpoint(
String.format(
"http://localhost:%d/%s",
azureBlobMock.getMappedPort(BLOB_STORAGE_PORT), TEST_ACCOUNT_NAME))
"http://%s:%d/%s",
azureBlobMock.getHost(),
azureBlobMock.getMappedPort(BLOB_STORAGE_PORT),
TEST_ACCOUNT_NAME))
.credential(CREDENTIAL)
.buildClient();
}
Expand Down Expand Up @@ -95,8 +97,10 @@ public BlobServiceClient awsStorage() {
return new BlobServiceClientBuilder()
.endpoint(
String.format(
"http://localhost:%d/%s",
azureBlobMock.getMappedPort(BLOB_STORAGE_PORT), TEST_ACCOUNT_NAME))
"http://%s:%d/%s",
azureBlobMock.getHost(),
azureBlobMock.getMappedPort(BLOB_STORAGE_PORT),
TEST_ACCOUNT_NAME))
.credential(CREDENTIAL)
.buildClient();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private static Storage createClient() {
return StorageOptions.newBuilder()
.setProjectId(TEST_PROJECT)
.setCredentials(ServiceAccountCredentials.create(credential))
.setHost("http://localhost:" + gcsMock.getMappedPort(GCS_PORT))
.setHost(String.format("http://%s:%d", gcsMock.getHost(), gcsMock.getMappedPort(GCS_PORT)))
.build()
.getService();
}
Expand Down Expand Up @@ -89,7 +89,8 @@ Storage googleStorage(ApplicationProperties applicationProperties) {
return StorageOptions.newBuilder()
.setProjectId(TEST_PROJECT)
.setCredentials(ServiceAccountCredentials.create(credential))
.setHost("http://localhost:" + gcsMock.getMappedPort(GCS_PORT))
.setHost(
String.format("http://%s:%d", gcsMock.getHost(), gcsMock.getMappedPort(GCS_PORT)))
.build()
.getService();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ private static AmazonS3 createClient() {
return AmazonS3ClientBuilder.standard()
.withEndpointConfiguration(
new AwsClientBuilder.EndpointConfiguration(
String.format("http://localhost:%d", s3Mock.getHttpServerPort()), TEST_REGION))
String.format("http://%s:%d", s3Mock.getHost(), s3Mock.getHttpServerPort()),
TEST_REGION))
.withCredentials(credentials)
.enablePathStyleAccess()
.build();
Expand Down Expand Up @@ -89,7 +90,8 @@ public AmazonS3 awsStorage() {
return AmazonS3ClientBuilder.standard()
.withEndpointConfiguration(
new AwsClientBuilder.EndpointConfiguration(
String.format("http://localhost:%d", s3Mock.getHttpServerPort()), TEST_REGION))
String.format("http://%s:%d", s3Mock.getHost(), s3Mock.getHttpServerPort()),
TEST_REGION))
.withCredentials(credentials)
.enablePathStyleAccess()
.build();
Expand Down

0 comments on commit 9184dde

Please sign in to comment.