Skip to content

Commit 9778d70

Browse files
committed
Update testcontainers config.
1 parent 53177c2 commit 9778d70

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/test/java/io/eigr/spawn/AbstractContainerBaseTest.java

+7-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package io.eigr.spawn;
22

3-
import com.github.dockerjava.api.model.HostConfig;
4-
import com.github.dockerjava.api.model.PortBinding;
53
import io.eigr.spawn.api.Spawn;
64
import io.eigr.spawn.api.TransportOpts;
75
import io.eigr.spawn.api.exceptions.SpawnException;
@@ -24,16 +22,13 @@ public abstract class AbstractContainerBaseTest {
2422
private static GenericContainer<?> SPAWN_CONTAINER;
2523
private static final String spawnProxyImage = "eigr/spawn-proxy:1.4.1-rc.1";
2624
private static final String userFunctionPort = "8091";
27-
private static final String spawnProxyPort = "9004";
2825
protected static Spawn spawnSystem;
2926
protected static final String spawnSystemName = "spawn-system-test";
3027

3128
static {
3229
Testcontainers.exposeHostPorts(8091);
3330

3431
SPAWN_CONTAINER = new GenericContainer<>(DockerImageName.parse(spawnProxyImage))
35-
.withCreateContainerCmdModifier(e -> e.withHostConfig(HostConfig.newHostConfig()
36-
.withPortBindings(PortBinding.parse("9004:9004"))))
3732
.waitingFor(new LogMessageWaitStrategy()
3833
.withRegEx(".*Proxy Application started successfully.*"))
3934
.withEnv("SPAWN_PROXY_LOGGER_LEVEL", "DEBUG")
@@ -44,13 +39,12 @@ public abstract class AbstractContainerBaseTest {
4439
.withEnv("NODE_COOKIE", "cookie-9ce3712b0c3ee21b582c30f942c0d4da-HLuZyQzy+nt0p0r/PVVFTp2tqfLom5igrdmwkYSuO+Q=")
4540
.withEnv("POD_NAMESPACE", spawnSystemName)
4641
.withEnv("POD_IP", spawnSystemName)
47-
.withEnv("PROXY_HTTP_PORT", spawnProxyPort)
42+
.withEnv("PROXY_HTTP_PORT", "9004")
4843
.withEnv("USER_FUNCTION_PORT", userFunctionPort)
49-
.withEnv("USER_FUNCTION_HOST", "host.docker.internal") // Docker
50-
.withExtraHost("host.docker.internal", "host-gateway") // Docker
51-
// .withEnv("USER_FUNCTION_HOST", "host.containers.internal") // Podman
52-
// .withExtraHost("host.containers.internal", "host-gateway") // Podman
53-
.withExposedPorts(9004);
44+
.withEnv("USER_FUNCTION_HOST", "host.testcontainers.internal")
45+
.withExtraHost("host.testcontainers.internal", "host-gateway")
46+
.withExposedPorts(9004)
47+
.withAccessToHost(true);
5448
SPAWN_CONTAINER.start();
5549

5650
DependencyInjector injector = SimpleDependencyInjector.createInjector();
@@ -65,8 +59,9 @@ public abstract class AbstractContainerBaseTest {
6559
.withActor(StatelessNamedActor.class)
6660
.withTerminationGracePeriodSeconds(5)
6761
.withTransportOptions(TransportOpts.builder()
62+
.host(SPAWN_CONTAINER.getHost())
6863
.port(8091)
69-
.proxyPort(9004)
64+
.proxyPort(SPAWN_CONTAINER.getMappedPort(9004))
7065
.build())
7166
.build();
7267

0 commit comments

Comments
 (0)