1
1
package io .eigr .spawn ;
2
2
3
- import com .github .dockerjava .api .model .HostConfig ;
4
- import com .github .dockerjava .api .model .PortBinding ;
5
3
import io .eigr .spawn .api .Spawn ;
6
4
import io .eigr .spawn .api .TransportOpts ;
7
5
import io .eigr .spawn .api .exceptions .SpawnException ;
@@ -24,16 +22,13 @@ public abstract class AbstractContainerBaseTest {
24
22
private static GenericContainer <?> SPAWN_CONTAINER ;
25
23
private static final String spawnProxyImage = "eigr/spawn-proxy:1.4.1-rc.1" ;
26
24
private static final String userFunctionPort = "8091" ;
27
- private static final String spawnProxyPort = "9004" ;
28
25
protected static Spawn spawnSystem ;
29
26
protected static final String spawnSystemName = "spawn-system-test" ;
30
27
31
28
static {
32
29
Testcontainers .exposeHostPorts (8091 );
33
30
34
31
SPAWN_CONTAINER = new GenericContainer <>(DockerImageName .parse (spawnProxyImage ))
35
- .withCreateContainerCmdModifier (e -> e .withHostConfig (HostConfig .newHostConfig ()
36
- .withPortBindings (PortBinding .parse ("9004:9004" ))))
37
32
.waitingFor (new LogMessageWaitStrategy ()
38
33
.withRegEx (".*Proxy Application started successfully.*" ))
39
34
.withEnv ("SPAWN_PROXY_LOGGER_LEVEL" , "DEBUG" )
@@ -44,13 +39,12 @@ public abstract class AbstractContainerBaseTest {
44
39
.withEnv ("NODE_COOKIE" , "cookie-9ce3712b0c3ee21b582c30f942c0d4da-HLuZyQzy+nt0p0r/PVVFTp2tqfLom5igrdmwkYSuO+Q=" )
45
40
.withEnv ("POD_NAMESPACE" , spawnSystemName )
46
41
.withEnv ("POD_IP" , spawnSystemName )
47
- .withEnv ("PROXY_HTTP_PORT" , spawnProxyPort )
42
+ .withEnv ("PROXY_HTTP_PORT" , "9004" )
48
43
.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 );
54
48
SPAWN_CONTAINER .start ();
55
49
56
50
DependencyInjector injector = SimpleDependencyInjector .createInjector ();
@@ -65,8 +59,9 @@ public abstract class AbstractContainerBaseTest {
65
59
.withActor (StatelessNamedActor .class )
66
60
.withTerminationGracePeriodSeconds (5 )
67
61
.withTransportOptions (TransportOpts .builder ()
62
+ .host (SPAWN_CONTAINER .getHost ())
68
63
.port (8091 )
69
- .proxyPort (9004 )
64
+ .proxyPort (SPAWN_CONTAINER . getMappedPort ( 9004 ) )
70
65
.build ())
71
66
.build ();
72
67
0 commit comments