Changeset - 325b9d16a72b
[Not reviewed]
0 8 0
Branko Majic (branko) - 3 years ago 2021-01-13 20:49:59
branko@majic.rs
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.
8 files changed with 87 insertions and 21 deletions:
0 comments (0 inline, 0 general)
docs/rolereference.rst
Show inline comments
 
@@ -463,6 +463,7 @@ Distribution compatibility
 
Role is compatible with the following distributions:
 

	
 
- Debian 9 (Stretch)
 
- Debian 10 (Buster)
 

	
 

	
 
Examples
roles/common/meta/main.yml
Show inline comments
 
@@ -22,5 +22,5 @@ galaxy_info:
 
  platforms:
 
    - name: Debian
 
      versions:
 
        - 8
 
        - 9
 
        - 10
roles/common/molecule/default/group_vars/parameters-optional.yml
Show inline comments
 
@@ -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') }}"
roles/common/molecule/default/molecule.yml
Show inline comments
 
@@ -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
 

	
roles/common/molecule/default/prepare.yml
Show inline comments
 
@@ -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
roles/common/molecule/default/tests/test_maintenance_from_allowed_client.py
Show inline comments
 
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
roles/common/molecule/default/tests/test_maintenance_from_disallowed_client.py
Show inline comments
 
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
roles/common/molecule/default/tests/test_parameters_optional.py
Show inline comments
 
@@ -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):
0 comments (0 inline, 0 general)