From 3f64fb5f32100f2c63682ee120e553694cc6d927 Mon Sep 17 00:00:00 2001 From: Laurent Indermuehle Date: Fri, 6 Jan 2023 16:12:27 +0100 Subject: [PATCH] Add options to the makefile --- CONTRIBUTING.md | 20 ++++++++++++++++ Makefile | 62 ++++++++++++++++++++++++------------------------- 2 files changed, 51 insertions(+), 31 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 70cd555..e3cd166 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,3 +3,23 @@ Refer to the [Ansible Contributing guidelines](https://docs.ansible.com/ansible/devel/community/index.html) to learn how to contribute to this collection. Refer to the [review checklist](https://docs.ansible.com/ansible/devel/community/collection_contributors/collection_reviewing.html) when triaging issues or reviewing PRs. + + +## Testing locally + +You can use GitHub to run ansible-test either on the community repo or your fork. But sometimes you want to quickly test a single version or a single target. To do that, you can use the Makefile present at the root of this repository. + +Actually, the makefile only support Podman. I don't have tested with docker yet. + +The Makefile accept the following options: + +- db_engin_version: The name of the container to use. Either MYSQL or MariaDB. Use ':' as a separator. +- 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 : TODO, I need to implement a Makefile optional variable for that. + +Exemples: + +```sh +make db_engine_version="mysql:5.7.40" connector="pymysql==0.7.10" python="3.8" +``` diff --git a/Makefile b/Makefile index 370fece..c416469 100644 --- a/Makefile +++ b/Makefile @@ -1,36 +1,36 @@ .PHONY: test-integration test-integration: - echo -n mysql:8.0.22 > tests/integration/db_engine_version - echo -n pymysql==0.9.3 > tests/integration/connector - podman run \ - --detach \ - --name primary \ - --env MARIADB_ROOT_PASSWORD=msandbox \ - --env MYSQL_ROOT_PASSWORD=msandbox \ - --network podman \ - --publish 3307:3306 \ - --health-cmd 'mysqladmin ping -P 3306 -pmsandbox | grep alive || exit 1' \ - mysql:8.0.22 - podman run \ - --detach \ - --name replica1 \ - --env MARIADB_ROOT_PASSWORD=msandbox \ - --env MYSQL_ROOT_PASSWORD=msandbox \ - --network podman \ - --publish 3308:3306 \ - --health-cmd 'mysqladmin ping -P 3306 -pmsandbox | grep alive || exit 1' \ - mysql:8.0.22 - podman run \ - --detach \ - --name replica2 \ - --env MARIADB_ROOT_PASSWORD=msandbox \ - --env MYSQL_ROOT_PASSWORD=msandbox \ - --network podman \ - --publish 3309:3306 \ - --health-cmd 'mysqladmin ping -P 3306 -pmsandbox | grep alive || exit 1' \ - mysql:8.0.22 - while ! podman healthcheck run primary && [[ "$$SECONDS" -lt 120 ]]; do sleep 1; done - -set -x; ansible-test integration -v --color --coverage --retry-on-error --continue-on-error --diff --docker --docker-network podman --python 3.8; set +x + echo -n $(db_engine_version) > tests/integration/db_engine_version + echo -n $(connector) > tests/integration/connector + podman run \ + --detach \ + --name primary \ + --env MARIADB_ROOT_PASSWORD=msandbox \ + --env MYSQL_ROOT_PASSWORD=msandbox \ + --network podman \ + --publish 3307:3306 \ + --health-cmd 'mysqladmin ping -P 3306 -pmsandbox | grep alive || exit 1' \ + $(db_engine_version) + podman run \ + --detach \ + --name replica1 \ + --env MARIADB_ROOT_PASSWORD=msandbox \ + --env MYSQL_ROOT_PASSWORD=msandbox \ + --network podman \ + --publish 3308:3306 \ + --health-cmd 'mysqladmin ping -P 3306 -pmsandbox | grep alive || exit 1' \ + $(db_engine_version) + podman run \ + --detach \ + --name replica2 \ + --env MARIADB_ROOT_PASSWORD=msandbox \ + --env MYSQL_ROOT_PASSWORD=msandbox \ + --network podman \ + --publish 3309:3306 \ + --health-cmd 'mysqladmin ping -P 3306 -pmsandbox | grep alive || exit 1' \ + $(db_engine_version) + while ! podman healthcheck run primary && [[ "$$SECONDS" -lt 120 ]]; do sleep 1; done + -set -x; ansible-test integration -v --color --coverage --retry-on-error --continue-on-error --diff --docker --docker-network podman --python $(python); set +x rm tests/integration/db_engine_version rm tests/integration/connector podman stop --time 0 --ignore primary