From 13e7f8a3330116602694631455ffed9953918989 Mon Sep 17 00:00:00 2001 From: Wen Liang Date: Tue, 20 Apr 2021 22:09:12 -0400 Subject: [PATCH] Support conditional testing for NM provider - To properly run tests for features that are supported both in initscripts and NM but require a specific NM version or other condition, add a new test category for these tests. - Use the new test category to enable testing coalesce support with initscripts Signed-off-by: Wen Liang --- .yamllint.yml | 1 + tests/ensure_provider_tests.py | 30 ++++++++++++++------ tests/tests_ethtool_coalesce_initscripts.yml | 13 +++++++++ 3 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 tests/tests_ethtool_coalesce_initscripts.yml diff --git a/.yamllint.yml b/.yamllint.yml index e50c134..bd4bad0 100644 --- a/.yamllint.yml +++ b/.yamllint.yml @@ -21,3 +21,4 @@ rules: ignore: | /tests/tests_wireless_plugin_installation_nm.yml /tests/tests_team_plugin_installation_nm.yml + /tests/tests_ethtool_coalesce_initscripts.yml diff --git a/tests/ensure_provider_tests.py b/tests/ensure_provider_tests.py index dc3f944..53a0ff7 100755 --- a/tests/ensure_provider_tests.py +++ b/tests/ensure_provider_tests.py @@ -72,10 +72,6 @@ NM_ONLY_TESTS = { MINIMUM_VERSION: "'1.20.0'", "comment": "# NetworKmanager 1.20.0 added support for forgetting profiles", }, - "playbooks/tests_ethtool_coalesce.yml": { - MINIMUM_VERSION: "'1.25.1'", - "comment": "# NetworkManager 1.25.1 introduced ethtool coalesce support", - }, "playbooks/tests_reapply.yml": {}, # team interface is not supported on Fedora "playbooks/tests_team.yml": { @@ -89,6 +85,15 @@ NM_ONLY_TESTS = { }, "playbooks/tests_wireless_plugin_installation.yml": {}, } +# NM_CONDITIONAL_TESTS is used to store the test playbooks which are demanding for NM +# minimum version or extra running condition, test playbooks in NM_CONDITIONAL_TESTS +# can also run with initscripts provider +NM_CONDITIONAL_TESTS = { + "playbooks/tests_ethtool_coalesce.yml": { + MINIMUM_VERSION: "'1.25.1'", + "comment": "# NetworkManager 1.25.1 introduced ethtool coalesce support", + }, +} IGNORE = [ # checked by tests_regression_nm.yml @@ -114,12 +119,19 @@ RUN_PLAYBOOK_WITH_INITSCRIPTS = """# SPDX-License-Identifier: BSD-3-Clause def create_nm_playbook(test_playbook): fileroot = os.path.splitext(os.path.basename(test_playbook))[0] nm_testfile = fileroot + "_nm.yml" + if test_playbook in NM_CONDITIONAL_TESTS: + minimum_nm_version = NM_CONDITIONAL_TESTS[test_playbook].get(MINIMUM_VERSION) + extra_run_condition = NM_CONDITIONAL_TESTS[test_playbook].get( + EXTRA_RUN_CONDITION, "" + ) + comment = NM_CONDITIONAL_TESTS.get(test_playbook, {}).get("comment", "") + else: + minimum_nm_version = NM_ONLY_TESTS.get(test_playbook, {}).get(MINIMUM_VERSION) + extra_run_condition = NM_ONLY_TESTS.get(test_playbook, {}).get( + EXTRA_RUN_CONDITION, "" + ) + comment = NM_ONLY_TESTS.get(test_playbook, {}).get("comment", "") - minimum_nm_version = NM_ONLY_TESTS.get(test_playbook, {}).get(MINIMUM_VERSION) - extra_run_condition = NM_ONLY_TESTS.get(test_playbook, {}).get( - EXTRA_RUN_CONDITION, "" - ) - comment = NM_ONLY_TESTS.get(test_playbook, {}).get("comment", "") if extra_run_condition: extra_run_condition = f"{EXTRA_RUN_CONDITION_PREFIX}{extra_run_condition}\n" diff --git a/tests/tests_ethtool_coalesce_initscripts.yml b/tests/tests_ethtool_coalesce_initscripts.yml new file mode 100644 index 0000000..7d06d81 --- /dev/null +++ b/tests/tests_ethtool_coalesce_initscripts.yml @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: BSD-3-Clause +# This file was generated by ensure_provider_tests.py +--- +- hosts: all + name: Run playbook 'playbooks/tests_ethtool_coalesce.yml' with initscripts as provider + tasks: + - name: Set network provider to 'initscripts' + set_fact: + network_provider: initscripts + tags: + - always + +- import_playbook: playbooks/tests_ethtool_coalesce.yml