From 0131cddb070c1d307c5b0966c8402a2add91e9b9 Mon Sep 17 00:00:00 2001 From: Franco Bruno Lavayen Date: Wed, 13 Jul 2022 17:06:44 -0300 Subject: [PATCH] [CONSUL-210] Run Bats test and verify sh script path (#15) --- .../Dockerfile-bats-core-windows | 1 + .../envoy/case-dummy-bats/verify_2.bats | 6 +-- .../connect/envoy/docker.windows.md | 50 +++++++++---------- 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/build-support-windows/Dockerfile-bats-core-windows b/build-support-windows/Dockerfile-bats-core-windows index b587093c20f9..3a2fec41d533 100644 --- a/build-support-windows/Dockerfile-bats-core-windows +++ b/build-support-windows/Dockerfile-bats-core-windows @@ -12,4 +12,5 @@ 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" +WORKDIR C:\\workdir ENTRYPOINT ["C:\\Program Files\\Git\\bin\\bash.exe", "C:\\bats\\bin\\bats"] \ No newline at end of file diff --git a/test/integration/connect/envoy/case-dummy-bats/verify_2.bats b/test/integration/connect/envoy/case-dummy-bats/verify_2.bats index 11b4274abf82..f2b421d7d169 100644 --- a/test/integration/connect/envoy/case-dummy-bats/verify_2.bats +++ b/test/integration/connect/envoy/case-dummy-bats/verify_2.bats @@ -3,12 +3,12 @@ load dummy-function setup() { - source $(pwd)/workdir/vars.sh - source $(pwd)/workdir/setup.sh "Content of the created setup.txt file in setup.sh" $TXT_FILE_NAME + source vars.sh + source setup.sh "Content of the created setup.txt file in setup.sh" $TXT_FILE_NAME } teardown() { - rm $TXT_FILE_NAME + cat /dev/null >$TXT_FILE_NAME } @test "Test with dummyFunction invoked" { diff --git a/test/integration/connect/envoy/docker.windows.md b/test/integration/connect/envoy/docker.windows.md index 5ec01fa5a753..bf361a2ab23a 100644 --- a/test/integration/connect/envoy/docker.windows.md +++ b/test/integration/connect/envoy/docker.windows.md @@ -4,8 +4,8 @@ - [About](#about-this-file) - [Pre-requisites](#pre-requisites) -- [Dockerfile-test-sds-server-windows](#dockerfile-test-sds-server-windows) - [Dockerfile-bats-windows](#dockerfile-bats-windows) +- [Dockerfile-test-sds-server-windows](#dockerfile-test-sds-server-windows) ## About this File @@ -14,13 +14,13 @@ In this file you will find which Dockerfiles are needed to run the Envoy integra ## Pre-requisites After building and running the images and containers, you need to have pre-built the base images used by these Dockerfiles. See [pre-built images required in Windows](../../../../build-support-windows/docker.windows.md) -## Dockerfile-test-sds-server-windows +## Dockerfile-bats-windows -This file sole purpose is to build the test-sds-server executable using Go. To do so, we use an official [golang image](https://hub.docker.com/_/golang/) provided in docker hub with Windows nano server. +This file sole purpose is to build the custom Bats image for Windows OS. To do this, the official [windows/servercore image](https://hub.docker.com/_/microsoft-windows-servercore) is used as base image. To build this image you need to run the following command on your terminal: ```shell -docker build -t test-sds-server -f Dockerfile-test-sds-server-windows test-sds-server +docker build -t bats-verify . -f Dockerfile-bats-windows ``` This is the same command used in run-tests.sh @@ -28,26 +28,30 @@ This is the same command used in run-tests.sh You can test the built file by running the following command: ```shell -docker run --rm -p 1234:1234 --name test-sds-server test-sds-server +docker run --rm --name bats-verify -v $(pwd -W)/case-dummy-bats:C:\\workdir bats-verify --pretty *.bats ``` -If everything works properly you should get the following output: +If everything works properly you should see the result of the dummy test executed as is displayed below ```shell -20XX-XX-XXTXX:XX:XX.XXX-XXX [INFO] Loaded cert from file: name=ca-root -20XX-XX-XXTXX:XX:XX.XXX-XXX [INFO] Loaded cert from file: name=foo.example.com -20XX-XX-XXTXX:XX:XX.XXX-XXX [INFO] Loaded cert from file: name=wildcard.ingress.consul -20XX-XX-XXTXX:XX:XX.XXX-XXX [INFO] Loaded cert from file: name=www.example.com -20XX-XX-XXTXX:XX:XX.XXX-XXX [INFO] ==> SDS listening: addr=0.0.0.0:1234 +docker run --rm --name bats-verify -v $(pwd -W)/case-dummy-bats:C:\\workdir bats-verify --pretty *.bats +verify_1.bats + ✔ Basic Test 1 + ✔ Basic Test 2 +verify_2.bats + ✔ Test with dummyFunction invoked + - Test skipped (skipped) + +4 tests, 0 failures, 1 skipped ``` -## Dockerfile-bats-windows +## Dockerfile-test-sds-server-windows -This file sole purpose is to build the custom Bats image for Windows OS. To do this, the official [windows/servercore image](https://hub.docker.com/_/microsoft-windows-servercore) is used as base image. +This file sole purpose is to build the test-sds-server executable using Go. To do so, we use an official [golang image](https://hub.docker.com/_/golang/) provided in docker hub with Windows nano server. To build this image you need to run the following command on your terminal: ```shell -docker build -t bats-verify . -f Dockerfile-bats-windows +docker build -t test-sds-server -f Dockerfile-test-sds-server-windows test-sds-server ``` This is the same command used in run-tests.sh @@ -55,19 +59,15 @@ This is the same command used in run-tests.sh You can test the built file by running the following command: ```shell -docker run --rm --name bats-verify -v $(pwd -W)/case-dummy-bats:C:\\workdir bats-verify --pretty /c/workdir/*.bats +docker run --rm -p 1234:1234 --name test-sds-server test-sds-server ``` -If everything works properly you should see the result of the dummy test executed as is displayed below +If everything works properly you should get the following output: ```shell -$ docker run --rm --name bats-verify -v $(pwd -W)/case-dummy-bats:C:\\workdir bats-verify --pretty /c/workdir/*.bats -verify_1.bats - ✔ Basic Test 1 - ✔ Basic Test 2 -verify_2.bats - ✔ Test with dummyFunction invoked - - Test skipped (skipped) - -4 tests, 0 failures, 1 skipped +20XX-XX-XXTXX:XX:XX.XXX-XXX [INFO] Loaded cert from file: name=ca-root +20XX-XX-XXTXX:XX:XX.XXX-XXX [INFO] Loaded cert from file: name=foo.example.com +20XX-XX-XXTXX:XX:XX.XXX-XXX [INFO] Loaded cert from file: name=wildcard.ingress.consul +20XX-XX-XXTXX:XX:XX.XXX-XXX [INFO] Loaded cert from file: name=www.example.com +20XX-XX-XXTXX:XX:XX.XXX-XXX [INFO] ==> SDS listening: addr=0.0.0.0:1234 ```