From fb5d6218deeaae102bca6ddc0d9bf1be7c754a09 Mon Sep 17 00:00:00 2001 From: Wen Liang Date: Wed, 28 Oct 2020 20:04:33 -0400 Subject: [PATCH] Test installation of NetworkManager plugins Signed-off-by: Wen Liang --- .yamllint.yml | 4 ++ tests/ensure_provider_tests.py | 2 + .../tests_team_plugin_installation.yml | 40 +++++++++++++++++++ .../tests_wireless_plugin_installation.yml | 40 +++++++++++++++++++ tests/tests_team_plugin_installation_nm.yml | 19 +++++++++ .../tests_wireless_plugin_installation_nm.yml | 19 +++++++++ 6 files changed, 124 insertions(+) create mode 100644 tests/playbooks/tests_team_plugin_installation.yml create mode 100644 tests/playbooks/tests_wireless_plugin_installation.yml create mode 100644 tests/tests_team_plugin_installation_nm.yml create mode 100644 tests/tests_wireless_plugin_installation_nm.yml diff --git a/.yamllint.yml b/.yamllint.yml index 24c0391..e50c134 100644 --- a/.yamllint.yml +++ b/.yamllint.yml @@ -17,3 +17,7 @@ extends: yamllint_defaults.yml # line-length: disable rules: truthy: disable + line-length: + ignore: | + /tests/tests_wireless_plugin_installation_nm.yml + /tests/tests_team_plugin_installation_nm.yml diff --git a/tests/ensure_provider_tests.py b/tests/ensure_provider_tests.py index 014f935..078e99d 100755 --- a/tests/ensure_provider_tests.py +++ b/tests/ensure_provider_tests.py @@ -83,11 +83,13 @@ NM_ONLY_TESTS = { "playbooks/tests_team.yml": { EXTRA_RUN_CONDITION: "ansible_distribution != 'Fedora'", }, + "playbooks/tests_team_plugin_installation.yml": {}, # mac80211_hwsim (used for tests_wireless) only seems to be available # and working on RHEL/CentOS 7 "playbooks/tests_wireless.yml": { EXTRA_RUN_CONDITION: "ansible_distribution_major_version == '7'", }, + "playbooks/tests_wireless_plugin_installation.yml": {}, } IGNORE = [ diff --git a/tests/playbooks/tests_team_plugin_installation.yml b/tests/playbooks/tests_team_plugin_installation.yml new file mode 100644 index 0000000..88690a3 --- /dev/null +++ b/tests/playbooks/tests_team_plugin_installation.yml @@ -0,0 +1,40 @@ +# SPDX-License-Identifier: BSD-3-Clause +--- +- hosts: all + tasks: + - name: remove the NetworkManager-team package + package: + name: "NetworkManager-team" + state: absent + + - name: "get the rpm package facts" + package_facts: + manager: "auto" + + - name: "Assert NetworkManager-team removed before team configuration" + assert: + that: + - "'NetworkManager-team' not in ansible_facts.packages" + msg: "NetworkManager-team is not removed before team configuration" + + - name: "Team interface configuration" + include_role: + name: linux-system-roles.network + vars: + network_connections: + # Specify the team profile + - name: team0 + persistent_state: present + type: team + interface_name: team0 + + - name: "get the rpm package facts" + package_facts: + manager: "auto" + + - name: "Assert NetworkManager-team is installed after team configuration" + assert: + that: + - "'NetworkManager-team' in ansible_facts.packages" + msg: "NetworkManager-team is not installed after team configuration" +... diff --git a/tests/playbooks/tests_wireless_plugin_installation.yml b/tests/playbooks/tests_wireless_plugin_installation.yml new file mode 100644 index 0000000..8288bc7 --- /dev/null +++ b/tests/playbooks/tests_wireless_plugin_installation.yml @@ -0,0 +1,40 @@ +# SPDX-License-Identifier: BSD-3-Clause +--- +- hosts: all + tasks: + - name: remove the NetworkManager-wifi package + package: + name: "NetworkManager-wifi" + state: absent + + - name: "get the rpm package facts" + package_facts: + manager: "auto" + + - name: "Assert NetworkManager-wifi removed before wireless configuration" + assert: + that: + - "'NetworkManager-wifi' not in ansible_facts.packages" + msg: "NetworkManager-wifi is not removed before wirelss configuration" + + - name: "wireless configuration" + include_role: + name: linux-system-roles.network + vars: + network_connections: + - name: wlan0 + type: wireless + wireless: + ssid: "My WPA2-PSK Network" + key_mgmt: "wpa-psk" + password: "p@55w0rD" + + - name: "get the rpm package facts" + package_facts: + manager: "auto" + + - name: "Assert NetworkManager-wifi installed after wireless configuration" + assert: + that: + - "'NetworkManager-wifi' in ansible_facts.packages" + msg: "NetworkManager-wifi is not installed after wireless configured" diff --git a/tests/tests_team_plugin_installation_nm.yml b/tests/tests_team_plugin_installation_nm.yml new file mode 100644 index 0000000..4572736 --- /dev/null +++ b/tests/tests_team_plugin_installation_nm.yml @@ -0,0 +1,19 @@ +# 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_team_plugin_installation.yml' with nm as provider + tasks: + - name: Set network provider to 'nm' + set_fact: + network_provider: nm + tags: + - always + + +# The test requires or should run with NetworkManager, therefore it cannot run +# on RHEL/CentOS 6 +- import_playbook: playbooks/tests_team_plugin_installation.yml + when: + - ansible_distribution_major_version != '6' diff --git a/tests/tests_wireless_plugin_installation_nm.yml b/tests/tests_wireless_plugin_installation_nm.yml new file mode 100644 index 0000000..5e55f50 --- /dev/null +++ b/tests/tests_wireless_plugin_installation_nm.yml @@ -0,0 +1,19 @@ +# 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_wireless_plugin_installation.yml' with nm as provider + tasks: + - name: Set network provider to 'nm' + set_fact: + network_provider: nm + tags: + - always + + +# The test requires or should run with NetworkManager, therefore it cannot run +# on RHEL/CentOS 6 +- import_playbook: playbooks/tests_wireless_plugin_installation.yml + when: + - ansible_distribution_major_version != '6'