From ca45474b558f41e8bdf92b1976d1e13a6aab40db Mon Sep 17 00:00:00 2001 From: tokoko Date: Sun, 21 Apr 2024 05:37:42 +0000 Subject: [PATCH] get container host from testcontainets in java it tests Signed-off-by: tokoko --- .../java/feast/serving/it/ServingEnvironment.java | 7 ++++++- .../serving/it/ServingRedisAzureRegistryIT.java | 12 ++++++++---- .../feast/serving/it/ServingRedisGSRegistryIT.java | 5 +++-- .../feast/serving/it/ServingRedisS3RegistryIT.java | 6 ++++-- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/java/serving/src/test/java/feast/serving/it/ServingEnvironment.java b/java/serving/src/test/java/feast/serving/it/ServingEnvironment.java index 43b82345c6..5489203856 100644 --- a/java/serving/src/test/java/feast/serving/it/ServingEnvironment.java +++ b/java/serving/src/test/java/feast/serving/it/ServingEnvironment.java @@ -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(); } @@ -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) diff --git a/java/serving/src/test/java/feast/serving/it/ServingRedisAzureRegistryIT.java b/java/serving/src/test/java/feast/serving/it/ServingRedisAzureRegistryIT.java index 8ab658fc2a..0b1ecca7d2 100644 --- a/java/serving/src/test/java/feast/serving/it/ServingRedisAzureRegistryIT.java +++ b/java/serving/src/test/java/feast/serving/it/ServingRedisAzureRegistryIT.java @@ -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(); } @@ -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(); } diff --git a/java/serving/src/test/java/feast/serving/it/ServingRedisGSRegistryIT.java b/java/serving/src/test/java/feast/serving/it/ServingRedisGSRegistryIT.java index 96aa2077c0..b3f185bbda 100644 --- a/java/serving/src/test/java/feast/serving/it/ServingRedisGSRegistryIT.java +++ b/java/serving/src/test/java/feast/serving/it/ServingRedisGSRegistryIT.java @@ -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(); } @@ -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(); } diff --git a/java/serving/src/test/java/feast/serving/it/ServingRedisS3RegistryIT.java b/java/serving/src/test/java/feast/serving/it/ServingRedisS3RegistryIT.java index 52e1af9065..67ba11128f 100644 --- a/java/serving/src/test/java/feast/serving/it/ServingRedisS3RegistryIT.java +++ b/java/serving/src/test/java/feast/serving/it/ServingRedisS3RegistryIT.java @@ -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(); @@ -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();