mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-08-21 13:31:45 -07:00
Embed pymysql
within the collection and use default test container
This change eliminates the need to install the connector on each controlled node, as `pymysql` version 1.1.1 is now included. As a result, we can safely assume its availability, thus simplifying the testing process. Also, I managed to remove the need for pre-built test containers. We now use the default test containers from ansible-test.
This commit is contained in:
parent
16d530348d
commit
04af62c400
49 changed files with 4392 additions and 979 deletions
48
TESTING.md
48
TESTING.md
|
@ -26,14 +26,6 @@ For now, the makefile only supports Podman.
|
|||
- Minimum 2GB of RAM
|
||||
|
||||
|
||||
### Custom ansible-test containers
|
||||
|
||||
Our integrations tests use custom containers for ansible-test. Those images have their definition file stored in the directory [test-containers](test-containers/). We build and publish the images on ghcr.io under the ansible-collection namespace: E.G.:
|
||||
`ghcr.io/ansible-collections/community.mysql/test-container-mariadb106-py310-mysqlclient211:latest`.
|
||||
|
||||
Availables images are listed [here](https://github.com/orgs/ansible-collections/packages).
|
||||
|
||||
|
||||
### Makefile options
|
||||
|
||||
The Makefile accept the following options
|
||||
|
@ -72,24 +64,6 @@ The Makefile accept the following options
|
|||
- "10.6.11" <- mariadb
|
||||
- Description: The tag of the container to use for the service containers that will host a primary database and two replicas. Do not use short version, like `mysql:8` (don't do that) because our tests expect a full version to filter tests precisely. For instance: `when: db_version is version ('8.0.22', '>')`. You can use any tag available on [hub.docker.com/_/mysql](https://hub.docker.com/_/mysql) and [hub.docker.com/_/mariadb](https://hub.docker.com/_/mariadb) but GitHub Action will only use the versions listed above.
|
||||
|
||||
- `connector_name`
|
||||
- Mandatory: true
|
||||
- Choices:
|
||||
- "pymysql"
|
||||
- "mysqlclient"
|
||||
- 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" <- pymysql (Only for MySQL 5.7)
|
||||
- "0.9.3" <- pymysql
|
||||
- "1.0.2" <- pymysql
|
||||
- "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`
|
||||
- Mandatory: true
|
||||
- Choices:
|
||||
|
@ -124,17 +98,17 @@ tests will overwrite the 3 databases containers so no need to kill them in advan
|
|||
|
||||
```sh
|
||||
# Run all targets
|
||||
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"
|
||||
make ansible="stable-2.12" db_engine_name="mysql" db_engine_version="5.7.40" python="3.8"
|
||||
|
||||
# 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" target="test_mysql_info"
|
||||
make ansible="stable-2.14" db_engine_name="mysql" db_engine_version="5.7.40" python="3.8" 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" target="test_mysql_query" keep_containers_alive=1 continue_on_errors=1
|
||||
make ansible="stable-2.14" db_engine_name="mysql" db_engine_version="8.0.31" python="3.9" 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"
|
||||
make local_python_version="3.8" ansible="stable-2.14" db_engine_name="mariadb" db_engine_version="10.6.11" python="3.9"
|
||||
```
|
||||
|
||||
|
||||
|
@ -149,18 +123,10 @@ python run_all_tests.py
|
|||
```
|
||||
|
||||
|
||||
### Add a new Python, Connector or Database version
|
||||
### Add a new Python or Database version
|
||||
|
||||
You can look into [.github/workflows/ansible-test-plugins.yml](https://github.com/ansible-collections/community.mysql/tree/main/.github/workflows)
|
||||
|
||||
You can look into [.github/workflows/ansible-test-plugins.yml](https://github.com/ansible-collections/community.mysql/tree/main/.github/workflows) to see how those containers are built using [build-docker-image.yml](https://github.com/ansible-collections/community.mysql/blob/main/.github/workflows/build-docker-image.yml) and all [docker-image-xxx.yml](https://github.com/ansible-collections/community.mysql/blob/main/.github/workflows/docker-image-mariadb103-py38-mysqlclient201.yml) files.
|
||||
|
||||
1. Add a workflow in [.github/workflows/](.github/workflows)
|
||||
1. Add a new folder in [test-containers](test-containers) containing a new Dockerfile. Your container must contains 3 things:
|
||||
- Python
|
||||
- A connector: The python package to connect to the database (pymysql, mysqlclient, ...)
|
||||
- A mysql client to prepare databases before our tests starts. This client must provide both `mysql` and `mysqldump` commands.
|
||||
1. Add your version in the matrix of *.github/workflows/ansible-test-plugins.yml*. You can use [run_all_tests.py](run_all_tests.py) to help you see what the matrix will be. Simply comment out the line `os.system(make_cmd)` before runing the script. You can also add `print(len(matrix))` to display how many tests there will be on GitHub Action.
|
||||
1. Ask the lead maintainer to mark your new image(s) as `public` under [https://github.com/orgs/ansible-collections/packages](https://github.com/orgs/ansible-collections/packages)
|
||||
|
||||
After pushing your commit to the remote, the container will be built and published on ghcr.io. Have a look in the "Action" tab to see if it worked. In case of error `failed to copy: io: read/write on closed pipe` re-run the workflow, this append unfortunately a lot.
|
||||
|
||||
To see the docker image produced, go to the package page in the ansible-collection namespace [https://github.com/orgs/ansible-collections/packages](https://github.com/orgs/ansible-collections/packages). This page indicate a "Published x days ago" that is updated infrequently. To see the last time the container has been updated you must click on its title and look in the right hands side bellow the title "Last published".
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue