diff --git a/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/config/envoy/EnvoyAdmin.kt b/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/config/envoy/EnvoyAdmin.kt index 9b613108c..675e23cc6 100644 --- a/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/config/envoy/EnvoyAdmin.kt +++ b/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/config/envoy/EnvoyAdmin.kt @@ -49,7 +49,7 @@ class EnvoyAdmin( fun isIngressReady() = statValue("http.ingress_http.rq_total") != "-1" - fun statValue(statName: String): String? = get("stats?filter=$statName").body()?.use { + fun statValue(statName: String): String? = get("stats?filter=^$statName$").body()?.use { val splitedStats = it.string().lines().first().split(":") if (splitedStats.size != 2) { return "-1" diff --git a/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/config/envoy/EnvoyContainer.kt b/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/config/envoy/EnvoyContainer.kt index 2998cc67b..1116cf856 100644 --- a/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/config/envoy/EnvoyContainer.kt +++ b/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/config/envoy/EnvoyContainer.kt @@ -18,7 +18,7 @@ class EnvoyContainer( image: String = DEFAULT_IMAGE ) : SSLGenericContainer(dockerfileBuilder = DockerfileBuilder() .from(image) - .run("apk --no-cache add curl iproute2") + .run("apt-get update && apt-get install -y curl iproute2 iptables") ) { companion object { @@ -32,7 +32,7 @@ class EnvoyContainer( const val EGRESS_LISTENER_CONTAINER_PORT = 5000 const val INGRESS_LISTENER_CONTAINER_PORT = 5001 - const val DEFAULT_IMAGE = "envoyproxy/envoy-alpine:v1.14.3" + const val DEFAULT_IMAGE = "marcinfalkowski/envoy-dev:v1.16.1-dev-lua-segfault-fix-1-16-0-backport-20201118-df9dc819" private const val ADMIN_PORT = 10000 } diff --git a/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/config/testcontainers/GenericContainer.kt b/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/config/testcontainers/GenericContainer.kt index 2730d5cc6..df82472eb 100644 --- a/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/config/testcontainers/GenericContainer.kt +++ b/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/config/testcontainers/GenericContainer.kt @@ -64,7 +64,7 @@ open class GenericContainer> : BaseGenericContaine val result = execInContainer(HOST_IP_SCRIPT_DEST) if (result.stderr.isNotEmpty() or result.stdout.isEmpty()) { - throw ContainerUnableToObtainHostIpException() + throw ContainerUnableToObtainHostIpException("stderr: ${result.stderr}") } return result.stdout.trim() @@ -123,7 +123,10 @@ open class GenericContainer> : BaseGenericContaine fun runCommands(commands: Array) { commands.forEach { command -> - execInContainer(*(command.split(" ").toTypedArray())) + val result = execInContainer(*(command.split(" ").toTypedArray())) + if (result.exitCode != 0) { + throw CommandFailedException(command, result.exitCode, result.stdout, result.stderr, this.containerName()) + } } } @@ -143,4 +146,13 @@ open class GenericContainer> : BaseGenericContaine fun containerName() = containerId.substring(0, 12) } -class ContainerUnableToObtainHostIpException : RuntimeException() +class ContainerUnableToObtainHostIpException(msg: String) : RuntimeException(msg) +class CommandFailedException( + cmd: String, + exitCode: Int, + stdout: String, + stderr: String, + containerName: String +) : RuntimeException( + "Command '$cmd' failed in container $containerName with exit code $exitCode; stderr: $stderr, stdout: $stdout" +) diff --git a/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/reliability/ReliabilityTest.kt b/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/reliability/ReliabilityTest.kt index 5ff4d786d..1e84fbbb3 100644 --- a/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/reliability/ReliabilityTest.kt +++ b/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/reliability/ReliabilityTest.kt @@ -79,7 +79,7 @@ open class ReliabilityTest : EnvoyControlTestConfiguration() { fun cleanup() { ((consulMastersInDc1 + consulMastersInDc2).map { it.container - } + listOf(envoyContainer1, echoContainer, echoContainer2)).forEach { + } + listOf(envoyContainer1)).forEach { it.sigcont() it.clearAllIptablesRules() } diff --git a/envoy-control-tests/src/main/resources/envoy/launch_envoy.sh b/envoy-control-tests/src/main/resources/envoy/launch_envoy.sh index 093894f49..54152d189 100755 --- a/envoy-control-tests/src/main/resources/envoy/launch_envoy.sh +++ b/envoy-control-tests/src/main/resources/envoy/launch_envoy.sh @@ -2,7 +2,7 @@ set -eu -HOST_IP=$(sh /usr/local/bin/host_ip.sh) +HOST_IP=$(bash /usr/local/bin/host_ip.sh) HOST_PORT=$1 HOST2_PORT=$2 diff --git a/tools/docker-compose.yaml b/tools/docker-compose.yaml index dd6f40746..2fcfd885d 100644 --- a/tools/docker-compose.yaml +++ b/tools/docker-compose.yaml @@ -25,8 +25,8 @@ services: dockerfile: Dockerfile ports: - "9999:9999" - - "31000:80" - - "31001:8080" + - "31000:31000" + - "31001:31001" envoy-control: container_name: envoy-control diff --git a/tools/envoy/Dockerfile b/tools/envoy/Dockerfile index cb805c7a5..7b6d0312d 100644 --- a/tools/envoy/Dockerfile +++ b/tools/envoy/Dockerfile @@ -1,11 +1,11 @@ -FROM envoyproxy/envoy-alpine:v1.14.3 +FROM marcinfalkowski/envoy-dev:v1.16.1-dev-lua-segfault-fix-1-16-0-backport-20201118-df9dc819 ENV PORT=9999:9999 ENV PORT=80:80 ENV ENVOY_NODE_ID=front-proxy-id ENV ENVOY_NODE_CLUSTER=front-proxy -ENV ENVOY_EGRESS_LISTENER_PORT=80 -ENV ENVOY_INGRESS_LISTENER_PORT=8080 +ENV ENVOY_EGRESS_LISTENER_PORT=31000 +ENV ENVOY_INGRESS_LISTENER_PORT=31001 ENV ENVOY_ADMIN_PORT=9999 ENV ENVOY_XDS_PORT=50000 ENV ENVOY_XDS_HOST=host.docker.internal diff --git a/tools/envoy/envoy-template.yaml b/tools/envoy/envoy-template.yaml index 76ce3d0ca..b013ca7e7 100644 --- a/tools/envoy/envoy-template.yaml +++ b/tools/envoy/envoy-template.yaml @@ -33,7 +33,7 @@ static_resources: access_log: name: envoy.file_access_log config: - path: "./envoy/ingress-access.log" + path: "/home/envoy/ingress-access.log" format: > [%START_TIME%] %PROTOCOL% %REQ(:METHOD)% %REQ(:authority)% %REQ(:PATH)% %RESPONSE_CODE% %RESPONSE_FLAGS% %BYTES_RECEIVED%b %BYTES_SENT%b %DURATION%ms "%DOWNSTREAM_REMOTE_ADDRESS%" -> "%UPSTREAM_HOST%"