Skip to content

Commit 31bf3a9

Browse files
committed
fix: Fix java integration tests and add more logging
Signed-off-by: Achal Shah <achals@gmail.com>
1 parent 4fbdfb1 commit 31bf3a9

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

java/serving/src/test/java/feast/serving/it/ServingEnvironment.java

+18-18
Original file line numberDiff line numberDiff line change
@@ -39,30 +39,30 @@
3939
import org.junit.jupiter.api.BeforeAll;
4040
import org.junit.jupiter.api.BeforeEach;
4141
import org.testcontainers.containers.DockerComposeContainer;
42+
import org.testcontainers.containers.output.OutputFrame;
4243
import org.testcontainers.containers.wait.strategy.Wait;
4344
import org.testcontainers.junit.jupiter.Testcontainers;
4445

4546
@Testcontainers
4647
abstract class ServingEnvironment {
4748
static DockerComposeContainer environment;
48-
49+
static int serverPort = getFreePort();
4950
ServingServiceGrpc.ServingServiceBlockingStub servingStub;
5051
Injector injector;
5152
String serverName;
5253
ManagedChannel channel;
5354
Server server;
5455
MutableHandlerRegistry serviceRegistry;
5556

56-
static int serverPort = getFreePort();
57-
5857
@BeforeAll
5958
static void globalSetup() {
6059
environment =
6160
new DockerComposeContainer(
6261
new File("src/test/resources/docker-compose/docker-compose-redis-it.yml"))
6362
.withExposedService("redis", 6379)
6463
.withExposedService("feast", 8080)
65-
.waitingFor("feast", Wait.forListeningPort());
64+
.waitingFor("feast", Wait.forListeningPort())
65+
.withLogConsumer("feast", f -> System.out.print(((OutputFrame) f).getUtf8String()));
6666
environment.start();
6767
}
6868

@@ -71,6 +71,20 @@ static void globalTeardown() {
7171
environment.stop();
7272
}
7373

74+
private static int getFreePort() {
75+
ServerSocket serverSocket;
76+
try {
77+
serverSocket = new ServerSocket(0);
78+
} catch (IOException e) {
79+
throw new RuntimeException("Couldn't allocate port");
80+
}
81+
82+
assertThat(serverSocket, is(notNullValue()));
83+
assertThat(serverSocket.getLocalPort(), greaterThan(0));
84+
85+
return serverSocket.getLocalPort();
86+
}
87+
7488
@BeforeEach
7589
public void envSetUp() throws Exception {
7690
AbstractModule appPropertiesModule =
@@ -155,18 +169,4 @@ public void envTeardown() throws Exception {
155169
AbstractModule registryConfig() {
156170
return null;
157171
}
158-
159-
private static int getFreePort() {
160-
ServerSocket serverSocket;
161-
try {
162-
serverSocket = new ServerSocket(0);
163-
} catch (IOException e) {
164-
throw new RuntimeException("Couldn't allocate port");
165-
}
166-
167-
assertThat(serverSocket, is(notNullValue()));
168-
assertThat(serverSocket.getLocalPort(), greaterThan(0));
169-
170-
return serverSocket.getLocalPort();
171-
}
172172
}

java/serving/src/test/resources/docker-compose/docker-compose-redis-it.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ services:
55
image: redis:6.2
66
command: redis-server --requirepass testpw
77
ports:
8-
- "6379:6379"
8+
- "6379"
99
feast:
1010
build: feast10
1111
ports:
12-
- "8080:8080"
12+
- "8080"
1313
links:
1414
- redis
1515

0 commit comments

Comments
 (0)