Skip to content

Commit e5f65a5

Browse files
committed
Update integration tests to use host.testcontainers.internal
Motivation While I was running the integration test, I found out that `host.docker.internal` doesn't work correctly on Linux. (It worked on Mac and Windows.) `host.docker.internal` is used for the container to access the host but the DNS resolution was keeping failing. While I was debugging on it, I also found out that the Testcontainers provides `host.testcontainers.internal` for the same purpose and there's no reason not to use it. https://java.testcontainers.org/features/networking/ Modification - Use `host.testcontainers.internal` instead of `host.docker.internal` Result - The integration tests now run successfully on Linux.
1 parent 95048ae commit e5f65a5

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

server/src/test/java/io/envoyproxy/controlplane/server/EnvoyContainer.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.util.function.Supplier;
55
import org.slf4j.Logger;
66
import org.slf4j.LoggerFactory;
7+
import org.testcontainers.Testcontainers;
78
import org.testcontainers.containers.BindMode;
89
import org.testcontainers.containers.GenericContainer;
910
import org.testcontainers.containers.output.Slf4jLogConsumer;
@@ -36,11 +37,11 @@ protected void configure() {
3637
withClasspathResourceMapping(LAUNCH_ENVOY_SCRIPT, LAUNCH_ENVOY_SCRIPT_DEST, BindMode.READ_ONLY);
3738
withClasspathResourceMapping(config, CONFIG_DEST, BindMode.READ_ONLY);
3839

39-
withExtraHost("host.docker.internal","host-gateway");
40-
40+
final Integer controlPlanePort = controlPlanePortSupplier.get();
41+
Testcontainers.exposeHostPorts(controlPlanePort);
4142
withCommand(
4243
"/bin/bash", "/usr/local/bin/launch_envoy.sh",
43-
Integer.toString(controlPlanePortSupplier.get()),
44+
Integer.toString(controlPlanePort),
4445
CONFIG_DEST,
4546
"-l", "debug"
4647
);

server/src/test/resources/envoy/ads.v3.config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static_resources:
2929
- endpoint:
3030
address:
3131
socket_address:
32-
address: host.docker.internal
32+
address: host.testcontainers.internal
3333
port_value: HOST_PORT
3434
http2_protocol_options: {}
3535
name: ads_cluster

server/src/test/resources/envoy/ads.v3.delta.config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static_resources:
2929
- endpoint:
3030
address:
3131
socket_address:
32-
address: host.docker.internal
32+
address: host.testcontainers.internal
3333
port_value: HOST_PORT
3434
http2_protocol_options: {}
3535
name: ads_cluster

server/src/test/resources/envoy/xds.v3.config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static_resources:
3333
- endpoint:
3434
address:
3535
socket_address:
36-
address: host.docker.internal
36+
address: host.testcontainers.internal
3737
port_value: HOST_PORT
3838
http2_protocol_options: {}
3939
name: xds_cluster

server/src/test/resources/envoy/xds.v3.delta.config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static_resources:
3333
- endpoint:
3434
address:
3535
socket_address:
36-
address: host.docker.internal
36+
address: host.testcontainers.internal
3737
port_value: HOST_PORT
3838
http2_protocol_options: {}
3939
name: xds_cluster

0 commit comments

Comments
 (0)