Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Get container host addresses from testcontainers (java) #4125

Merged
merged 1 commit into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: f-strings are a little nicer in many ways.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😄 this is java, i don't think there's a better option

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♂️ this is what I get for reviewing PRs before coffee

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
Loading