From 325b9d16a72bbb97a211fc08df9ac3ef57562a97 2021-01-13 20:49:59 From: Branko Majic Date: 2021-01-13 20:49:59 Subject: [PATCH] MAR-151: Added support for Debian 10 Buster to common role: - Updated tests. - Updated role reference documentation. - Updated role metadata information. - Refactored IP plan for the test machines for better separation between different types of machines and versions. - Parametrised tests for limited connectivity using the maintenance mode. - Don't use MariaDB compat package in tests - name differs between Debian 9 and Debian 10, and relevant parameter is already getting tested properly using the remaining packages. --- diff --git a/docs/rolereference.rst b/docs/rolereference.rst index c84b607eb6185085f8314adbf14b6ef99a4d2dc3..3fa0242594b3f0a762d8038157b49c2f39541f22 100644 --- a/docs/rolereference.rst +++ b/docs/rolereference.rst @@ -463,6 +463,7 @@ Distribution compatibility Role is compatible with the following distributions: - Debian 9 (Stretch) +- Debian 10 (Buster) Examples diff --git a/roles/common/meta/main.yml b/roles/common/meta/main.yml index 9c2ff7234486a62d9424aca6398285b4c1b51a70..775316b8a7df2288b57e1673d959919a0cf23e7e 100644 --- a/roles/common/meta/main.yml +++ b/roles/common/meta/main.yml @@ -22,5 +22,5 @@ galaxy_info: platforms: - name: Debian versions: - - 8 - 9 + - 10 diff --git a/roles/common/molecule/default/group_vars/parameters-optional.yml b/roles/common/molecule/default/group_vars/parameters-optional.yml index eb960343d8101ae6a4b4b23c617c33628fe52687..989ca3c2e742c0c8cd351ce8da7e99c4742b17de 100644 --- a/roles/common/molecule/default/group_vars/parameters-optional.yml +++ b/roles/common/molecule/default/group_vars/parameters-optional.yml @@ -31,7 +31,6 @@ os_groups: common_packages: - units - gnutls-bin - - libmariadbclient-dev-compat - emacs24-nox ca_certificates: cacert1: "{{ lookup('file', 'tests/data/x509/ca/level1.cert.pem') }}" diff --git a/roles/common/molecule/default/molecule.yml b/roles/common/molecule/default/molecule.yml index 65bf1232c722cf9b7fd0b4146e62cb01436f0c01..43e9e28086ea3dd8e5756d7d00198bc557ee15f0 100644 --- a/roles/common/molecule/default/molecule.yml +++ b/roles/common/molecule/default/molecule.yml @@ -57,7 +57,7 @@ platforms: cpus: 1 interfaces: - auto_config: true - ip: 10.31.127.5 + ip: 10.31.127.11 network_name: private_network type: static @@ -69,7 +69,31 @@ platforms: cpus: 1 interfaces: - auto_config: true - ip: 10.31.127.6 + ip: 10.31.127.12 + network_name: private_network + type: static + + - name: parameters-mandatory-buster64 + groups: + - parameters-mandatory + box: debian/contrib-buster64 + memory: 256 + cpus: 1 + interfaces: + - auto_config: true + ip: 10.31.127.21 + network_name: private_network + type: static + + - name: parameters-optional-buster64 + groups: + - parameters-optional + box: debian/contrib-buster64 + memory: 256 + cpus: 1 + interfaces: + - auto_config: true + ip: 10.31.127.22 network_name: private_network type: static diff --git a/roles/common/molecule/default/prepare.yml b/roles/common/molecule/default/prepare.yml index 67d0a452ca7869733dcd433c4a1f6211fc7cbeb4..3a1939f5da4db3622842f63449e0573f883f75b3 100644 --- a/roles/common/molecule/default/prepare.yml +++ b/roles/common/molecule/default/prepare.yml @@ -51,7 +51,31 @@ name: apt-cacher-ng state: present -- hosts: all +- hosts: client + become: true + tasks: + + - name: Install tool for testing TCP connectivity + apt: + name: hping3 + state: present + + - name: Set-up /etc/hosts with entries for all servers + lineinfile: + path: /etc/hosts + regexp: "^{{ item.key }}" + line: "{{ item.key }} {{ item.value }}" + owner: root + group: root + mode: 0644 + state: present + with_dict: + 10.31.127.11: parameters-mandatory-stretch64 + 10.31.127.12: parameters-optional-stretch64 + 10.31.127.21: parameters-mandatory-buster64 + 10.31.127.22: parameters-optional-buster64 + +- hosts: parameters-mandatory,parameters-optional become: true tasks: @@ -72,8 +96,6 @@ with_dict: 10.31.127.3: client1 10.31.127.4: client2 - 10.31.127.5: parameters-mandatory - 10.31.127.6: parameters-optional - hosts: parameters-mandatory,parameters-optional become: true diff --git a/roles/common/molecule/default/tests/test_maintenance_from_allowed_client.py b/roles/common/molecule/default/tests/test_maintenance_from_allowed_client.py index 7fbf599434965d3b2ca9ee91231cc648de782184..759cb91ed97fd525334372cf42a6b3b1bd64bcfc 100644 --- a/roles/common/molecule/default/tests/test_maintenance_from_allowed_client.py +++ b/roles/common/molecule/default/tests/test_maintenance_from_allowed_client.py @@ -1,5 +1,7 @@ import os +import pytest + import testinfra.utils.ansible_runner @@ -7,29 +9,37 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('client-allowed') -def test_ssh_connectivity(host): +@pytest.mark.parametrize("platform", [ + "stretch64", + "buster64" +]) +def test_ssh_connectivity(host, platform): """ Test if SSH server is reachable. """ with host.sudo(): - ping = host.run('hping3 -S -p 22 -c 1 %s', 'parameters-mandatory') + ping = host.run('hping3 -S -p 22 -c 1 %s', 'parameters-mandatory-%s' % platform) assert ping.rc == 0 - ping = host.run('hping3 -S -p 22 -c 1 %s', 'parameters-optional') + ping = host.run('hping3 -S -p 22 -c 1 %s', 'parameters-optional-%s' % platform) assert ping.rc == 0 -def test_http_connectivity(host): +@pytest.mark.parametrize("platform", [ + "stretch64", + "buster64" +]) +def test_http_connectivity(host, platform): """ Test if HTTP server is reachable. """ with host.sudo(): - ping = host.run('hping3 -S -p 80 -c 1 %s', 'parameters-mandatory') + ping = host.run('hping3 -S -p 80 -c 1 %s', 'parameters-mandatory-%s' % platform) assert ping.rc == 0 - ping = host.run('hping3 -S -p 80 -c 1 %s', 'parameters-optional') + ping = host.run('hping3 -S -p 80 -c 1 %s', 'parameters-optional-%s' % platform) assert ping.rc == 0 diff --git a/roles/common/molecule/default/tests/test_maintenance_from_disallowed_client.py b/roles/common/molecule/default/tests/test_maintenance_from_disallowed_client.py index 54bbc136d969e43cc5c756f91972d5ea9b3d30c2..4231b469107c4f6430c6c6423d169c2335efde05 100644 --- a/roles/common/molecule/default/tests/test_maintenance_from_disallowed_client.py +++ b/roles/common/molecule/default/tests/test_maintenance_from_disallowed_client.py @@ -1,5 +1,7 @@ import os +import pytest + import testinfra.utils.ansible_runner @@ -7,29 +9,37 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('client-disallowed') -def test_ssh_connectivity(host): +@pytest.mark.parametrize("platform", [ + "stretch64", + "buster64" +]) +def test_ssh_connectivity(host, platform): """ Test if SSH server is reachable. """ with host.sudo(): - ping = host.run('hping3 -S -p 22 -c 1 %s', 'parameters-mandatory') + ping = host.run('hping3 -S -p 22 -c 1 %s', 'parameters-mandatory-%s' % platform) assert ping.rc == 0 - ping = host.run('hping3 -S -p 22 -c 1 %s', 'parameters-optional') + ping = host.run('hping3 -S -p 22 -c 1 %s', 'parameters-optional-%s' % platform) assert ping.rc == 0 -def test_http_connectivity(host): +@pytest.mark.parametrize("platform", [ + "stretch64", + "buster64" +]) +def test_http_connectivity(host, platform): """ Test if HTTP server is reachable. """ with host.sudo(): - ping = host.run('hping3 -S -p 80 -c 1 %s', 'parameters-mandatory') + ping = host.run('hping3 -S -p 80 -c 1 %s', 'parameters-mandatory-%s' % platform) assert ping.rc == 0 - ping = host.run('hping3 -S -p 80 -c 1 %s', 'parameters-optional') + ping = host.run('hping3 -S -p 80 -c 1 %s', 'parameters-optional-%s' % platform) assert ping.rc != 0 diff --git a/roles/common/molecule/default/tests/test_parameters_optional.py b/roles/common/molecule/default/tests/test_parameters_optional.py index df89cf5db9fd677a1887514475a5d75af953aa5d..7672bb146b6cc33074a25408b970f994a6e9952f 100644 --- a/roles/common/molecule/default/tests/test_parameters_optional.py +++ b/roles/common/molecule/default/tests/test_parameters_optional.py @@ -39,14 +39,14 @@ def test_bash_prompt_content(host): assert "export PS1='\\[\\e]0;\\u@\\h: \\w\\a\\]${debian_chroot:+($debian_chroot)}\\u@\\h[test]:\\w\\$ '" in config.content_string -def test_common_installed_packages_common(host): +def test_common_packages_are_installed(host): """ Tests that user-provided common packages have been installed. """ assert host.package('units').is_installed assert host.package('gnutls-bin').is_installed - assert host.package('libmariadbclient-dev-compat').is_installed + assert host.package('emacs24-nox').is_installed def test_ssh_login_mechanisms(host):