From 31a41d1a09a78c9fffd57155727fa558f1b859be Mon Sep 17 00:00:00 2001 From: Laurent Indermuehle Date: Mon, 23 Jan 2023 16:50:45 +0100 Subject: [PATCH] Skip retry-on-error by default and add option to activate it on demand --- Makefile | 17 ++++++++++++----- TESTS.md | 1 + 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index ea8a6f3..fe83651 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/TESTS.md b/TESTS.md index 5e98c68..0604cf1 100644 --- a/TESTS.md +++ b/TESTS.md @@ -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 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: