Skip to content

Commit 9184dde

Browse files
authored
fix: Get container host addresses from testcontainers (java) (#4125)
1 parent 2b6f1d0 commit 9184dde

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

java/serving/src/test/java/feast/serving/it/ServingEnvironment.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ static void globalSetup() {
6363
.withExposedService(
6464
"feast", 8080, Wait.forListeningPort().withStartupTimeout(Duration.ofSeconds(180)))
6565
.withTailChildContainers(true);
66+
67+
if (System.getenv("FEAST_TESTCONTAINERS_LOCAL_COMPOSE") != null) {
68+
environment = environment.withLocalCompose(true);
69+
}
70+
6671
environment.start();
6772
}
6873

@@ -136,7 +141,7 @@ ApplicationProperties applicationProperties() {
136141
server = injector.getInstance(Server.class);
137142
server.start();
138143

139-
channel = ManagedChannelBuilder.forAddress("localhost", serverPort).usePlaintext().build();
144+
channel = ManagedChannelBuilder.forAddress("127.0.0.1", serverPort).usePlaintext().build();
140145

141146
servingStub =
142147
ServingServiceGrpc.newBlockingStub(channel)

java/serving/src/test/java/feast/serving/it/ServingRedisAzureRegistryIT.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@ private static BlobServiceClient createClient() {
5050
return new BlobServiceClientBuilder()
5151
.endpoint(
5252
String.format(
53-
"http://localhost:%d/%s",
54-
azureBlobMock.getMappedPort(BLOB_STORAGE_PORT), TEST_ACCOUNT_NAME))
53+
"http://%s:%d/%s",
54+
azureBlobMock.getHost(),
55+
azureBlobMock.getMappedPort(BLOB_STORAGE_PORT),
56+
TEST_ACCOUNT_NAME))
5557
.credential(CREDENTIAL)
5658
.buildClient();
5759
}
@@ -95,8 +97,10 @@ public BlobServiceClient awsStorage() {
9597
return new BlobServiceClientBuilder()
9698
.endpoint(
9799
String.format(
98-
"http://localhost:%d/%s",
99-
azureBlobMock.getMappedPort(BLOB_STORAGE_PORT), TEST_ACCOUNT_NAME))
100+
"http://%s:%d/%s",
101+
azureBlobMock.getHost(),
102+
azureBlobMock.getMappedPort(BLOB_STORAGE_PORT),
103+
TEST_ACCOUNT_NAME))
100104
.credential(CREDENTIAL)
101105
.buildClient();
102106
}

java/serving/src/test/java/feast/serving/it/ServingRedisGSRegistryIT.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ private static Storage createClient() {
6161
return StorageOptions.newBuilder()
6262
.setProjectId(TEST_PROJECT)
6363
.setCredentials(ServiceAccountCredentials.create(credential))
64-
.setHost("http://localhost:" + gcsMock.getMappedPort(GCS_PORT))
64+
.setHost(String.format("http://%s:%d", gcsMock.getHost(), gcsMock.getMappedPort(GCS_PORT)))
6565
.build()
6666
.getService();
6767
}
@@ -89,7 +89,8 @@ Storage googleStorage(ApplicationProperties applicationProperties) {
8989
return StorageOptions.newBuilder()
9090
.setProjectId(TEST_PROJECT)
9191
.setCredentials(ServiceAccountCredentials.create(credential))
92-
.setHost("http://localhost:" + gcsMock.getMappedPort(GCS_PORT))
92+
.setHost(
93+
String.format("http://%s:%d", gcsMock.getHost(), gcsMock.getMappedPort(GCS_PORT)))
9394
.build()
9495
.getService();
9596
}

java/serving/src/test/java/feast/serving/it/ServingRedisS3RegistryIT.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ private static AmazonS3 createClient() {
4242
return AmazonS3ClientBuilder.standard()
4343
.withEndpointConfiguration(
4444
new AwsClientBuilder.EndpointConfiguration(
45-
String.format("http://localhost:%d", s3Mock.getHttpServerPort()), TEST_REGION))
45+
String.format("http://%s:%d", s3Mock.getHost(), s3Mock.getHttpServerPort()),
46+
TEST_REGION))
4647
.withCredentials(credentials)
4748
.enablePathStyleAccess()
4849
.build();
@@ -89,7 +90,8 @@ public AmazonS3 awsStorage() {
8990
return AmazonS3ClientBuilder.standard()
9091
.withEndpointConfiguration(
9192
new AwsClientBuilder.EndpointConfiguration(
92-
String.format("http://localhost:%d", s3Mock.getHttpServerPort()), TEST_REGION))
93+
String.format("http://%s:%d", s3Mock.getHost(), s3Mock.getHttpServerPort()),
94+
TEST_REGION))
9395
.withCredentials(credentials)
9496
.enablePathStyleAccess()
9597
.build();

0 commit comments

Comments
 (0)