From ff20c8ce186eed99bffff63c338708335563aeae Mon Sep 17 00:00:00 2001 From: Laurent Indermuehle Date: Mon, 23 Jan 2023 13:59:15 +0100 Subject: [PATCH] Add option to let containers alive at end of testing --- CONTRIBUTING.md | 8 ++++++++ Makefile | 8 ++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index deb3b71..4a5e61b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 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 ``` diff --git a/Makefile b/Makefile index 6600b31..ea8a6f3 100644 --- a/Makefile +++ b/Makefile @@ -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