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 c00dc7b1f3..cffa2ae3af 100644 --- a/java/serving/src/test/java/feast/serving/it/ServingEnvironment.java +++ b/java/serving/src/test/java/feast/serving/it/ServingEnvironment.java @@ -39,13 +39,14 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.testcontainers.containers.DockerComposeContainer; +import org.testcontainers.containers.output.OutputFrame; import org.testcontainers.containers.wait.strategy.Wait; import org.testcontainers.junit.jupiter.Testcontainers; @Testcontainers abstract class ServingEnvironment { static DockerComposeContainer environment; - + static int serverPort = getFreePort(); ServingServiceGrpc.ServingServiceBlockingStub servingStub; Injector injector; String serverName; @@ -53,8 +54,6 @@ abstract class ServingEnvironment { Server server; MutableHandlerRegistry serviceRegistry; - static int serverPort = getFreePort(); - @BeforeAll static void globalSetup() { environment = @@ -62,7 +61,8 @@ static void globalSetup() { new File("src/test/resources/docker-compose/docker-compose-redis-it.yml")) .withExposedService("redis", 6379) .withExposedService("feast", 8080) - .waitingFor("feast", Wait.forListeningPort()); + .waitingFor("feast", Wait.forListeningPort()) + .withLogConsumer("feast", f -> System.out.print(((OutputFrame) f).getUtf8String())); environment.start(); } @@ -71,6 +71,20 @@ static void globalTeardown() { environment.stop(); } + private static int getFreePort() { + ServerSocket serverSocket; + try { + serverSocket = new ServerSocket(0); + } catch (IOException e) { + throw new RuntimeException("Couldn't allocate port"); + } + + assertThat(serverSocket, is(notNullValue())); + assertThat(serverSocket.getLocalPort(), greaterThan(0)); + + return serverSocket.getLocalPort(); + } + @BeforeEach public void envSetUp() throws Exception { AbstractModule appPropertiesModule = @@ -155,18 +169,4 @@ public void envTeardown() throws Exception { AbstractModule registryConfig() { return null; } - - private static int getFreePort() { - ServerSocket serverSocket; - try { - serverSocket = new ServerSocket(0); - } catch (IOException e) { - throw new RuntimeException("Couldn't allocate port"); - } - - assertThat(serverSocket, is(notNullValue())); - assertThat(serverSocket.getLocalPort(), greaterThan(0)); - - return serverSocket.getLocalPort(); - } } diff --git a/java/serving/src/test/resources/docker-compose/docker-compose-redis-it.yml b/java/serving/src/test/resources/docker-compose/docker-compose-redis-it.yml index 1dee243cb8..5c9ab18cdf 100644 --- a/java/serving/src/test/resources/docker-compose/docker-compose-redis-it.yml +++ b/java/serving/src/test/resources/docker-compose/docker-compose-redis-it.yml @@ -5,11 +5,11 @@ services: image: redis:6.2 command: redis-server --requirepass testpw ports: - - "6379:6379" + - "6379" feast: build: feast10 ports: - - "8080:8080" + - "8080" links: - redis