Skip to content

Commit

Permalink
fix: Update java integration tests and add more logging (#2637)
Browse files Browse the repository at this point in the history
Signed-off-by: Achal Shah <achals@gmail.com>
  • Loading branch information
achals authored May 5, 2022
1 parent 4fbdfb1 commit 10e23b4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
36 changes: 18 additions & 18 deletions java/serving/src/test/java/feast/serving/it/ServingEnvironment.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,30 @@
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;
ManagedChannel channel;
Server server;
MutableHandlerRegistry serviceRegistry;

static int serverPort = getFreePort();

@BeforeAll
static void globalSetup() {
environment =
new DockerComposeContainer(
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();
}

Expand All @@ -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 =
Expand Down Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 10e23b4

Please sign in to comment.