Skip retry-on-error by default and add option to activate it on demand

This commit is contained in:
Laurent Indermuehle 2023-01-23 16:50:45 +01:00
parent cbc3721bc6
commit 31a41d1a09
No known key found for this signature in database
GPG key ID: 93FA944C9F34DD09
2 changed files with 13 additions and 5 deletions

View file

@ -1,5 +1,16 @@
SHELL := /bin/bash
# To tell ansible-test and Make to not kill the containers on failure or
# end of tests. Disabled by default.
ifdef keep_containers_alive
_keep_containers_alive = --docker-terminate never
endif
# This match what GitHub Action will do. Disabled by default.
ifdef continue_on_errors
_continue_on_errors = --retry-on-error --continue-on-error
endif
.PHONY: test-integration
test-integration:
echo -n $(db_engine_version) > tests/integration/db_engine_version
@ -52,11 +63,7 @@ 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
endif
-set -x; ansible-test integration $(target) -v --color --coverage --diff --docker $(docker_image) --docker-network podman $(_continue_on_errors) $(_keep_containers_alive) --python $(python); set +x
rm tests/integration/db_engine_version
rm tests/integration/connector
rm tests/integration/python

View file

@ -22,6 +22,7 @@ The Makefile accept the following options:
- **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.
- **continue_on_errors**: Tells ansible-test to retry on errors and also continue on errors. This is the way the GitHub Action's workflow runs the tests. If you develop a new target, this option can be used to validate that your tests cleanup everything so a new run can restart without errors like "Failed to create database x because it already exists".
Examples: