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: Update java integration tests and add more logging #2637

Merged
merged 1 commit into from
May 5, 2022
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 @@ -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