Skip to content

Commit

Permalink
Fix the Makefile for integration tests not using the Python Venv (#532)…
Browse files Browse the repository at this point in the history
… (#534)

* Fix venv not being used by keeping the same shell

Also fix "-set -x" command not found.

* Fix missing option in the command usage documentation

* Document connector-version relationship

* Fix missing option in the command usage documentation

* Rephrase commands descriptions

* Document that you need to kill the ansible-test container yourself

(cherry picked from commit 426084a)

Co-authored-by: Laurent Indermühle <laurent.indermuehle@pm.me>
  • Loading branch information
patchback[bot] and laurent-indermuehle authored Apr 27, 2023
1 parent 095df1e commit 9670218
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
20 changes: 14 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,20 @@ test-integration:
while ! podman healthcheck run primary && [[ "$$SECONDS" -lt 120 ]]; do sleep 1; done
mkdir -p .venv/$(ansible)
python$(local_python_version) -m venv .venv/$(ansible)
source .venv/$(ansible)/bin/activate
python$(local_python_version) -m ensurepip
python$(local_python_version) -m pip install --disable-pip-version-check https://github.com/ansible/ansible/archive/$(ansible).tar.gz
-set -x; ansible-test integration $(target) -v --color --coverage --diff \
--docker ghcr.io/ansible-collections/community.mysql/test-container-$(db_client)-py$(python_version_flat)-$(connector_name)$(connector_version_flat):latest \
--docker-network podman $(_continue_on_errors) $(_keep_containers_alive) --python $(python); set +x

# Start venv (use `; \` to keep the same shell)
source .venv/$(ansible)/bin/activate; \
python$(local_python_version) -m ensurepip; \
python$(local_python_version) -m pip install --disable-pip-version-check \
https://github.com/ansible/ansible/archive/$(ansible).tar.gz; \
set -x; \
ansible-test integration $(target) -v --color --coverage --diff \
--docker ghcr.io/ansible-collections/community.mysql/test-container\
-$(db_client)-py$(python_version_flat)-$(connector_name)$(connector_version_flat):latest \
--docker-network podman $(_continue_on_errors) $(_keep_containers_alive) --python $(python); \
set +x
# End of venv

rm tests/integration/db_engine_name
rm tests/integration/db_engine_version
rm tests/integration/connector_name
Expand Down
22 changes: 11 additions & 11 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,17 @@ The Makefile accept the following options
- Choices:
- "pymysql
- "mysqlclient"
- Description: The python package of the connector to use. This value is used to filter tests meant for other connectors.
- Description: The python package of the connector to use. In addition to selecting the test container, this value is also used for tests filtering: `when: connector_name == 'pymysql'`.

- `connector_version`
- Mandatory: true
- Choices:
- "0.7.11" <- Only for MySQL 5.7
- "0.9.3"
- "1.0.2" <- Not working, need fix
- "2.0.1"
- "2.0.3"
- "2.1.1"
- "0.7.11" <- pymysql (Only for MySQL 5.7)
- "0.9.3" <- pymysql
- "1.0.2" <- pymysql (Not working, need fix)
- "2.0.1" <- mysqlclient
- "2.0.3" <- mysqlclient
- "2.1.1" <- mysqlclient
- Description: The version of the python package of the connector to use. This value is used to filter tests meant for other connectors.

- `python`
Expand All @@ -113,11 +113,11 @@ The Makefile accept the following options
- `keep_containers_alive`
- Mandatory: false
- Description: 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. Rerunning the
test will recreate those containers so no need to kill it. Add any value to activate this option: `keep_containers_alive=1`
tests will overwrite the 3 databases containers so no need to kill them in advance. But nothing will kill the ansible-test container. You must do that using `podman stop` and `podman rm`. Add any value to activate this option: `keep_containers_alive=1`

- `continue_on_errors`
- Mandatory: false
- Description: Tells ansible-test to retry on errors and also continue on errors. This is the way the GitHub Action's workflow runs the tests. This can be use to catch all errors in a single run, but you'll need to scroll up to find them. Add any value to activate this option: `continue_on_errors=1`
- Description: Tells ansible-test to retry on errors and also continue on errors. This is the way the GitHub Action's workflow runs the tests. This can be used to catch all errors in a single run, but you'll need to scroll up to find them. Add any value to activate this option: `continue_on_errors=1`


#### Makefile usage examples:
Expand All @@ -127,11 +127,11 @@ test will recreate those containers so no need to kill it. Add any value to acti
make ansible="stable-2.12" db_engine_name="mysql" db_engine_version="5.7.40" python="3.8" connector_name="pymysql" connector_version="0.7.11"

# A single target
make ansible="stable-2.14" db_engine_name="mysql" db_engine_version="5.7.40" python="3.8" connector_name="pymysql" connector_version="0.7.11"
make ansible="stable-2.14" db_engine_name="mysql" db_engine_version="5.7.40" python="3.8" connector_name="pymysql" connector_version="0.7.11" target="test_mysql_info"

# Keep databases and ansible tests containers alives
# A single target and continue on errors
make ansible="stable-2.14" db_engine_name="mysql" db_engine_version="8.0.31" python="3.9" connector_name="mysqlclient" connector_version="2.0.3"
make ansible="stable-2.14" db_engine_name="mysql" db_engine_version="8.0.31" python="3.9" connector_name="mysqlclient" connector_version="2.0.3" target="test_mysql_query" keep_containers_alive=1 continue_on_errors=1

# If your system has an usupported version of Python:
make local_python_version="3.8" ansible="stable-2.14" db_engine_name="mariadb" db_engine_version="10.6.11" python="3.9" connector_name="pymysql" connector_version="0.9.3"
Expand Down

0 comments on commit 9670218

Please sign in to comment.