Add option to let containers alive at end of testing

This commit is contained in:
Laurent Indermuehle 2023-01-23 13:59:15 +01:00
commit ff20c8ce18
No known key found for this signature in database
GPG key ID: 93FA944C9F34DD09
2 changed files with 14 additions and 2 deletions

View file

@ -23,6 +23,7 @@ The Makefile accept the following options:
- **connector**: The name of the python package of the connector along with its version number. Use '==' as a separator.
- **python**: The python version to use in the controller.
- **target** : If omitted, all test targets will run. But you can limit the tests to a single target to speed up your tests.
- **keep_containers_alive**: This option keeps all tree databases containers and the ansible-test container alive at the end of tests or in case of failure. This is useful to enter one of the containers with `podman exec -it <container-name> bash` for debugging.
Examples:
@ -32,6 +33,13 @@ make ansible="stable-2.14" db_engine_version="mysql:5.7.40" python="3.8" connect
# A single target
make ansible="stable-2.14" db_engine_version="mysql:5.7.40" python="3.8" connector="pymysql==0.7.10" docker_image="ghcr.io/community.mysql/test-container-my80-py39-mysqlclient203:latest" target="test_mysql_db"
# Keep databases and ansible tests containers alives
# A single target
make ansible="stable-2.14" db_engine_version="mysql:5.7.40" python="3.8" connector="pymysql==0.7.10" docker_image="ghcr.io/community.mysql/test-container-my80-py39-mysqlclient203:latest" target="test_mysql_db" keep_containers_alive=1
# Rerun tests after using `keep_containers_alive=1`
podman stop -a; podman rm -a; make ansible="stable-2.14" db_engine_version="mysql:5.7.40" python="3.8" connector="pymysql==0.7.10" docker_image="ghcr.io/community.mysql/test-container-my80-py39-mysqlclient203:latest" target="test_mysql_db" keep_containers_alive=1
```

View file

@ -52,16 +52,20 @@ test-integration:
python -m venv .venv/$(ansible)
source .venv/$(ansible)/bin/activate
python -m pip install --disable-pip-version-check --user https://github.com/ansible/ansible/archive/$(ansible).tar.gz ansible-test
ifdef keep_containers_alive
-set -x; ansible-test integration $(target) -v --color --coverage --retry-on-error --continue-on-error --diff --docker $(docker_image) --docker-network podman --docker-terminate never --python $(python); set +x
else
-set -x; ansible-test integration $(target) -v --color --coverage --retry-on-error --continue-on-error --diff --docker $(docker_image) --docker-network podman --python $(python); set +x
# -set -x; ansible-test integration $(target) -v --color --coverage --retry-on-error --continue-on-error --diff --docker $(docker_image) --docker-network podman --python $(python); set +x
# -set -x; ansible-test integration $(target) -v --color --coverage --diff --docker $(docker_image) --docker-network podman --docker-terminate never --python $(python); set +x
endif
rm tests/integration/db_engine_version
rm tests/integration/connector
rm tests/integration/python
rm tests/integration/ansible
ifndef keep_containers_alive
podman stop --time 0 --ignore primary
podman stop --time 0 --ignore replica1
podman stop --time 0 --ignore replica2
podman rm --ignore primary
podman rm --ignore replica1
podman rm --ignore replica2
endif