From 40ddc198006ab3c96921733f71f34da790030179 Mon Sep 17 00:00:00 2001 From: minwoox Date: Wed, 13 Dec 2023 14:36:49 +0900 Subject: [PATCH] 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. Signed-off-by: minwoox --- .../io/envoyproxy/controlplane/server/EnvoyContainer.java | 7 ++++--- server/src/test/resources/envoy/ads.v3.config.yaml | 2 +- server/src/test/resources/envoy/ads.v3.delta.config.yaml | 2 +- server/src/test/resources/envoy/xds.v3.config.yaml | 2 +- server/src/test/resources/envoy/xds.v3.delta.config.yaml | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/server/src/test/java/io/envoyproxy/controlplane/server/EnvoyContainer.java b/server/src/test/java/io/envoyproxy/controlplane/server/EnvoyContainer.java index 7906b360b..b0423cbd9 100644 --- a/server/src/test/java/io/envoyproxy/controlplane/server/EnvoyContainer.java +++ b/server/src/test/java/io/envoyproxy/controlplane/server/EnvoyContainer.java @@ -4,6 +4,7 @@ import java.util.function.Supplier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.testcontainers.Testcontainers; import org.testcontainers.containers.BindMode; import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.output.Slf4jLogConsumer; @@ -36,11 +37,11 @@ protected void configure() { withClasspathResourceMapping(LAUNCH_ENVOY_SCRIPT, LAUNCH_ENVOY_SCRIPT_DEST, BindMode.READ_ONLY); withClasspathResourceMapping(config, CONFIG_DEST, BindMode.READ_ONLY); - withExtraHost("host.docker.internal","host-gateway"); - + final Integer controlPlanePort = controlPlanePortSupplier.get(); + Testcontainers.exposeHostPorts(controlPlanePort); withCommand( "/bin/bash", "/usr/local/bin/launch_envoy.sh", - Integer.toString(controlPlanePortSupplier.get()), + Integer.toString(controlPlanePort), CONFIG_DEST, "-l", "debug" ); diff --git a/server/src/test/resources/envoy/ads.v3.config.yaml b/server/src/test/resources/envoy/ads.v3.config.yaml index 794d3ec25..dcaf48865 100644 --- a/server/src/test/resources/envoy/ads.v3.config.yaml +++ b/server/src/test/resources/envoy/ads.v3.config.yaml @@ -29,7 +29,7 @@ static_resources: - endpoint: address: socket_address: - address: host.docker.internal + address: host.testcontainers.internal port_value: HOST_PORT http2_protocol_options: {} name: ads_cluster diff --git a/server/src/test/resources/envoy/ads.v3.delta.config.yaml b/server/src/test/resources/envoy/ads.v3.delta.config.yaml index cfced3abc..d5627e987 100644 --- a/server/src/test/resources/envoy/ads.v3.delta.config.yaml +++ b/server/src/test/resources/envoy/ads.v3.delta.config.yaml @@ -29,7 +29,7 @@ static_resources: - endpoint: address: socket_address: - address: host.docker.internal + address: host.testcontainers.internal port_value: HOST_PORT http2_protocol_options: {} name: ads_cluster diff --git a/server/src/test/resources/envoy/xds.v3.config.yaml b/server/src/test/resources/envoy/xds.v3.config.yaml index b862da640..fd59f85e8 100644 --- a/server/src/test/resources/envoy/xds.v3.config.yaml +++ b/server/src/test/resources/envoy/xds.v3.config.yaml @@ -33,7 +33,7 @@ static_resources: - endpoint: address: socket_address: - address: host.docker.internal + address: host.testcontainers.internal port_value: HOST_PORT http2_protocol_options: {} name: xds_cluster diff --git a/server/src/test/resources/envoy/xds.v3.delta.config.yaml b/server/src/test/resources/envoy/xds.v3.delta.config.yaml index 95bf086b2..93d9f00e6 100644 --- a/server/src/test/resources/envoy/xds.v3.delta.config.yaml +++ b/server/src/test/resources/envoy/xds.v3.delta.config.yaml @@ -33,7 +33,7 @@ static_resources: - endpoint: address: socket_address: - address: host.docker.internal + address: host.testcontainers.internal port_value: HOST_PORT http2_protocol_options: {} name: xds_cluster