From 40b5747adcb33027e7a06b2fa0ee07a1096b1202 2018-05-27 20:16:32 From: Branko Majic Date: 2018-05-27 20:16:32 Subject: [PATCH] MAR-129: Updated backup_server role tests: - Move the 'ss' utility out of place in order to be able to test if sockets are open (seehttps://github.com/philpep/testinfra/pull/320). - Updated tests to use correct mechanism for setting-up list of machines where the tests should be run. --- diff --git a/roles/common/molecule/default/prepare.yml b/roles/common/molecule/default/prepare.yml index 59567b5e85a899689a70209645fc87dbbbbdcaf3..dc7886f2a699dc55f301bb12853dbe16404b1b4d 100644 --- a/roles/common/molecule/default/prepare.yml +++ b/roles/common/molecule/default/prepare.yml @@ -23,3 +23,10 @@ apt: name: net-tools state: present + +- hosts: parameters-mandatory,parameters-optional + become: true + tasks: + + - name: Rename the ss utility (see https://github.com/philpep/testinfra/pull/320) + command: "mv /bin/ss /bin/ss.bak" diff --git a/roles/common/molecule/default/tests/test_default.py b/roles/common/molecule/default/tests/test_default.py index 0061e53a9332d7f8ab3a42050d3b07b00f40ec90..ccad7b6bd2ee408e63fa35fc39fe2785c2851625 100644 --- a/roles/common/molecule/default/tests/test_default.py +++ b/roles/common/molecule/default/tests/test_default.py @@ -1,9 +1,10 @@ +import os + import testinfra.utils.ansible_runner testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( - '.molecule/ansible_inventory.yml').get_hosts('all') -testinfra_hosts.remove("helper") + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts(['parameters-mandatory', 'parameters-optional']) def test_pam_umask(host): diff --git a/roles/common/molecule/default/tests/test_parameters_mandatory.py b/roles/common/molecule/default/tests/test_parameters_mandatory.py index 9d6e4c73b638be39f642c664d81bf54209d810d9..6750dfcd091dc61ac81e405e03e3273c3b52e54e 100644 --- a/roles/common/molecule/default/tests/test_parameters_mandatory.py +++ b/roles/common/molecule/default/tests/test_parameters_mandatory.py @@ -1,3 +1,4 @@ +import os import socket import paramiko @@ -6,7 +7,7 @@ import testinfra.utils.ansible_runner testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( - '.molecule/ansible_inventory.yml').get_hosts('parameters-mandatory') + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts(['parameters-mandatory']) def test_apt_proxy(host): diff --git a/roles/common/molecule/default/tests/test_parameters_optional.py b/roles/common/molecule/default/tests/test_parameters_optional.py index e6f18e1a9d2ed61d3b89e6d128206f527a46ff85..36b84dfac6f2d7b11848200af82346be99407ad1 100644 --- a/roles/common/molecule/default/tests/test_parameters_optional.py +++ b/roles/common/molecule/default/tests/test_parameters_optional.py @@ -8,7 +8,7 @@ import testinfra.utils.ansible_runner testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( - '.molecule/ansible_inventory.yml').get_hosts('parameters-optional') + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts(['parameters-optional']) def test_apt_proxy(host):