mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-08-22 05:51: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
|
@ -4,6 +4,14 @@
|
|||
# and should not be used as examples of how to write Ansible roles #
|
||||
####################################################################
|
||||
|
||||
- name: "{{ role_name }} | Mains | Install required packages for testing"
|
||||
ansible.builtin.package:
|
||||
name:
|
||||
- bzip2 # To test mysql_db dump compression
|
||||
- iproute2 # To gather network facts
|
||||
- mariadb-client # Can't install both mysql_client, had to make a choice
|
||||
state: present
|
||||
|
||||
- name: Prepare the fake root folder
|
||||
ansible.builtin.import_tasks:
|
||||
file: fake_root.yml
|
||||
|
|
|
@ -1,23 +1,11 @@
|
|||
---
|
||||
|
||||
- name: "{{ role_name }} | Setvars | Extract Podman/Docker Network Gateway"
|
||||
ansible.builtin.shell:
|
||||
cmd: ip route|grep default|awk '{print $3}'
|
||||
register: ip_route_output
|
||||
- name: "{{ role_name }} | Setvars | Gather facts"
|
||||
ansible.builtin.setup:
|
||||
|
||||
- name: "{{ role_name }} | Setvars | Set Fact"
|
||||
ansible.builtin.set_fact:
|
||||
gateway_addr: "{{ ip_route_output.stdout }}"
|
||||
connector_name_lookup: >-
|
||||
{{ lookup(
|
||||
'file',
|
||||
'/root/ansible_collections/community/mysql/tests/integration/connector_name'
|
||||
) }}
|
||||
connector_version_lookup: >-
|
||||
{{ lookup(
|
||||
'file',
|
||||
'/root/ansible_collections/community/mysql/tests/integration/connector_version'
|
||||
) }}
|
||||
gateway_addr: "{{ ansible_default_ipv4.gateway }}"
|
||||
db_engine_name_lookup: >-
|
||||
{{ lookup(
|
||||
'file',
|
||||
|
@ -41,8 +29,6 @@
|
|||
|
||||
- name: "{{ role_name }} | Setvars | Set Fact using above facts"
|
||||
ansible.builtin.set_fact:
|
||||
connector_name: "{{ connector_name_lookup.strip() }}"
|
||||
connector_version: "{{ connector_version_lookup.strip() }}"
|
||||
db_engine: "{{ db_engine_name_lookup.strip() }}"
|
||||
db_version: "{{ db_engine_version_lookup.strip() }}"
|
||||
python_version: "{{ python_version_lookup.strip() }}"
|
||||
|
@ -69,8 +55,6 @@
|
|||
- name: "{{ role_name }} | Setvars | Output test informations"
|
||||
vars:
|
||||
msg: |-
|
||||
connector_name: {{ connector_name }}
|
||||
connector_version: {{ connector_version }}
|
||||
db_engine: {{ db_engine }}
|
||||
db_version: {{ db_version }}
|
||||
python_version: {{ python_version }}
|
||||
|
|
|
@ -1,63 +1,35 @@
|
|||
---
|
||||
|
||||
- vars:
|
||||
mysql_parameters: &mysql_params
|
||||
login_user: root
|
||||
login_password: msandbox
|
||||
login_host: "{{ gateway_addr }}"
|
||||
login_port: 3307
|
||||
- name: Query Primary container over TCP for MySQL/MariaDB version
|
||||
community.mysql.mysql_info:
|
||||
login_user: root
|
||||
login_password: msandbox
|
||||
login_host: "{{ gateway_addr }}"
|
||||
login_port: 3307
|
||||
filter:
|
||||
- version
|
||||
register: primary_info
|
||||
failed_when:
|
||||
- registred_db_version != db_version
|
||||
vars:
|
||||
registred_db_version:
|
||||
"{{ primary_info.version.major }}.{{ primary_info.version.minor }}\
|
||||
.{{ primary_info.version.release }}"
|
||||
|
||||
block:
|
||||
- name: Assert that expected Python is installed
|
||||
ansible.builtin.command:
|
||||
cmd: python{{ python_version }} -V
|
||||
changed_when: false
|
||||
register: python_in_use
|
||||
failed_when:
|
||||
- python_in_use.stdout is not search(python_version)
|
||||
|
||||
- name: Query Primary container over TCP for MySQL/MariaDB version
|
||||
mysql_info:
|
||||
<<: *mysql_params
|
||||
filter:
|
||||
- version
|
||||
register: primary_info
|
||||
|
||||
- name: Assert that test container runs the expected MySQL/MariaDB version
|
||||
assert:
|
||||
that:
|
||||
- registred_db_version == db_version
|
||||
vars:
|
||||
registred_db_version:
|
||||
"{{ primary_info.version.major }}.{{ primary_info.version.minor }}\
|
||||
.{{ primary_info.version.release }}"
|
||||
|
||||
- name: Assert that mysql_info module used the expected version of pymysql
|
||||
assert:
|
||||
that:
|
||||
- primary_info.connector_name == connector_name
|
||||
- primary_info.connector_version == connector_version
|
||||
when:
|
||||
- connector_name == 'pymysql'
|
||||
|
||||
- name: Assert that mysql_info module used the expected version of mysqlclient
|
||||
assert:
|
||||
that:
|
||||
- primary_info.connector_name == 'MySQLdb'
|
||||
- primary_info.connector_version == connector_version
|
||||
when:
|
||||
- connector_name == 'mysqlclient'
|
||||
|
||||
- name: Display the python version in use
|
||||
command:
|
||||
cmd: python{{ python_version }} -V
|
||||
changed_when: false
|
||||
register: python_in_use
|
||||
|
||||
- name: Assert that expected Python is installed
|
||||
assert:
|
||||
that:
|
||||
- python_in_use.stdout is search(python_version)
|
||||
|
||||
- name: Assert that we run the expected ansible version
|
||||
assert:
|
||||
that:
|
||||
- ansible_running_version == test_ansible_version
|
||||
vars:
|
||||
ansible_running_version:
|
||||
"{{ ansible_version.major }}.{{ ansible_version.minor }}"
|
||||
when:
|
||||
- test_ansible_version != 'devel' # Devel will change overtime
|
||||
- name: Assert that we run the expected ansible version
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- ansible_running_version == test_ansible_version
|
||||
vars:
|
||||
ansible_running_version:
|
||||
"{{ ansible_version.major }}.{{ ansible_version.minor }}"
|
||||
when:
|
||||
- test_ansible_version != 'devel' # Devel will change overtime
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue