From 0fe262f26af1e54407c1e040ebe4b02b64f6b27f Mon Sep 17 00:00:00 2001 From: Franco Bruno Lavayen Date: Thu, 8 Sep 2022 17:17:38 -0300 Subject: [PATCH] [CONSUL-412] Run test-sds-server in single container (#48) --- .../Dockerfile-consul-dev-windows | 5 ++++- .../envoy/Dockerfile-test-sds-server-windows | 4 ++-- .../connect/envoy/helpers.windows.bash | 11 +++++++---- .../connect/envoy/run-tests.windows.sh | 17 +++++++++-------- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/build-support-windows/Dockerfile-consul-dev-windows b/build-support-windows/Dockerfile-consul-dev-windows index b97f630856ec..6f5489240826 100644 --- a/build-support-windows/Dockerfile-consul-dev-windows +++ b/build-support-windows/Dockerfile-consul-dev-windows @@ -17,9 +17,9 @@ COPY --from=envoy ["C:/Program Files/envoy/", "C:/envoy/"] RUN choco install openssl -yf RUN choco install jq -yf +# Install Bats ENV BATS_URL=https://github.com/bats-core/bats-core/archive/refs/tags/v1.7.0.zip RUN curl %BATS_URL% -L -o bats.zip - RUN mkdir bats-core RUN tar -xf bats.zip -C bats-core --strip-components=1 RUN cd "C:\\Program Files\\Git\\bin" && bash.exe -c "/c/bats-core/install.sh /c/bats" @@ -30,6 +30,9 @@ RUN curl %JAEGER_URL% -L -o jaeger.tar.gz RUN mkdir jaeger RUN tar -xf jaeger.tar.gz -C jaeger --strip-components=1 +# Copy test-sds-server binary and certs +COPY --from=test-sds-server ["C:/go/src/", "C:/test-sds-server/"] + EXPOSE 8300 EXPOSE 8301 8301/udp 8302 8302/udp EXPOSE 8500 8600 8600/udp diff --git a/test/integration/connect/envoy/Dockerfile-test-sds-server-windows b/test/integration/connect/envoy/Dockerfile-test-sds-server-windows index a9328a26108b..5973757530d1 100644 --- a/test/integration/connect/envoy/Dockerfile-test-sds-server-windows +++ b/test/integration/connect/envoy/Dockerfile-test-sds-server-windows @@ -3,6 +3,6 @@ FROM golang:1.18.1-nanoserver-1809 WORKDIR /go/src COPY ./ . -RUN go build -v -o test-sds-server sds.go +RUN go build -v -o test-sds-server.exe sds.go -CMD ["/go/src/test-sds-server"] +CMD ["test-sds-server.exe"] diff --git a/test/integration/connect/envoy/helpers.windows.bash b/test/integration/connect/envoy/helpers.windows.bash index ef2200c9e29b..ee3725efc4e2 100644 --- a/test/integration/connect/envoy/helpers.windows.bash +++ b/test/integration/connect/envoy/helpers.windows.bash @@ -155,7 +155,9 @@ function assert_cert_signed_by_ca { if [ -n "$SERVER_NAME" ]; then SNI_FLAG="-servername $SERVER_NAME" fi - CERT=$(openssl s_client -connect $HOSTPORT $SNI_FLAG -CAfile $CA_FILE -showcerts /dev/null # TODO(rb): switch back to "${HASHICORP_DOCKER_PROXY}/google/pause" once that is cached - - # pre-build the test-sds-server container - echo "Rebuilding 'test-sds-server' image..." - docker.exe build -t test-sds-server -f Dockerfile-test-sds-server-windows test-sds-server } function suite_teardown { @@ -811,6 +807,8 @@ function run_container_zipkin { } function run_container_jaeger { + echo "Starting Jaeger service..." + local DC=${1:-primary} local CONTAINER_NAME="$SINGLE_CONTAINER_BASE_NAME"-"$DC"_1 @@ -819,10 +817,13 @@ function run_container_jaeger { } function run_container_test-sds-server { - docker.exe run -d --name $(container_name) \ - $WORKDIR_SNIPPET \ - $(network_snippet primary) \ - "test-sds-server" + echo "Starting test-sds-server" + + local DC=${1:-primary} + local CONTAINER_NAME="$SINGLE_CONTAINER_BASE_NAME"-"$DC"_1 + + docker.exe exec -d $CONTAINER_NAME bash -c "cd /c/test-sds-server && + ./test-sds-server.exe" } function container_name {