diff --git a/.github/workflows/ansible-test-plugins.yml b/.github/workflows/ansible-test-plugins.yml index 1883fca..55d3ddb 100644 --- a/.github/workflows/ansible-test-plugins.yml +++ b/.github/workflows/ansible-test-plugins.yml @@ -583,7 +583,11 @@ jobs: echo Setting db_engine_version to "${{ matrix.db_engine_version }}"...; 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 + echo -n "${{ matrix.connector }}" > tests/integration/connector; + echo Setting Python version to "${{ matrix.python }}"...; + echo -n "${{ matrix.python }}" > tests/integration/python; + echo Setting Ansible version to "${{ matrix.ansible }}"...; + echo -n "${{ matrix.ansible }}" > tests/integration/ansible docker-image: ${{ matrix.docker_image }} target-python-version: ${{ matrix.python }} testing-type: integration diff --git a/Makefile b/Makefile index b5ac08c..6600b31 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,8 @@ SHELL := /bin/bash test-integration: echo -n $(db_engine_version) > tests/integration/db_engine_version echo -n $(connector) > tests/integration/connector + echo -n $(python) > tests/integration/python + echo -n $(ansible) > tests/integration/ansible podman run \ --detach \ --name primary \ @@ -55,6 +57,8 @@ test-integration: # -set -x; ansible-test integration $(target) -v --color --coverage --diff --docker $(docker_image) --docker-network podman --docker-terminate never --python $(python); set +x rm tests/integration/db_engine_version rm tests/integration/connector + rm tests/integration/python + rm tests/integration/ansible podman stop --time 0 --ignore primary podman stop --time 0 --ignore replica1 podman stop --time 0 --ignore replica2 diff --git a/tests/integration/targets/setup_controller/tasks/main.yml b/tests/integration/targets/setup_controller/tasks/main.yml index cea9ac4..d895480 100644 --- a/tests/integration/targets/setup_controller/tasks/main.yml +++ b/tests/integration/targets/setup_controller/tasks/main.yml @@ -12,3 +12,7 @@ - name: Set variables ansible.builtin.import_tasks: file: setvars.yml + +- name: Verify all components version under test + ansible.builtin.import_tasks: + file: verify.yml diff --git a/tests/integration/targets/setup_controller/tasks/setvars.yml b/tests/integration/targets/setup_controller/tasks/setvars.yml index 601bd86..27ba668 100644 --- a/tests/integration/targets/setup_controller/tasks/setvars.yml +++ b/tests/integration/targets/setup_controller/tasks/setvars.yml @@ -18,6 +18,16 @@ 'file', '/root/ansible_collections/community/mysql/tests/integration/db_engine_version' ) }} + python_version_lookup: >- + {{ lookup( + 'file', + '/root/ansible_collections/community/mysql/tests/integration/python' + ) }} + ansible_version_lookup: >- + {{ lookup( + 'file', + '/root/ansible_collections/community/mysql/tests/integration/ansible' + ) }} - name: "{{ role_name }} | Setvars | Set Fact using above facts" ansible.builtin.set_fact: @@ -25,6 +35,8 @@ connector_ver: "{{ connector_name_version.split('=')[2].strip() }}" db_engine: "{{ db_engine_version.split(':')[0].strip() }}" db_version: "{{ db_engine_version.split(':')[1].strip() }}" + python_version: "{{ python_version_lookup.strip() }}" + test_ansible_version: "{{ ansible_version_lookup.split('-')[1].strip() }}" mysql_command: >- mysql -h{{ gateway_addr }} @@ -46,5 +58,7 @@ connector_ver: {{ connector_ver }} db_engine: {{ db_engine }} db_version: {{ db_version }} + python_version: {{ python_version }} + test_ansible_version: {{ test_ansible_version }} ansible.builtin.debug: msg: "{{ msg.split('\n') }}" diff --git a/tests/integration/targets/setup_controller/tasks/verify.yml b/tests/integration/targets/setup_controller/tasks/verify.yml index e0f848a..408c399 100644 --- a/tests/integration/targets/setup_controller/tasks/verify.yml +++ b/tests/integration/targets/setup_controller/tasks/verify.yml @@ -1,3 +1,46 @@ --- -# TODO, write tests that assert that our container are running the -# version of MySQL/MariaDB specified in db_engind_version + +- vars: + mysql_parameters: &mysql_params + login_user: root + login_password: msandbox + login_host: "{{ gateway_addr }}" + login_port: 3307 + + block: + + - 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: + - primary_info.version.full == db_version + + - name: Assert that mysql_info module used the expected connector + assert: + that: + - primary_info.connector.name == connector_name + - primary_info.connector.version == connector_ver + + - 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_version is in python_in_use.stdout + + - name: Assert that we run the expected ansible version + assert: + that: + - > + "{{ ansible_version.major }}.{{ ansible_version.minor }}" + is version(test_ansible_version, '==')