mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-04-23 02:41:29 -07:00
Add PoC using custom ansible-test containers
This commit is contained in:
parent
199b7a5b64
commit
db995249cb
6 changed files with 147 additions and 89 deletions
97
.github/workflows/ansible-test-plugins.yml
vendored
97
.github/workflows/ansible-test-plugins.yml
vendored
|
@ -40,48 +40,60 @@ jobs:
|
|||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
db_engine_version:
|
||||
- mysql:5.7.40
|
||||
- mysql:8.0.31
|
||||
- mariadb:10.4.24
|
||||
- mariadb:10.5.18
|
||||
- mariadb:10.6.11
|
||||
- mariadb:10.7.7
|
||||
- mariadb:10.8.3
|
||||
ansible:
|
||||
- stable-2.12
|
||||
- stable-2.13
|
||||
- stable-2.14
|
||||
- devel
|
||||
python:
|
||||
- "3.8"
|
||||
- "3.9"
|
||||
- "3.10" # Without quotes, this become 3.1 in run_all_test.py!
|
||||
connector:
|
||||
- pymysql==0.7.10
|
||||
- pymysql==0.9.3
|
||||
- mysqlclient==2.0.1
|
||||
exclude:
|
||||
- db_engine_version: mysql:8.0.22
|
||||
connector: pymysql==0.7.10
|
||||
- db_engine_version: mariadb:10.4.24
|
||||
connector: pymysql==0.7.10
|
||||
- db_engine_version: mariadb:10.5.18
|
||||
connector: pymysql==0.7.10
|
||||
- db_engine_version: mariadb:10.8.3
|
||||
connector: pymysql==0.7.10
|
||||
- python: 3.8
|
||||
ansible: stable-2.13
|
||||
- python: 3.8
|
||||
ansible: stable-2.14
|
||||
- python: 3.8
|
||||
ansible: devel
|
||||
- python: 3.9
|
||||
ansible: stable-2.12
|
||||
- python: 3.9
|
||||
connector: mysqlclient==2.0.1
|
||||
- python: 3.10
|
||||
ansible: stable-2.12
|
||||
include:
|
||||
- ansible: stable-2.12
|
||||
db_engine_version: mysql:5.7.40
|
||||
python: 3.8
|
||||
connector: pymysql==0.7.11
|
||||
docker_container: my57-py38-mysqlclient201-pymysql0711
|
||||
- ansible: stable-2.12
|
||||
db_engine_version: mysql:5.7.40
|
||||
python: 3.8
|
||||
connector: pymysql==0.9.3
|
||||
docker_container: my57-py38-pymysql093
|
||||
|
||||
# db_engine_version:
|
||||
# - mysql:5.7.40
|
||||
# - mysql:8.0.31
|
||||
# - mariadb:10.4.24
|
||||
# - mariadb:10.5.18
|
||||
# - mariadb:10.6.11
|
||||
# - mariadb:10.7.7
|
||||
# - mariadb:10.8.3
|
||||
# ansible:
|
||||
# - stable-2.12
|
||||
# - stable-2.13
|
||||
# - stable-2.14
|
||||
# - devel
|
||||
# python:
|
||||
# - "3.8"
|
||||
# - "3.9"
|
||||
# - "3.10" # Without quotes, this become 3.1 in run_all_test.py!
|
||||
# connector:
|
||||
# - pymysql==0.7.10
|
||||
# - pymysql==0.9.3
|
||||
# - mysqlclient==2.0.1
|
||||
# exclude:
|
||||
# - db_engine_version: mysql:8.0.22
|
||||
# connector: pymysql==0.7.10
|
||||
# - db_engine_version: mariadb:10.4.24
|
||||
# connector: pymysql==0.7.10
|
||||
# - db_engine_version: mariadb:10.5.18
|
||||
# connector: pymysql==0.7.10
|
||||
# - db_engine_version: mariadb:10.8.3
|
||||
# connector: pymysql==0.7.10
|
||||
# - python: 3.8
|
||||
# ansible: stable-2.13
|
||||
# - python: 3.8
|
||||
# ansible: stable-2.14
|
||||
# - python: 3.8
|
||||
# ansible: devel
|
||||
# - python: 3.9
|
||||
# ansible: stable-2.12
|
||||
# - python: 3.9
|
||||
# connector: mysqlclient==2.0.1
|
||||
# - python: 3.10
|
||||
# ansible: stable-2.12
|
||||
|
||||
services:
|
||||
db_primary:
|
||||
|
@ -157,6 +169,7 @@ jobs:
|
|||
echo -n "${{ matrix.db_engine_version }}" > tests/integration/db_engine_version;
|
||||
echo Setting Connector version to "${{ matrix.connector }}"...;
|
||||
echo -n "${{ matrix.connector }}" > tests/integration/connector
|
||||
docker_container: ${{ matrix.docker_container }}
|
||||
target-python-version: ${{ matrix.python }}
|
||||
testing-type: integration
|
||||
|
||||
|
|
|
@ -13,6 +13,29 @@ Actually, the makefile only support Podman. I don't have tested with docker yet.
|
|||
|
||||
The Makefile accept the following options:
|
||||
|
||||
- ansible: Mandatory version of ansible to install in a venv to run ansible-test.
|
||||
- container_image:
|
||||
The container image to use to run our test. There images are created in github.com/community.mysql-test-containers and push the following images on quay.io:
|
||||
- my57-py38-pymysql093
|
||||
- my57-py38-mysqlclient201-pymysql0711
|
||||
- my57-py39-pymysql093
|
||||
- my57-py39-mysqlclient203-pymysql0711
|
||||
- my57-py310-pymysql093
|
||||
- my57-py310-mysqlclient211-pymysql0711
|
||||
- my80-py38-pymysql093
|
||||
- my80-py38-mysqlclient201-pymysql0711
|
||||
- my80-py39-pymysql093
|
||||
- my80-py39-mysqlclient203-pymysql0711
|
||||
- my80-py310-pymysql093
|
||||
- my80-py310-mysqlclient211-pymysql0711
|
||||
- mariadb-py38-pymysql093
|
||||
- mariadb-py38-mysqlclient201
|
||||
- mariadb-py39-pymysql093
|
||||
- mariadb-py39-mysqlclient203
|
||||
- mariadb-py310-pymysql093
|
||||
- mariadb-py310-mysqlclient211
|
||||
Unfortunatly you must provide the right container_image yourself. And you still need to provides db_engine_version, python, etc...
|
||||
To minimise the amount of images, pymysql 0.7.11 and mysqlclient are shipped together.
|
||||
- db_engine_version: The name of the container to use. Either MYSQL or MariaDB. Use ':' as a separator. Do not use short version, like mysql:8 for instance. Our tests expect a full version to filter tests based on released version. For instance: when: db_version is version ('8.0.22', '>').
|
||||
- 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.
|
||||
|
@ -22,10 +45,10 @@ Examples:
|
|||
|
||||
```sh
|
||||
# Run all targets
|
||||
make db_engine_version="mysql:5.7.40" connector="pymysql==0.7.10" python="3.8"
|
||||
make ansible="stable-2.14" db_engine_version="mysql:5.7.40" connector="pymysql==0.7.10" python="3.8" container_image="my57-py38-mysqlclient201-pymysql0711"
|
||||
|
||||
# A single target
|
||||
make db_engine_version="mysql:5.7.40" connector="pymysql==0.7.10" python="3.8" target="test_mysql_db"
|
||||
make ansible="stable-2.14" db_engine_version="mysql:5.7.40" connector="pymysql==0.7.10" python="3.8" container_image="my57-py38-mysqlclient201-pymysql0711" target="test_mysql_db"
|
||||
```
|
||||
|
||||
|
||||
|
|
|
@ -28,27 +28,31 @@ def extract_matrix(workflow_yaml):
|
|||
return matrix
|
||||
|
||||
|
||||
def is_exclude(exclude_list, test_suite):
|
||||
test_is_excluded = False
|
||||
for excl in exclude_list:
|
||||
match = 0
|
||||
# def is_exclude(exclude_list, test_suite):
|
||||
# test_is_excluded = False
|
||||
# for excl in exclude_list:
|
||||
# match = 0
|
||||
|
||||
if 'db_engine_version' in excl:
|
||||
if excl.get('db_engine_version') == test_suite[0]:
|
||||
match += 1
|
||||
# if 'ansible' in excl:
|
||||
# if excl.get('ansible') == test_suite[0]:
|
||||
# match += 1
|
||||
|
||||
if 'python' in excl:
|
||||
if excl.get('python') == test_suite[1]:
|
||||
match += 1
|
||||
# if 'db_engine_version' in excl:
|
||||
# if excl.get('db_engine_version') == test_suite[1]:
|
||||
# match += 1
|
||||
|
||||
if 'connector' in excl:
|
||||
if excl.get('connector') == test_suite[2]:
|
||||
match += 1
|
||||
# if 'python' in excl:
|
||||
# if excl.get('python') == test_suite[2]:
|
||||
# match += 1
|
||||
|
||||
if match > 1:
|
||||
test_is_excluded = True
|
||||
# if 'connector' in excl:
|
||||
# if excl.get('connector') == test_suite[3]:
|
||||
# match += 1
|
||||
|
||||
return test_is_excluded
|
||||
# if match > 1:
|
||||
# test_is_excluded = True
|
||||
|
||||
# return test_is_excluded
|
||||
|
||||
|
||||
def main():
|
||||
|
@ -56,17 +60,23 @@ def main():
|
|||
tests_matrix_yaml = extract_matrix(workflow_yaml)
|
||||
|
||||
matrix = []
|
||||
exclude_list = tests_matrix_yaml.get('exclude')
|
||||
for db_engine in tests_matrix_yaml.get('db_engine_version'):
|
||||
for python in tests_matrix_yaml.get('python'):
|
||||
for connector in tests_matrix_yaml.get('connector'):
|
||||
if not is_exclude(exclude_list, (db_engine, python, connector)):
|
||||
matrix.append((db_engine, python, connector))
|
||||
# exclude_list = tests_matrix_yaml.get('exclude')
|
||||
# for ansible in tests_matrix_yaml.get('ansible'):
|
||||
# for db_engine in tests_matrix_yaml.get('db_engine_version'):
|
||||
# for python in tests_matrix_yaml.get('python'):
|
||||
# for connector in tests_matrix_yaml.get('connector'):
|
||||
# if not is_exclude(exclude_list, (ansible, db_engine, python, connector)):
|
||||
# matrix.append((ansible, db_engine, python, connector))
|
||||
|
||||
for tests in matrix:
|
||||
make_cmd = f'make db_engine_version="{tests[0]}" python="{tests[1]}" connector="{tests[2]}" test-integration'
|
||||
print(f'Run tests for: {tests[0]}, Python: {tests[1]}, Connector: {tests[2]}')
|
||||
os.system(make_cmd)
|
||||
for tests in tests_matrix_yaml.get('include'):
|
||||
a = tests.get('ansible')
|
||||
d = tests.get('db_engine_version')
|
||||
p = tests.get('python')
|
||||
c = tests.get('connector')
|
||||
i = tests.get('docker_container')
|
||||
make_cmd = f'make ansible="{a}" db_engine_version="{d}" python="{p}" connector="{c}" docker_container="{i}" test-integration'
|
||||
print(f'Run tests for: Ansible: {a}, DB: {d}, Python: {p}, Connector: {c}, Image: {i}')
|
||||
# os.system(make_cmd)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -1,6 +1,18 @@
|
|||
---
|
||||
|
||||
- name: "{{ role_name }} | Connector | Install python packages"
|
||||
ansible.builtin.pip:
|
||||
name: "{{ connector_name }}"
|
||||
state: present
|
||||
# - name: "{{ role_name }} | Connector | Install requirements for mysqlclient"
|
||||
# ansible.builtin.apt:
|
||||
# name:
|
||||
# - python3-dev
|
||||
# - default-libmysqlclient-dev
|
||||
# - build-essential
|
||||
# state: present
|
||||
# environment:
|
||||
# DEBIAN_FRONTEND: noninteractive
|
||||
# when:
|
||||
# - connector_name == 'mysqlclient'
|
||||
|
||||
# - name: "{{ role_name }} | Connector | Install python packages"
|
||||
# ansible.builtin.pip:
|
||||
# name: "{{ connector_name_version }}"
|
||||
# state: present
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
---
|
||||
|
||||
- name: "{{ role_name }} | install | Required package for testing"
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- iproute2
|
||||
- python3-cryptography # To authenticate with MySQL 8+
|
||||
state: present
|
||||
update_cache: true
|
||||
environment:
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
# - name: "{{ role_name }} | install | Required package for testing"
|
||||
# ansible.builtin.apt:
|
||||
# name:
|
||||
# - iproute2 # To grab docker network gateway address
|
||||
# - python3-cryptography # To authenticate with MySQL 8+
|
||||
# state: present
|
||||
# update_cache: true
|
||||
# environment:
|
||||
# DEBIAN_FRONTEND: noninteractive
|
||||
|
||||
- name: "{{ role_name }} | install | Ensure fake root folder"
|
||||
ansible.builtin.file:
|
||||
|
|
|
@ -13,10 +13,10 @@
|
|||
ansible.builtin.import_tasks:
|
||||
file: setvars.yml
|
||||
|
||||
- name: Install MySQL local client
|
||||
ansible.builtin.import_tasks:
|
||||
file: client.yml
|
||||
# - name: Install MySQL local client
|
||||
# ansible.builtin.import_tasks:
|
||||
# file: client.yml
|
||||
|
||||
- name: Install MySQL Python connector
|
||||
ansible.builtin.import_tasks:
|
||||
file: connector.yml
|
||||
# - name: Install MySQL Python connector
|
||||
# ansible.builtin.import_tasks:
|
||||
# file: connector.yml
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue