From 16ba71f3038dcc8db1dabca9007d05bfc9c97f3e Mon Sep 17 00:00:00 2001 From: Till Maas Date: Sat, 18 Apr 2020 11:31:29 +0200 Subject: [PATCH] Integration tests: Explicitly select provider Instead of determining the non-default provider, run all integration tests explicitly for both providers or only the providers that are required. Since Ansible does not allow to pass variables to playbooks imported with `import_playbook` to select another playbook to import, generate the files instead of using a shared playbook like `run_with_nm.yml` or `run_with_initscripts.yml`. --- .travis/config.sh | 7 + .travis/custom.sh | 2 +- examples/down-profile.yml | 1 - examples/down_profile.yml | 1 + examples/remove-profile.yml | 1 - examples/remove_profile.yml | 1 + tests/ensure_non_running_provider.py | 118 ----------- tests/ensure_provider_tests.py | 187 ++++++++++++++++++ .../down_profile.yml} | 0 .../remove_profile.yml} | 0 .../run_tasks.yml} | 0 tests/{ => playbooks}/tests_bridge.yml | 12 +- tests/{ => playbooks}/tests_ethernet.yml | 4 +- tests/tests_802_1x_nm.yml | 10 +- tests/tests_bridge_initscripts.yml | 11 ++ tests/tests_bridge_nm.yml | 21 ++ tests/tests_bridge_other_provider.yml | 18 -- tests/tests_ethernet_initscripts.yml | 11 ++ tests/tests_ethernet_nm.yml | 21 ++ tests/tests_ethernet_other_provider.yml | 18 -- tests/tests_ethtool_features_nm.yml | 34 ++-- tests/tests_reapply_nm.yml | 8 +- tests/tests_regression_nm.yml | 1 + tests/tests_states.yml | 11 -- tests/tests_states_nm.yml | 21 ++ tests/tests_vlan_mtu_initscripts.yml | 8 +- tests/tests_vlan_mtu_nm.yml | 10 +- 27 files changed, 337 insertions(+), 200 deletions(-) delete mode 120000 examples/down-profile.yml create mode 120000 examples/down_profile.yml delete mode 120000 examples/remove-profile.yml create mode 120000 examples/remove_profile.yml delete mode 100755 tests/ensure_non_running_provider.py create mode 100755 tests/ensure_provider_tests.py rename tests/{down-profile.yml => playbooks/down_profile.yml} (100%) rename tests/{remove-profile.yml => playbooks/remove_profile.yml} (100%) rename tests/{run-tasks.yml => playbooks/run_tasks.yml} (100%) rename tests/{ => playbooks}/tests_bridge.yml (83%) rename tests/{ => playbooks}/tests_ethernet.yml (94%) create mode 100644 tests/tests_bridge_initscripts.yml create mode 100644 tests/tests_bridge_nm.yml delete mode 100644 tests/tests_bridge_other_provider.yml create mode 100644 tests/tests_ethernet_initscripts.yml create mode 100644 tests/tests_ethernet_nm.yml delete mode 100644 tests/tests_ethernet_other_provider.yml delete mode 100644 tests/tests_states.yml create mode 100644 tests/tests_states_nm.yml diff --git a/.travis/config.sh b/.travis/config.sh index c1262bb..16b9e58 100644 --- a/.travis/config.sh +++ b/.travis/config.sh @@ -39,6 +39,13 @@ # # - RUN_FLAKE8_DISABLED # - RUN_FLAKE8_EXTRA_ARGS +if [[ "$(python2 -c "import sys; print(sys.version_info.major)")" == "2" ]] +then + PYTHON2_EXCLUDES="tests/ensure_provider_tests.py" + FLAKE8_DEFAULT_EXCLUDES=".svn,CVS,.bzr,.hg,.git,__pycache__,.tox,.eggs,*.egg" + RUN_PYLINT_EXCLUDE='^(\..*|ensure_provider_tests\.py)$' + RUN_FLAKE8_EXTRA_ARGS="--exclude ${FLAKE8_DEFAULT_EXCLUDES},${PYTHON2_EXCLUDES}" +fi # # * .travis/runsyspycmd.sh: # diff --git a/.travis/custom.sh b/.travis/custom.sh index 9a1738b..2775a41 100755 --- a/.travis/custom.sh +++ b/.travis/custom.sh @@ -11,5 +11,5 @@ SCRIPTDIR=$(readlink -f $(dirname $0)) # Write your custom commands here that should be run when `tox -e custom`: if [[ -z "${TRAVIS}" ]] || lsr_check_python_version python -eq '3.6'; then - (set -x; cd ${TOPDIR}/tests; ${ENVPYTHON} ./ensure_non_running_provider.py) + (set -x; cd ${TOPDIR}/tests; ${ENVPYTHON} ./ensure_provider_tests.py) fi diff --git a/examples/down-profile.yml b/examples/down-profile.yml deleted file mode 120000 index d5d2ed7..0000000 --- a/examples/down-profile.yml +++ /dev/null @@ -1 +0,0 @@ -../tests/down-profile.yml \ No newline at end of file diff --git a/examples/down_profile.yml b/examples/down_profile.yml new file mode 120000 index 0000000..fe44746 --- /dev/null +++ b/examples/down_profile.yml @@ -0,0 +1 @@ +../tests/playbooks/down_profile.yml \ No newline at end of file diff --git a/examples/remove-profile.yml b/examples/remove-profile.yml deleted file mode 120000 index f2cf478..0000000 --- a/examples/remove-profile.yml +++ /dev/null @@ -1 +0,0 @@ -../tests/remove-profile.yml \ No newline at end of file diff --git a/examples/remove_profile.yml b/examples/remove_profile.yml new file mode 120000 index 0000000..d9959bc --- /dev/null +++ b/examples/remove_profile.yml @@ -0,0 +1 @@ +../tests/playbooks/remove_profile.yml \ No newline at end of file diff --git a/tests/ensure_non_running_provider.py b/tests/ensure_non_running_provider.py deleted file mode 100755 index 2fb2176..0000000 --- a/tests/ensure_non_running_provider.py +++ /dev/null @@ -1,118 +0,0 @@ -#!/usr/bin/env python3 -# SPDX-License-Identifier: BSD-3-Clause -""" Check that there is a playbook to run all role tests with the non-default -provider as well """ -# vim: fileencoding=utf8 - -import glob -import os -import sys - - -import yaml - -OTHER_PROVIDER_SUFFIX = "_other_provider.yml" - -IGNORE = [ - "tests_802_1x_nm.yml", - "tests_default_initscripts.yml", - "tests_default_nm.yml", - "tests_default.yml", - "tests_ethtool_features_initscripts.yml", - "tests_ethtool_features_nm.yml", - "tests_helpers-and-asserts.yml", - "tests_reapply_nm.yml", - "tests_regression_nm.yml", - "tests_states.yml", - "tests_unit.yml", - "tests_vlan_mtu_initscripts.yml", - "tests_vlan_mtu_nm.yml", -] - -OTHER_PLAYBOOK = """ -# SPDX-License-Identifier: BSD-3-Clause ---- -- name: Run playbook '{tests_playbook}' with non-default provider - hosts: all - vars: - network_provider_current: - tasks: - # required for the code to set network_provider_current - - name: Get service facts - service_facts: - - name: Set network provider - set_fact: - network_provider: '{{{{ "initscripts" if network_provider_current == "nm" - else "nm" }}}}' - -- import_playbook: "{tests_playbook}" - when: - - ansible_distribution_major_version != '6' -""" # noqa: E501 # ignore that the line is too long - - -def get_current_provider_code(): - with open("../defaults/main.yml") as defaults: - yaml_defaults = yaml.safe_load(defaults) - current_provider = yaml_defaults["network_provider_current"] - return current_provider - - -def generate_nominal_other_playbook(tests_playbook): - nominal_other_testfile_data = OTHER_PLAYBOOK.format(tests_playbook=tests_playbook) - nominal = yaml.safe_load(nominal_other_testfile_data) - nominal[0]["vars"]["network_provider_current"] = get_current_provider_code() - yaml_dump = yaml.dump( - nominal, default_flow_style=False, explicit_start=True, width=80 - ) - return "# yamllint disable\n" + yaml_dump - - -def main(): - testsfiles = glob.glob("tests_*.yml") - missing = [] - returncode = 0 - - # Generate files when specified - generate = bool(len(sys.argv) > 1 and sys.argv[1] == "generate") - - if not testsfiles: - print("ERROR: No tests found") - returncode = 1 - - for filename in testsfiles: - if filename.endswith(OTHER_PROVIDER_SUFFIX): - continue - - if filename in IGNORE: - continue - - fileroot = os.path.splitext(filename)[0] - other_testfile = fileroot + OTHER_PROVIDER_SUFFIX - nominal_other_testfile_data = generate_nominal_other_playbook(filename) - - if generate: - with open(other_testfile, "w") as ofile: - ofile.write(nominal_other_testfile_data) - - if other_testfile not in testsfiles and not generate: - missing.append(filename) - else: - with open(other_testfile) as ifile: - testdata = ifile.read() - if testdata != nominal_other_testfile_data: - print( - "ERROR: Playbook does not match nominal value " + other_testfile - ) - returncode = 1 - - if missing: - print("ERROR: No tests for other provider found for:\n" + ", \n".join(missing)) - print("Try to generate them with '{} generate'".format(sys.argv[0])) - returncode = 1 - - return returncode - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/tests/ensure_provider_tests.py b/tests/ensure_provider_tests.py new file mode 100755 index 0000000..04c26f1 --- /dev/null +++ b/tests/ensure_provider_tests.py @@ -0,0 +1,187 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: BSD-3-Clause +""" Check that there is a playbook to run all role tests with both providers +""" +# vim: fileencoding=utf8 + +import glob +import os +import sys + + +GET_NM_VERSION = """ + - block: + - name: Install NetworkManager + package: + name: NetworkManager + state: present + - name: Get NetworkManager version + command: rpm -q --qf "%{version}" NetworkManager + args: + warn: false + register: NetworkManager_version + when: true + when: + - ansible_distribution_major_version != '6' +""" + +MINIMUM_NM_VERSION_CHECK = """ + - NetworkManager_version.stdout is version({minimum_nm_version}, '>=') +""" + +RUN_PLAYBOOK_WITH_NM = """# SPDX-License-Identifier: BSD-3-Clause +# This file was generated by ensure_provider_tests.py +--- +# set network provider and gather facts +- hosts: all + name: Run playbook '{test_playbook}' with nm as provider + tasks: + - name: Set network provider to 'nm' + set_fact: + network_provider: nm +{get_nm_version} + +# workaround for: https://github.com/ansible/ansible/issues/27973 +# There is no way in Ansible to abort a playbook hosts with specific OS +# releases Therefore we include the playbook with the tests only if the hosts +# would support it. +# The test requires or should run with NetworkManager, therefore it cannot run +# on RHEL/CentOS 6 +- import_playbook: {test_playbook} + when: + - ansible_distribution_major_version != '6' +{minimum_nm_version_check}""" + +MINIMUM_VERSION = "minimum_version" +NM_ONLY_TESTS = { + "playbooks/tests_ethtool_features.yml": { + MINIMUM_VERSION: "'1.20.0'", + "comment": "# NetworkManager 1.20.0 introduced ethtool settings support", + }, + "playbooks/tests_reapply.yml": {}, + "playbooks/tests_states.yml": {}, + "playbooks/tests_802_1x.yml": {}, +} + +IGNORE = [ + # checked by tests_regression_nm.yml + "playbooks/tests_checkpoint_cleanup.yml", +] + +RUN_PLAYBOOK_WITH_INITSCRIPTS = """# SPDX-License-Identifier: BSD-3-Clause +# This file was generated by ensure_provider_tests.py +--- +- hosts: all + name: Run playbook '{test_playbook}' with initscripts as provider + tasks: + - name: Set network provider to 'initscripts' + set_fact: + network_provider: initscripts + +- import_playbook: {test_playbook} +""" + + +def create_nm_playbook(test_playbook): + fileroot = os.path.splitext(os.path.basename(test_playbook))[0] + nm_testfile = fileroot + "_nm.yml" + + minimum_nm_version = NM_ONLY_TESTS.get(test_playbook, {}).get(MINIMUM_VERSION) + nm_version_check = "" + if minimum_nm_version: + nm_version_check = MINIMUM_NM_VERSION_CHECK.format( + minimum_nm_version=minimum_nm_version + ) + + nominal_nm_testfile_data = RUN_PLAYBOOK_WITH_NM.format( + test_playbook=test_playbook, + get_nm_version=minimum_nm_version and GET_NM_VERSION or "", + minimum_nm_version_check=nm_version_check, + ) + + return nm_testfile, nominal_nm_testfile_data + + +def create_initscripts_playbook(test_playbook): + fileroot = os.path.splitext(os.path.basename(test_playbook))[0] + init_testfile = fileroot + "_initscripts.yml" + + nominal_data = RUN_PLAYBOOK_WITH_INITSCRIPTS.format(test_playbook=test_playbook) + + return init_testfile, nominal_data + + +def check_playbook(generate, testfile, test_playbook, nominal_data): + is_missing = False + returncode = None + if generate: + print(testfile) + with open(testfile, "w") as ofile: + ofile.write(nominal_data) + + if not os.path.isfile(testfile) and not generate: + is_missing = True + else: + with open(testfile) as ifile: + testdata = ifile.read() + if testdata != nominal_data: + print(f"ERROR: Playbook does not match nominal value: {testfile}") + returncode = 1 + + return is_missing, returncode + + +def main(): + testsfiles = glob.glob("playbooks/tests_*.yml") + missing = [] + returncode = 0 + + # Generate files when specified + generate = bool(len(sys.argv) > 1 and sys.argv[1] == "generate") + + if not testsfiles: + print("ERROR: No tests found") + returncode = 1 + + for test_playbook in testsfiles: + if test_playbook in IGNORE: + continue + + nm_testfile, nominal_nm_testfile_data = create_nm_playbook(test_playbook) + + is_missing, new_returncode = check_playbook( + generate=generate, + testfile=nm_testfile, + test_playbook=test_playbook, + nominal_data=nominal_nm_testfile_data, + ) + if is_missing: + missing.append(test_playbook) + if new_returncode: + returncode = new_returncode + + if test_playbook not in NM_ONLY_TESTS: + init_testfile, nominal_init_testfile_data = create_initscripts_playbook( + test_playbook + ) + is_missing, new_returncode = check_playbook( + generate=generate, + testfile=init_testfile, + test_playbook=test_playbook, + nominal_data=nominal_init_testfile_data, + ) + if is_missing: + missing.append(test_playbook) + if new_returncode: + returncode = new_returncode + + if missing: + print("ERROR: No NM or initscripts tests found for:\n" + ", \n".join(missing)) + print("Try to generate them with '{} generate'".format(sys.argv[0])) + returncode = 1 + + return returncode + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tests/down-profile.yml b/tests/playbooks/down_profile.yml similarity index 100% rename from tests/down-profile.yml rename to tests/playbooks/down_profile.yml diff --git a/tests/remove-profile.yml b/tests/playbooks/remove_profile.yml similarity index 100% rename from tests/remove-profile.yml rename to tests/playbooks/remove_profile.yml diff --git a/tests/run-tasks.yml b/tests/playbooks/run_tasks.yml similarity index 100% rename from tests/run-tasks.yml rename to tests/playbooks/run_tasks.yml diff --git a/tests/tests_bridge.yml b/tests/playbooks/tests_bridge.yml similarity index 83% rename from tests/tests_bridge.yml rename to tests/playbooks/tests_bridge.yml index bcd8572..f1b4332 100644 --- a/tests/tests_bridge.yml +++ b/tests/playbooks/tests_bridge.yml @@ -26,30 +26,30 @@ roles: - linux-system-roles.network -- import_playbook: run-tasks.yml +- import_playbook: run_tasks.yml vars: task: tasks/assert-device_present.yml -- import_playbook: run-tasks.yml +- import_playbook: run_tasks.yml vars: profile: "{{ interface }}" task: tasks/assert-profile_present.yml -- import_playbook: down-profile.yml +- import_playbook: down_profile.yml vars: profile: "{{ interface }}" # FIXME: assert profile/device down -- import_playbook: remove-profile.yml +- import_playbook: remove_profile.yml vars: profile: "{{ interface }}" -- import_playbook: run-tasks.yml +- import_playbook: run_tasks.yml vars: profile: "{{ interface }}" task: tasks/assert-profile_absent.yml # FIXME: Devices might still be left when profile is absent -# - import_playbook: run-tasks.yml +# - import_playbook: run_tasks.yml # vars: # task: tasks/assert-device_absent.yml diff --git a/tests/tests_ethernet.yml b/tests/playbooks/tests_ethernet.yml similarity index 94% rename from tests/tests_ethernet.yml rename to tests/playbooks/tests_ethernet.yml index 25f117d..99360d6 100644 --- a/tests/tests_ethernet.yml +++ b/tests/playbooks/tests_ethernet.yml @@ -45,11 +45,11 @@ # FIXME: assert profile present # FIXME: assert profile/device up + IP address -- import_playbook: down-profile.yml +- import_playbook: down_profile.yml vars: profile: "{{ interface }}" # FIXME: assert profile/device down -- import_playbook: remove-profile.yml +- import_playbook: remove_profile.yml vars: profile: "{{ interface }}" # FIXME: assert profile away diff --git a/tests/tests_802_1x_nm.yml b/tests/tests_802_1x_nm.yml index f4ad1be..caa3f0d 100644 --- a/tests/tests_802_1x_nm.yml +++ b/tests/tests_802_1x_nm.yml @@ -1,15 +1,21 @@ +# SPDX-License-Identifier: BSD-3-Clause +# This file was generated by ensure_provider_tests.py --- # set network provider and gather facts - hosts: all + name: Run playbook 'playbooks/tests_802_1x.yml' with nm as provider tasks: - name: Set network provider to 'nm' set_fact: network_provider: nm + # workaround for: https://github.com/ansible/ansible/issues/27973 # There is no way in Ansible to abort a playbook hosts with specific OS # releases Therefore we include the playbook with the tests only if the hosts # would support it. -# The test requires NetworkManager, therefore it cannot run on RHEL/CentOS 6 +# The test requires or should run with NetworkManager, therefore it cannot run +# on RHEL/CentOS 6 - import_playbook: playbooks/tests_802_1x.yml - when: ansible_distribution_major_version != '6' + when: + - ansible_distribution_major_version != '6' diff --git a/tests/tests_bridge_initscripts.yml b/tests/tests_bridge_initscripts.yml new file mode 100644 index 0000000..6299083 --- /dev/null +++ b/tests/tests_bridge_initscripts.yml @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: BSD-3-Clause +# This file was generated by ensure_provider_tests.py +--- +- hosts: all + name: Run playbook 'playbooks/tests_bridge.yml' with initscripts as provider + tasks: + - name: Set network provider to 'initscripts' + set_fact: + network_provider: initscripts + +- import_playbook: playbooks/tests_bridge.yml diff --git a/tests/tests_bridge_nm.yml b/tests/tests_bridge_nm.yml new file mode 100644 index 0000000..f50810d --- /dev/null +++ b/tests/tests_bridge_nm.yml @@ -0,0 +1,21 @@ +# SPDX-License-Identifier: BSD-3-Clause +# This file was generated by ensure_provider_tests.py +--- +# set network provider and gather facts +- hosts: all + name: Run playbook 'playbooks/tests_bridge.yml' with nm as provider + tasks: + - name: Set network provider to 'nm' + set_fact: + network_provider: nm + + +# workaround for: https://github.com/ansible/ansible/issues/27973 +# There is no way in Ansible to abort a playbook hosts with specific OS +# releases Therefore we include the playbook with the tests only if the hosts +# would support it. +# The test requires or should run with NetworkManager, therefore it cannot run +# on RHEL/CentOS 6 +- import_playbook: playbooks/tests_bridge.yml + when: + - ansible_distribution_major_version != '6' diff --git a/tests/tests_bridge_other_provider.yml b/tests/tests_bridge_other_provider.yml deleted file mode 100644 index 6de85bd..0000000 --- a/tests/tests_bridge_other_provider.yml +++ /dev/null @@ -1,18 +0,0 @@ -# yamllint disable ---- -- hosts: all - name: Run playbook 'tests_bridge.yml' with non-default provider - tasks: - - name: Get service facts - service_facts: null - - name: Set network provider - set_fact: - network_provider: '{{ "initscripts" if network_provider_current == "nm" else - "nm" }}' - vars: - network_provider_current: '{{ ''nm'' if ''NetworkManager.service'' in ansible_facts.services - and ansible_facts.services[''NetworkManager.service''][''state''] == ''running'' - else ''initscripts'' }}' -- import_playbook: tests_bridge.yml - when: - - ansible_distribution_major_version != '6' diff --git a/tests/tests_ethernet_initscripts.yml b/tests/tests_ethernet_initscripts.yml new file mode 100644 index 0000000..87e55a4 --- /dev/null +++ b/tests/tests_ethernet_initscripts.yml @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: BSD-3-Clause +# This file was generated by ensure_provider_tests.py +--- +- hosts: all + name: Run playbook 'playbooks/tests_ethernet.yml' with initscripts as provider + tasks: + - name: Set network provider to 'initscripts' + set_fact: + network_provider: initscripts + +- import_playbook: playbooks/tests_ethernet.yml diff --git a/tests/tests_ethernet_nm.yml b/tests/tests_ethernet_nm.yml new file mode 100644 index 0000000..a2f6d29 --- /dev/null +++ b/tests/tests_ethernet_nm.yml @@ -0,0 +1,21 @@ +# SPDX-License-Identifier: BSD-3-Clause +# This file was generated by ensure_provider_tests.py +--- +# set network provider and gather facts +- hosts: all + name: Run playbook 'playbooks/tests_ethernet.yml' with nm as provider + tasks: + - name: Set network provider to 'nm' + set_fact: + network_provider: nm + + +# workaround for: https://github.com/ansible/ansible/issues/27973 +# There is no way in Ansible to abort a playbook hosts with specific OS +# releases Therefore we include the playbook with the tests only if the hosts +# would support it. +# The test requires or should run with NetworkManager, therefore it cannot run +# on RHEL/CentOS 6 +- import_playbook: playbooks/tests_ethernet.yml + when: + - ansible_distribution_major_version != '6' diff --git a/tests/tests_ethernet_other_provider.yml b/tests/tests_ethernet_other_provider.yml deleted file mode 100644 index 6989b60..0000000 --- a/tests/tests_ethernet_other_provider.yml +++ /dev/null @@ -1,18 +0,0 @@ -# yamllint disable ---- -- hosts: all - name: Run playbook 'tests_ethernet.yml' with non-default provider - tasks: - - name: Get service facts - service_facts: null - - name: Set network provider - set_fact: - network_provider: '{{ "initscripts" if network_provider_current == "nm" else - "nm" }}' - vars: - network_provider_current: '{{ ''nm'' if ''NetworkManager.service'' in ansible_facts.services - and ansible_facts.services[''NetworkManager.service''][''state''] == ''running'' - else ''initscripts'' }}' -- import_playbook: tests_ethernet.yml - when: - - ansible_distribution_major_version != '6' diff --git a/tests/tests_ethtool_features_nm.yml b/tests/tests_ethtool_features_nm.yml index 28e5144..16f9ca5 100644 --- a/tests/tests_ethtool_features_nm.yml +++ b/tests/tests_ethtool_features_nm.yml @@ -1,29 +1,37 @@ +# SPDX-License-Identifier: BSD-3-Clause +# This file was generated by ensure_provider_tests.py --- # set network provider and gather facts - hosts: all + name: Run playbook 'playbooks/tests_ethtool_features.yml' with nm as provider tasks: - name: Set network provider to 'nm' set_fact: network_provider: nm - - name: Install NetworkManager - package: - name: NetworkManager - state: present - - name: Get NetworkManager version - command: rpm -q --qf "%{version}" NetworkManager - args: - warn: "no" - when: true - register: NetworkManager_version + + - block: + - name: Install NetworkManager + package: + name: NetworkManager + state: present + - name: Get NetworkManager version + command: rpm -q --qf "%{version}" NetworkManager + args: + warn: false + register: NetworkManager_version + when: true + when: + - ansible_distribution_major_version != '6' + # workaround for: https://github.com/ansible/ansible/issues/27973 # There is no way in Ansible to abort a playbook hosts with specific OS # releases Therefore we include the playbook with the tests only if the hosts # would support it. -# The test should run with NetworkManager, therefore it cannot run on -# RHEL/CentOS 6 +# The test requires or should run with NetworkManager, therefore it cannot run +# on RHEL/CentOS 6 - import_playbook: playbooks/tests_ethtool_features.yml when: - ansible_distribution_major_version != '6' - # NetworkManager 1.20.0 introduced ethtool settings support + - NetworkManager_version.stdout is version('1.20.0', '>=') diff --git a/tests/tests_reapply_nm.yml b/tests/tests_reapply_nm.yml index 81f3570..e3458e5 100644 --- a/tests/tests_reapply_nm.yml +++ b/tests/tests_reapply_nm.yml @@ -1,17 +1,21 @@ +# SPDX-License-Identifier: BSD-3-Clause +# This file was generated by ensure_provider_tests.py --- # set network provider and gather facts - hosts: all + name: Run playbook 'playbooks/tests_reapply.yml' with nm as provider tasks: - name: Set network provider to 'nm' set_fact: network_provider: nm + # workaround for: https://github.com/ansible/ansible/issues/27973 # There is no way in Ansible to abort a playbook hosts with specific OS # releases Therefore we include the playbook with the tests only if the hosts # would support it. -# The test should run with NetworkManager, therefore it cannot run on -# RHEL/CentOS 6 +# The test requires or should run with NetworkManager, therefore it cannot run +# on RHEL/CentOS 6 - import_playbook: playbooks/tests_reapply.yml when: - ansible_distribution_major_version != '6' diff --git a/tests/tests_regression_nm.yml b/tests/tests_regression_nm.yml index 2094c2e..9eb8084 100644 --- a/tests/tests_regression_nm.yml +++ b/tests/tests_regression_nm.yml @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: BSD-3-Clause --- # set network provider and gather facts - hosts: all diff --git a/tests/tests_states.yml b/tests/tests_states.yml deleted file mode 100644 index b45030d..0000000 --- a/tests/tests_states.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -# empty playbook to gather facts for import_playbook when clause -- hosts: all - -# workaround for: https://github.com/ansible/ansible/issues/27973 -# There is no way in Ansible to abort a playbook hosts with specific OS -# releases Therefore we include the playbook with the tests only if the hosts -# would support it. -# The test requires NetworkManager, therefore it cannot run on RHEL/CentOS 6 -- import_playbook: playbooks/tests_states.yml - when: ansible_distribution_major_version != '6' diff --git a/tests/tests_states_nm.yml b/tests/tests_states_nm.yml new file mode 100644 index 0000000..506b364 --- /dev/null +++ b/tests/tests_states_nm.yml @@ -0,0 +1,21 @@ +# SPDX-License-Identifier: BSD-3-Clause +# This file was generated by ensure_provider_tests.py +--- +# set network provider and gather facts +- hosts: all + name: Run playbook 'playbooks/tests_states.yml' with nm as provider + tasks: + - name: Set network provider to 'nm' + set_fact: + network_provider: nm + + +# workaround for: https://github.com/ansible/ansible/issues/27973 +# There is no way in Ansible to abort a playbook hosts with specific OS +# releases Therefore we include the playbook with the tests only if the hosts +# would support it. +# The test requires or should run with NetworkManager, therefore it cannot run +# on RHEL/CentOS 6 +- import_playbook: playbooks/tests_states.yml + when: + - ansible_distribution_major_version != '6' diff --git a/tests/tests_vlan_mtu_initscripts.yml b/tests/tests_vlan_mtu_initscripts.yml index a57db4b..c85c099 100644 --- a/tests/tests_vlan_mtu_initscripts.yml +++ b/tests/tests_vlan_mtu_initscripts.yml @@ -1,13 +1,11 @@ +# SPDX-License-Identifier: BSD-3-Clause +# This file was generated by ensure_provider_tests.py --- -# set network provider and gather facts - hosts: all + name: Run playbook 'playbooks/tests_vlan_mtu.yml' with initscripts as provider tasks: - name: Set network provider to 'initscripts' set_fact: network_provider: initscripts -# workaround for: https://github.com/ansible/ansible/issues/27973 -# There is no way in Ansible to abort a playbook hosts with specific OS -# releases Therefore we include the playbook with the tests only if the hosts -# would support it. - import_playbook: playbooks/tests_vlan_mtu.yml diff --git a/tests/tests_vlan_mtu_nm.yml b/tests/tests_vlan_mtu_nm.yml index d777370..0037ffd 100644 --- a/tests/tests_vlan_mtu_nm.yml +++ b/tests/tests_vlan_mtu_nm.yml @@ -1,15 +1,21 @@ +# SPDX-License-Identifier: BSD-3-Clause +# This file was generated by ensure_provider_tests.py --- # set network provider and gather facts - hosts: all + name: Run playbook 'playbooks/tests_vlan_mtu.yml' with nm as provider tasks: - name: Set network provider to 'nm' set_fact: network_provider: nm + # workaround for: https://github.com/ansible/ansible/issues/27973 # There is no way in Ansible to abort a playbook hosts with specific OS # releases Therefore we include the playbook with the tests only if the hosts # would support it. -# The test requires NetworkManager, therefore it cannot run on RHEL/CentOS 6 +# The test requires or should run with NetworkManager, therefore it cannot run +# on RHEL/CentOS 6 - import_playbook: playbooks/tests_vlan_mtu.yml - when: ansible_distribution_major_version != '6' + when: + - ansible_distribution_major_version != '6'