Skip to content

Commit

Permalink
[CONSUL-210] Run Bats test and verify sh script path (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
cocolavayen authored and joselo85 committed Dec 21, 2022
1 parent 6b9e741 commit 0131cdd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 28 deletions.
1 change: 1 addition & 0 deletions build-support-windows/Dockerfile-bats-core-windows
Expand Up @@ -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"]
6 changes: 3 additions & 3 deletions test/integration/connect/envoy/case-dummy-bats/verify_2.bats
Expand Up @@ -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" {
Expand Down
50 changes: 25 additions & 25 deletions test/integration/connect/envoy/docker.windows.md
Expand Up @@ -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

Expand All @@ -14,60 +14,60 @@ 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

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

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
```

0 comments on commit 0131cdd

Please sign in to comment.