diff --git a/tasks/main.yml b/tasks/main.yml index 4deb3a00..c55f5efe 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -36,6 +36,9 @@ when: - not network_packages is subset(ansible_facts.packages.keys()) register: __network_package_install + until: __network_package_install is success + retries: 6 + delay: 10 - name: Install NetworkManager and nmstate when using network_state variable package: diff --git a/tests/ensure_provider_tests.py b/tests/ensure_provider_tests.py index e454d046..54c9f843 100755 --- a/tests/ensure_provider_tests.py +++ b/tests/ensure_provider_tests.py @@ -83,7 +83,7 @@ "playbooks/tests_provider.yml": { MINIMUM_VERSION: "'1.20.0'", "comment": "# NetworKmanager 1.20.0 added support for forgetting profiles", - EXTRA_RUN_CONDITION: "ansible_distribution != 'RedHat' or\n ansible_distr\ + EXTRA_RUN_CONDITION: "ansible_distribution not in ['RedHat', 'CentOS'] or\n ansible_distr\ ibution_major_version | int < 9", }, "playbooks/tests_eth_pci_address_match.yml": { diff --git a/tests/playbooks/tests_802_1x.yml b/tests/playbooks/tests_802_1x.yml index aa79ecf0..a02e13ce 100644 --- a/tests/playbooks/tests_802_1x.yml +++ b/tests/playbooks/tests_802_1x.yml @@ -143,3 +143,5 @@ - name: Update ca trust command: update-ca-trust changed_when: false + - name: Verify network state restored to default + include_tasks: tasks/check_network_dns.yml diff --git a/tests/playbooks/tests_auto_gateway.yml b/tests/playbooks/tests_auto_gateway.yml index 4bc23d3c..6a26cc01 100644 --- a/tests/playbooks/tests_auto_gateway.yml +++ b/tests/playbooks/tests_auto_gateway.yml @@ -150,3 +150,5 @@ include_tasks: tasks/manage_test_interface.yml vars: state: absent + - name: Verify network state restored to default + include_tasks: tasks/check_network_dns.yml diff --git a/tests/playbooks/tests_bond.yml b/tests/playbooks/tests_bond.yml index 9be82324..6a49c466 100644 --- a/tests/playbooks/tests_bond.yml +++ b/tests/playbooks/tests_bond.yml @@ -123,3 +123,5 @@ when: - network_provider == "initscripts" changed_when: false + - name: Verify network state restored to default + include_tasks: tasks/check_network_dns.yml diff --git a/tests/playbooks/tests_bond_cloned_mac.yml b/tests/playbooks/tests_bond_cloned_mac.yml index ab9727ff..0c1fe4cf 100644 --- a/tests/playbooks/tests_bond_cloned_mac.yml +++ b/tests/playbooks/tests_bond_cloned_mac.yml @@ -135,3 +135,5 @@ when: - network_provider == "initscripts" changed_when: false + - name: Verify network state restored to default + include_tasks: tasks/check_network_dns.yml diff --git a/tests/playbooks/tests_bond_deprecated.yml b/tests/playbooks/tests_bond_deprecated.yml index 572bf8ac..3aca8c8b 100644 --- a/tests/playbooks/tests_bond_deprecated.yml +++ b/tests/playbooks/tests_bond_deprecated.yml @@ -23,6 +23,11 @@ import_tasks: tasks/assert_device_present.yml vars: interface: "{{ dhcp_interface2 }}" + - name: "Backup the /etc/resolv.conf for initscript" + command: cp -vf /etc/resolv.conf /etc/resolv.conf.bak + when: + - network_provider == "initscripts" + changed_when: false - name: Test bond device using deprecated 'master' argument block: - name: "TEST Add Bond with 2 ports using deprecated 'master' argument" @@ -113,3 +118,10 @@ changed_when: false - name: Import the task 'remove_test_interfaces_with_dhcp.yml' import_tasks: tasks/remove_test_interfaces_with_dhcp.yml + - name: "Restore the /etc/resolv.conf for initscript" + command: mv -vf /etc/resolv.conf.bak /etc/resolv.conf + when: + - network_provider == "initscripts" + changed_when: false + - name: Verify network state restored to default + include_tasks: tasks/check_network_dns.yml diff --git a/tests/playbooks/tests_bond_options.yml b/tests/playbooks/tests_bond_options.yml index 219a015f..73bfc243 100644 --- a/tests/playbooks/tests_bond_options.yml +++ b/tests/playbooks/tests_bond_options.yml @@ -9,201 +9,84 @@ dhcp_interface1: test1 port2_profile: bond0.1 dhcp_interface2: test2 + lsr_fail_debug: + - __network_connections_result + bond_options_to_assert: + - {key: 'mode', value: '802.3ad'} + - {key: 'ad_actor_sys_prio', value: '65535'} + - {key: 'ad_actor_system', value: '00:00:5e:00:53:5d'} + - {key: 'ad_select', value: 'stable'} + - {key: 'ad_user_port_key', value: '1023'} + # wokeignore:rule=slave + - {key: 'all_slaves_active', value: '1'} + - {key: 'downdelay', value: '0'} + - {key: 'lacp_rate', value: 'slow'} + - {key: 'lp_interval', value: '128'} + - {key: 'miimon', value: '110'} + - {key: 'num_grat_arp', value: '64'} + - {key: 'resend_igmp', value: '225'} + - {key: 'updelay', value: '0'} + - {key: 'use_carrier', value: '1'} + - {key: 'xmit_hash_policy', value: 'encap2+3'} tasks: - - name: "INIT Prepare setup" + - name: Show playbook name debug: - msg: "##################################################" - - name: Import the task 'create_test_interfaces_with_dhcp.yml' - import_tasks: tasks/create_test_interfaces_with_dhcp.yml - - name: Import the task 'assert_device_present.yml' - import_tasks: tasks/assert_device_present.yml - vars: - interface: "{{ dhcp_interface1 }}" - - name: Import the task 'assert_device_present.yml' - import_tasks: tasks/assert_device_present.yml - vars: - interface: "{{ dhcp_interface2 }}" - - name: Test bond options - block: - - name: "TEST Add Bond with 2 ports" - debug: - msg: "##################################################" - - name: Configure the bond options - import_role: - name: linux-system-roles.network - vars: - network_connections: - # Create a bond controller - - name: "{{ controller_profile }}" - state: up - type: bond - interface_name: "{{ controller_device }}" - bond: - mode: 802.3ad - ad_actor_sys_prio: 65535 - ad_actor_system: 00:00:5e:00:53:5d - ad_select: stable - ad_user_port_key: 1023 - all_ports_active: true - downdelay: 0 - lacp_rate: slow - lp_interval: 128 - miimon: 110 - min_links: 0 - num_grat_arp: 64 - primary_reselect: better - resend_igmp: 225 - updelay: 0 - use_carrier: true - xmit_hash_policy: encap2+3 - ip: - route_metric4: 65535 + msg: "this is: playbooks/tests_bond_options.yml" + tags: + - always - # add an ethernet to the bond - - name: "{{ port1_profile }}" - state: up - type: ethernet - interface_name: "{{ dhcp_interface1 }}" - controller: "{{ controller_profile }}" - # add a second ethernet to the bond - - name: "{{ port2_profile }}" - state: up - type: ethernet - interface_name: "{{ dhcp_interface2 }}" - controller: "{{ controller_profile }}" - - name: Import the task 'assert_device_present.yml' - import_tasks: tasks/assert_device_present.yml - vars: - interface: "{{ controller_device }}" - - name: Include the task 'assert_profile_present.yml' - include_tasks: tasks/assert_profile_present.yml + - name: Test the bond options + tags: + - tests::bond:create + block: + - name: Include the task 'run_test.yml' + include_tasks: tasks/run_test.yml vars: - profile: "{{ item }}" - loop: - - "{{ controller_profile }}" - - "{{ port1_profile }}" - - "{{ port2_profile }}" + lsr_description: Given two DHCP-enabled network interfaces, + when creating a bond profile with them, + then the controller device and bond port profiles are present and + the specified bond options are set for the controller device. + lsr_setup: + - tasks/create_test_interfaces_with_dhcp.yml + - tasks/assert_dhcp_device_present.yml + lsr_test: + - tasks/create_bond_profile.yml + lsr_assert: + - tasks/assert_controller_device_present.yml + - tasks/assert_bond_port_profile_present.yml + - tasks/assert_bond_options.yml + lsr_cleanup: + - tasks/cleanup_bond_profile+device.yml + - tasks/remove_test_interfaces_with_dhcp.yml - - name: "** TEST check bond settings" - command: cat - /sys/class/net/{{ controller_device }}/bonding/'{{ item.key }}' - register: result - until: "'{{ item.value }}' in result.stdout" - loop: - - {key: 'mode', value: '802.3ad'} - - {key: 'ad_actor_sys_prio', value: '65535'} - - {key: 'ad_actor_system', value: '00:00:5e:00:53:5d'} - - {key: 'ad_select', value: 'stable'} - - {key: 'ad_user_port_key', value: '1023'} - # wokeignore:rule=slave - - {key: 'all_slaves_active', value: '1'} - - {key: 'downdelay', value: '0'} - - {key: 'lacp_rate', value: 'slow'} - - {key: 'lp_interval', value: '128'} - - {key: 'miimon', value: '110'} - - {key: 'num_grat_arp', value: '64'} - - {key: 'resend_igmp', value: '225'} - - {key: 'updelay', value: '0'} - - {key: 'use_carrier', value: '1'} - - {key: 'xmit_hash_policy', value: 'encap2+3'} - changed_when: false + - name: "Reset bond options to assert" + set_fact: + bond_options_to_assert: + - {key: 'mode', value: 'active-backup'} + - {key: 'arp_interval', value: '60'} + - {key: 'arp_ip_target', value: '192.0.2.128'} + - {key: 'arp_validate', value: 'none'} + - {key: 'primary', value: '{{ dhcp_interface1 }}'} - - name: "** TEST check IPv4" - command: ip -4 a s {{ controller_device }} - register: result - until: "'192.0.2' in result.stdout" - retries: 20 - delay: 2 - changed_when: false - - name: "** TEST check IPv6" - command: ip -6 a s {{ controller_device }} - register: result - until: "'2001' in result.stdout" - retries: 20 - delay: 2 - changed_when: false - - - name: Reconfigure the bond options - import_role: - name: linux-system-roles.network + - name: Reconfigure the bond options + tags: + - tests::states:reconfigure + block: + - name: Include the task 'run_test.yml' + include_tasks: tasks/run_test.yml vars: - network_connections: - # Create a bond controller - - name: "{{ controller_profile }}" - state: up - type: bond - interface_name: "{{ controller_device }}" - bond: - mode: active-backup - arp_interval: 60 - arp_ip_target: 192.0.2.128 - arp_validate: none - primary: "{{ dhcp_interface1 }}" - ip: - route_metric4: 65535 - # add an ethernet to the bond - - name: "{{ port1_profile }}" - state: up - type: ethernet - interface_name: "{{ dhcp_interface1 }}" - controller: "{{ controller_profile }}" - # add a second ethernet to the bond - - name: "{{ port2_profile }}" - state: up - type: ethernet - interface_name: "{{ dhcp_interface2 }}" - controller: "{{ controller_profile }}" - - name: "** TEST check bond settings" - command: cat - /sys/class/net/{{ controller_device }}/bonding/'{{ item.key }}' - register: result - until: "'{{ item.value }}' in result.stdout" - loop: - - {key: 'mode', value: 'active-backup'} - - {key: 'arp_interval', value: '60'} - - {key: 'arp_ip_target', value: '192.0.2.128'} - - {key: 'arp_validate', value: 'none'} - - {key: 'primary', value: '{{ dhcp_interface1 }}'} - changed_when: false - - - name: "** TEST check IPv4" - command: ip -4 a s {{ controller_device }} - register: result - until: "'192.0.2' in result.stdout" - retries: 20 - delay: 2 - changed_when: false - - name: "** TEST check IPv6" - command: ip -6 a s {{ controller_device }} - register: result - until: "'2001' in result.stdout" - retries: 20 - delay: 2 - changed_when: false - - always: - - name: Clean up the test devices and the connection profiles - tags: - - "tests::cleanup" - block: - - name: Import network role - import_role: - name: linux-system-roles.network - vars: - network_connections: - - name: "{{ port2_profile }}" - persistent_state: absent - state: down - - name: "{{ port1_profile }}" - persistent_state: absent - state: down - - name: "{{ controller_profile }}" - persistent_state: absent - state: down - failed_when: false - - name: Delete the device '{{ controller_device }}' - command: ip link del {{ controller_device }} - failed_when: false - changed_when: false - - name: Import the task 'remove_test_interfaces_with_dhcp.yml' - import_tasks: tasks/remove_test_interfaces_with_dhcp.yml + lsr_description: Given two DHCP-enabled network interfaces, + when creating a bond profile with them, + then the controller device and bond port profiles are present and + the specified bond options are set for the controller device. + lsr_setup: + - tasks/create_test_interfaces_with_dhcp.yml + - tasks/assert_dhcp_device_present.yml + lsr_test: + - tasks/create_bond_profile_reconfigure.yml + lsr_assert: + - tasks/assert_bond_options.yml + lsr_cleanup: + - tasks/cleanup_bond_profile+device.yml + - tasks/remove_test_interfaces_with_dhcp.yml + - tasks/check_network_dns.yml diff --git a/tests/playbooks/tests_bond_removal.yml b/tests/playbooks/tests_bond_removal.yml index b4c2c9d2..96fd4aaf 100644 --- a/tests/playbooks/tests_bond_removal.yml +++ b/tests/playbooks/tests_bond_removal.yml @@ -257,3 +257,5 @@ when: - network_provider == "initscripts" changed_when: false + - name: Verify network state restored to default + include_tasks: tasks/check_network_dns.yml diff --git a/tests/playbooks/tests_bridge.yml b/tests/playbooks/tests_bridge.yml index 643b4bfb..880a0749 100644 --- a/tests/playbooks/tests_bridge.yml +++ b/tests/playbooks/tests_bridge.yml @@ -60,3 +60,9 @@ import_playbook: run_tasks.yml vars: task: tasks/assert_device_absent.yml + +- name: Verify that cleanup restored state to default + hosts: all + tasks: + - name: Verify network state restored to default + include_tasks: tasks/check_network_dns.yml diff --git a/tests/playbooks/tests_bridge_cloned_mac.yml b/tests/playbooks/tests_bridge_cloned_mac.yml index 58431672..b30a9aec 100644 --- a/tests/playbooks/tests_bridge_cloned_mac.yml +++ b/tests/playbooks/tests_bridge_cloned_mac.yml @@ -60,3 +60,9 @@ import_playbook: remove_profile.yml vars: profile: "{{ interface }}" + +- name: Verify that cleanup restored state to default + hosts: all + tasks: + - name: Verify network state restored to default + include_tasks: tasks/check_network_dns.yml diff --git a/tests/playbooks/tests_checkpoint_cleanup.yml b/tests/playbooks/tests_checkpoint_cleanup.yml index 6c93b08d..48f59365 100644 --- a/tests/playbooks/tests_checkpoint_cleanup.yml +++ b/tests/playbooks/tests_checkpoint_cleanup.yml @@ -101,3 +101,5 @@ - name: Delete the device '{{ interface }}' command: ip link del "{{ interface }}" changed_when: false + - name: Verify network state restored to default + include_tasks: tasks/check_network_dns.yml diff --git a/tests/playbooks/tests_dummy.yml b/tests/playbooks/tests_dummy.yml index 9b3b63bd..518795d3 100644 --- a/tests/playbooks/tests_dummy.yml +++ b/tests/playbooks/tests_dummy.yml @@ -32,3 +32,4 @@ - tasks/assert_device_present.yml lsr_cleanup: - tasks/cleanup_profile+device.yml + - tasks/check_network_dns.yml diff --git a/tests/playbooks/tests_eth_dns_support.yml b/tests/playbooks/tests_eth_dns_support.yml index a528efaf..044346f7 100644 --- a/tests/playbooks/tests_eth_dns_support.yml +++ b/tests/playbooks/tests_eth_dns_support.yml @@ -138,4 +138,6 @@ profile: "{{ interface }}" - name: Include the task 'assert_device_absent.yml' include_tasks: tasks/assert_device_absent.yml + - name: Verify network state restored to default + include_tasks: tasks/check_network_dns.yml ... diff --git a/tests/playbooks/tests_eth_pci_address_match.yml b/tests/playbooks/tests_eth_pci_address_match.yml index 0a9bded5..e58f9759 100644 --- a/tests/playbooks/tests_eth_pci_address_match.yml +++ b/tests/playbooks/tests_eth_pci_address_match.yml @@ -79,3 +79,5 @@ persistent_state: absent state: down failed_when: false + - name: Verify network state restored to default + include_tasks: tasks/check_network_dns.yml diff --git a/tests/playbooks/tests_ethernet.yml b/tests/playbooks/tests_ethernet.yml index 3cf096cf..2fdc5477 100644 --- a/tests/playbooks/tests_ethernet.yml +++ b/tests/playbooks/tests_ethernet.yml @@ -74,3 +74,8 @@ profile: "{{ interface }}" - name: Include the task 'assert_device_absent.yml' include_tasks: tasks/assert_device_absent.yml +- name: Verify that cleanup restored state to default + hosts: all + tasks: + - name: Verify network state restored to default + include_tasks: tasks/check_network_dns.yml diff --git a/tests/playbooks/tests_ethtool_coalesce.yml b/tests/playbooks/tests_ethtool_coalesce.yml index b97063f8..d2889911 100644 --- a/tests/playbooks/tests_ethtool_coalesce.yml +++ b/tests/playbooks/tests_ethtool_coalesce.yml @@ -174,3 +174,5 @@ include_tasks: tasks/manage_test_interface.yml vars: state: absent + - name: Verify network state restored to default + include_tasks: tasks/check_network_dns.yml diff --git a/tests/playbooks/tests_ethtool_features.yml b/tests/playbooks/tests_ethtool_features.yml index 897476f8..c87d861f 100644 --- a/tests/playbooks/tests_ethtool_features.yml +++ b/tests/playbooks/tests_ethtool_features.yml @@ -224,3 +224,5 @@ include_tasks: tasks/manage_test_interface.yml vars: state: absent + - name: Verify network state restored to default + include_tasks: tasks/check_network_dns.yml diff --git a/tests/playbooks/tests_ethtool_ring.yml b/tests/playbooks/tests_ethtool_ring.yml index e1c99eea..fdcc263d 100644 --- a/tests/playbooks/tests_ethtool_ring.yml +++ b/tests/playbooks/tests_ethtool_ring.yml @@ -215,3 +215,5 @@ include_tasks: tasks/manage_test_interface.yml vars: state: absent + - name: Verify network state restored to default + include_tasks: tasks/check_network_dns.yml diff --git a/tests/playbooks/tests_ignore_auto_dns.yml b/tests/playbooks/tests_ignore_auto_dns.yml index 90071629..f191ce8b 100644 --- a/tests/playbooks/tests_ignore_auto_dns.yml +++ b/tests/playbooks/tests_ignore_auto_dns.yml @@ -79,4 +79,6 @@ include_tasks: tasks/assert_profile_absent.yml vars: profile: "{{ interface }}" + - name: Verify network state restored to default + include_tasks: tasks/check_network_dns.yml ... diff --git a/tests/playbooks/tests_infiniband.yml b/tests/playbooks/tests_infiniband.yml index 00fbee73..65a85c93 100644 --- a/tests/playbooks/tests_infiniband.yml +++ b/tests/playbooks/tests_infiniband.yml @@ -89,3 +89,5 @@ command: ip link del {{ interface }}.000a failed_when: false changed_when: false + - name: Verify network state restored to default + include_tasks: tasks/check_network_dns.yml diff --git a/tests/playbooks/tests_ipv6.yml b/tests/playbooks/tests_ipv6.yml index 7488a29b..8d49775f 100644 --- a/tests/playbooks/tests_ipv6.yml +++ b/tests/playbooks/tests_ipv6.yml @@ -112,3 +112,5 @@ when: - ansible_distribution_major_version != '6' changed_when: false + - name: Verify network state restored to default + include_tasks: tasks/check_network_dns.yml diff --git a/tests/playbooks/tests_ipv6_disabled.yml b/tests/playbooks/tests_ipv6_disabled.yml index 0a9c8744..2cbe43e5 100644 --- a/tests/playbooks/tests_ipv6_disabled.yml +++ b/tests/playbooks/tests_ipv6_disabled.yml @@ -93,4 +93,6 @@ profile: "{{ interface }}" - name: Include the task 'assert_device_absent.yml' include_tasks: tasks/assert_device_absent.yml + - name: Verify network state restored to default + include_tasks: tasks/check_network_dns.yml ... diff --git a/tests/playbooks/tests_ipv6_dns_search.yml b/tests/playbooks/tests_ipv6_dns_search.yml index cabd9c69..b5828a18 100644 --- a/tests/playbooks/tests_ipv6_dns_search.yml +++ b/tests/playbooks/tests_ipv6_dns_search.yml @@ -161,3 +161,5 @@ persistent_state: absent state: down failed_when: false + - name: Verify network state restored to default + include_tasks: tasks/check_network_dns.yml diff --git a/tests/playbooks/tests_network_state.yml b/tests/playbooks/tests_network_state.yml index 4625b081..054933cf 100644 --- a/tests/playbooks/tests_network_state.yml +++ b/tests/playbooks/tests_network_state.yml @@ -173,6 +173,14 @@ msg: the file `/run/NetworkManager/no-stub-resolv.conf` does not contain the specified DNS configuration + - name: Purge the DNS + import_role: + name: linux-system-roles.network + vars: + network_state: + dns-resolver: + config: {} + - name: Include the task 'delete_interface.yml' include_tasks: tasks/delete_interface.yml - name: Include the task 'assert_device_absent.yml' @@ -185,4 +193,6 @@ include_tasks: tasks/delete_interface.yml - name: Include the task 'assert_device_absent.yml' include_tasks: tasks/assert_device_absent.yml + - name: Verify network state restored to default + include_tasks: tasks/check_network_dns.yml ... diff --git a/tests/playbooks/tests_provider.yml b/tests/playbooks/tests_provider.yml index 1875aa66..e373acdc 100644 --- a/tests/playbooks/tests_provider.yml +++ b/tests/playbooks/tests_provider.yml @@ -38,3 +38,4 @@ - tasks/assert_profile_present.yml lsr_cleanup: - tasks/cleanup_profile+device.yml + - tasks/check_network_dns.yml diff --git a/tests/playbooks/tests_reapply.yml b/tests/playbooks/tests_reapply.yml index 453391ea..16be84f7 100644 --- a/tests/playbooks/tests_reapply.yml +++ b/tests/playbooks/tests_reapply.yml @@ -79,3 +79,5 @@ - name: Delete the device '{{ interface }}' command: ip link del "{{ interface }}" changed_when: false + - name: Verify network state restored to default + include_tasks: tasks/check_network_dns.yml diff --git a/tests/playbooks/tests_route_device.yml b/tests/playbooks/tests_route_device.yml index 53fabb3f..3feba4e0 100644 --- a/tests/playbooks/tests_route_device.yml +++ b/tests/playbooks/tests_route_device.yml @@ -185,4 +185,6 @@ loop: - "{{ interface0 }}" - "{{ interface1 }}" + - name: Verify network state restored to default + include_tasks: tasks/check_network_dns.yml ... diff --git a/tests/playbooks/tests_route_table.yml b/tests/playbooks/tests_route_table.yml index ab6f10fb..e128bd9b 100644 --- a/tests/playbooks/tests_route_table.yml +++ b/tests/playbooks/tests_route_table.yml @@ -152,4 +152,6 @@ profile: "{{ interface }}" - name: Include the task 'assert_device_absent.yml' include_tasks: tasks/assert_device_absent.yml + - name: Verify network state restored to default + include_tasks: tasks/check_network_dns.yml ... diff --git a/tests/playbooks/tests_route_type.yml b/tests/playbooks/tests_route_type.yml index d1a25f7f..4394109c 100644 --- a/tests/playbooks/tests_route_type.yml +++ b/tests/playbooks/tests_route_type.yml @@ -191,4 +191,6 @@ profile: "{{ interface }}" - name: Include the task 'assert_device_absent.yml' include_tasks: tasks/assert_device_absent.yml + - name: Verify network state restored to default + include_tasks: tasks/check_network_dns.yml ... diff --git a/tests/playbooks/tests_routing_rules.yml b/tests/playbooks/tests_routing_rules.yml index 9c7c4dc4..e7508f7b 100644 --- a/tests/playbooks/tests_routing_rules.yml +++ b/tests/playbooks/tests_routing_rules.yml @@ -273,4 +273,6 @@ profile: "{{ interface }}" - name: Include the task 'assert_device_absent.yml' include_tasks: tasks/assert_device_absent.yml + - name: Verify network state restored to default + include_tasks: tasks/check_network_dns.yml ... diff --git a/tests/playbooks/tests_states.yml b/tests/playbooks/tests_states.yml index 8cf9def7..451c5df9 100644 --- a/tests/playbooks/tests_states.yml +++ b/tests/playbooks/tests_states.yml @@ -145,3 +145,4 @@ condition: "{{ network_provider == 'nm' }}" lsr_cleanup: - tasks/cleanup_profile+device.yml + - tasks/check_network_dns.yml diff --git a/tests/playbooks/tests_switch_provider.yml b/tests/playbooks/tests_switch_provider.yml index 42faca9a..006b9454 100644 --- a/tests/playbooks/tests_switch_provider.yml +++ b/tests/playbooks/tests_switch_provider.yml @@ -61,3 +61,5 @@ include_tasks: tasks/delete_interface.yml - name: Include the task 'assert_device_absent.yml' include_tasks: tasks/assert_device_absent.yml + - name: Verify network state restored to default + include_tasks: tasks/check_network_dns.yml diff --git a/tests/playbooks/tests_team.yml b/tests/playbooks/tests_team.yml index ba8db329..b1cca661 100644 --- a/tests/playbooks/tests_team.yml +++ b/tests/playbooks/tests_team.yml @@ -32,3 +32,4 @@ - tasks/assert_device_present.yml lsr_cleanup: - tasks/cleanup_profile+device.yml + - tasks/check_network_dns.yml diff --git a/tests/playbooks/tests_team_plugin_installation.yml b/tests/playbooks/tests_team_plugin_installation.yml index ebab201a..f7c53f8a 100644 --- a/tests/playbooks/tests_team_plugin_installation.yml +++ b/tests/playbooks/tests_team_plugin_installation.yml @@ -42,4 +42,7 @@ that: - "'NetworkManager-team' in ansible_facts.packages" msg: "NetworkManager-team is not installed after team configuration" + + - name: Verify network state restored to default + include_tasks: tasks/check_network_dns.yml ... diff --git a/tests/playbooks/tests_vlan_mtu.yml b/tests/playbooks/tests_vlan_mtu.yml index b7d7bb79..1e9824a4 100644 --- a/tests/playbooks/tests_vlan_mtu.yml +++ b/tests/playbooks/tests_vlan_mtu.yml @@ -74,3 +74,5 @@ include_tasks: tasks/manage_test_interface.yml vars: state: absent + - name: Verify network state restored to default + include_tasks: tasks/check_network_dns.yml diff --git a/tests/playbooks/tests_wireless.yml b/tests/playbooks/tests_wireless.yml index f5f444dc..fbcccc3b 100644 --- a/tests/playbooks/tests_wireless.yml +++ b/tests/playbooks/tests_wireless.yml @@ -95,3 +95,5 @@ failed_when: false - name: Include the task 'cleanup_mock_wifi.yml' include_tasks: tasks/cleanup_mock_wifi.yml + - name: Verify network state restored to default + include_tasks: tasks/check_network_dns.yml diff --git a/tests/playbooks/tests_wireless_plugin_installation.yml b/tests/playbooks/tests_wireless_plugin_installation.yml index 16ebe5bc..b59a775a 100644 --- a/tests/playbooks/tests_wireless_plugin_installation.yml +++ b/tests/playbooks/tests_wireless_plugin_installation.yml @@ -43,3 +43,6 @@ that: - "'NetworkManager-wifi' in ansible_facts.packages" msg: "NetworkManager-wifi is not installed after wireless configured" + + - name: Verify network state restored to default + include_tasks: tasks/check_network_dns.yml diff --git a/tests/playbooks/tests_wireless_wpa3_owe.yml b/tests/playbooks/tests_wireless_wpa3_owe.yml index 41344a12..51400e42 100644 --- a/tests/playbooks/tests_wireless_wpa3_owe.yml +++ b/tests/playbooks/tests_wireless_wpa3_owe.yml @@ -60,3 +60,5 @@ failed_when: false - name: Include the task 'cleanup_mock_wifi.yml' include_tasks: tasks/cleanup_mock_wifi.yml + - name: Verify network state restored to default + include_tasks: tasks/check_network_dns.yml diff --git a/tests/playbooks/tests_wireless_wpa3_sae.yml b/tests/playbooks/tests_wireless_wpa3_sae.yml index d2b5549c..7aad3027 100644 --- a/tests/playbooks/tests_wireless_wpa3_sae.yml +++ b/tests/playbooks/tests_wireless_wpa3_sae.yml @@ -61,3 +61,5 @@ failed_when: false - name: Include the task 'cleanup_mock_wifi.yml' include_tasks: tasks/cleanup_mock_wifi.yml + - name: Verify network state restored to default + include_tasks: tasks/check_network_dns.yml diff --git a/tests/tasks/assert_IPv4_present.yml b/tests/tasks/assert_IPv4_present.yml new file mode 100644 index 00000000..125e3d42 --- /dev/null +++ b/tests/tasks/assert_IPv4_present.yml @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: BSD-3-Clause +--- +- name: "** TEST check IPv4" + command: ip -4 a s {{ interface }} + register: result + until: "'{{ address }}' in result.stdout" + retries: 20 + delay: 2 + changed_when: false diff --git a/tests/tasks/assert_IPv6_present.yml b/tests/tasks/assert_IPv6_present.yml new file mode 100644 index 00000000..51aa1aca --- /dev/null +++ b/tests/tasks/assert_IPv6_present.yml @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: BSD-3-Clause +--- +- name: "** TEST check IPv6" + command: ip -6 a s {{ controller_device }} + register: result + until: "'{{ address }}' in result.stdout" + retries: 20 + delay: 2 + changed_when: false diff --git a/tests/tasks/assert_bond_options.yml b/tests/tasks/assert_bond_options.yml new file mode 100644 index 00000000..4a6e5ffd --- /dev/null +++ b/tests/tasks/assert_bond_options.yml @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: BSD-3-Clause +--- +- name: "** TEST check bond settings" + command: cat + /sys/class/net/{{ controller_device }}/bonding/'{{ item.key }}' + register: result + until: "'{{ item.value }}' in result.stdout" + loop: "{{ bond_options_to_assert }}" + changed_when: false +- name: Include the task 'assert_IPv4_present.yml' + include_tasks: assert_IPv4_present.yml + vars: + interface: "{{ controller_device }}" + address: '192.0.2' +- name: Include the task 'assert_IPv6_present.yml' + include_tasks: assert_IPv6_present.yml + vars: + interface: "{{ controller_device }}" + address: '2001' diff --git a/tests/tasks/assert_bond_port_profile_present.yml b/tests/tasks/assert_bond_port_profile_present.yml new file mode 100644 index 00000000..e0544c6d --- /dev/null +++ b/tests/tasks/assert_bond_port_profile_present.yml @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +--- +- name: Include the task 'assert_profile_present.yml' + include_tasks: tasks/assert_profile_present.yml + vars: + profile: "{{ item }}" + loop: + - "{{ controller_profile }}" + - "{{ port1_profile }}" + - "{{ port2_profile }}" diff --git a/tests/tasks/assert_controller_device_present.yml b/tests/tasks/assert_controller_device_present.yml new file mode 100644 index 00000000..7d387cd5 --- /dev/null +++ b/tests/tasks/assert_controller_device_present.yml @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: BSD-3-Clause +--- +- name: Import the task 'assert_device_present.yml' + import_tasks: tasks/assert_device_present.yml + vars: + interface: "{{ controller_device }}" diff --git a/tests/tasks/assert_dhcp_device_present.yml b/tests/tasks/assert_dhcp_device_present.yml new file mode 100644 index 00000000..84fb5de6 --- /dev/null +++ b/tests/tasks/assert_dhcp_device_present.yml @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause +--- +- name: Import the task 'assert_device_present.yml' + import_tasks: tasks/assert_device_present.yml + vars: + interface: "{{ dhcp_interface1 }}" +- name: Import the task 'assert_device_present.yml' + import_tasks: tasks/assert_device_present.yml + vars: + interface: "{{ dhcp_interface2 }}" diff --git a/tests/tasks/check_network_dns.yml b/tests/tasks/check_network_dns.yml new file mode 100644 index 00000000..0bb3b242 --- /dev/null +++ b/tests/tasks/check_network_dns.yml @@ -0,0 +1,39 @@ +# SPDX-License-Identifier: BSD-3-Clause +--- +# This is typically used after cleanup, to verify that cleanup +# worked and left networking in the default state - sort of like +# a post-condition, or pre-condition for subsequent tests +- name: Check routes and DNS + shell: | + set -euo pipefail + echo IP + ip a + echo IP ROUTE + ip route + echo IP -6 ROUTE + ip -6 route + echo RESOLV + if [ -f /etc/resolv.conf ]; then + cat /etc/resolv.conf + else + echo NO /etc/resolv.conf + ls -alrtF /etc/resolv.* || : + fi + changed_when: false + +- name: Verify DNS and network connectivity + shell: | + set -euo pipefail + echo CHECK DNS AND CONNECTIVITY + for host in mirrors.fedoraproject.org mirrors.centos.org; do + if ! getent hosts "$host"; then + echo FAILED to lookup host "$host" + exit 1 + fi + if ! curl -o /dev/null https://"$host"; then + echo FAILED to contact host "$host" + exit 1 + fi + done + when: ansible_facts["distribution"] == "CentOS" + changed_when: false diff --git a/tests/tasks/cleanup_bond_profile+device.yml b/tests/tasks/cleanup_bond_profile+device.yml new file mode 100644 index 00000000..a6b666c5 --- /dev/null +++ b/tests/tasks/cleanup_bond_profile+device.yml @@ -0,0 +1,26 @@ +# SPDX-License-Identifier: BSD-3-Clause +--- +- name: Clean up the test devices and the connection profiles + tags: + - "tests::cleanup" + block: + - name: Import network role + import_role: + name: linux-system-roles.network + vars: + network_connections: + - name: "{{ port2_profile }}" + persistent_state: absent + state: down + - name: "{{ port1_profile }}" + persistent_state: absent + state: down + - name: "{{ controller_profile }}" + persistent_state: absent + state: down + failed_when: false + - name: Delete the device '{{ controller_device }}' + command: ip link del {{ controller_device }} + failed_when: false + changed_when: false +... diff --git a/tests/tasks/create_bond_profile.yml b/tests/tasks/create_bond_profile.yml new file mode 100644 index 00000000..3624ec0c --- /dev/null +++ b/tests/tasks/create_bond_profile.yml @@ -0,0 +1,49 @@ +# SPDX-License-Identifier: BSD-3-Clause +--- +- name: Include network role + include_role: + name: linux-system-roles.network + vars: + network_connections: + # Create a bond controller + - name: "{{ controller_profile }}" + state: up + type: bond + interface_name: "{{ controller_device }}" + bond: + mode: 802.3ad + ad_actor_sys_prio: 65535 + ad_actor_system: 00:00:5e:00:53:5d + ad_select: stable + ad_user_port_key: 1023 + all_ports_active: true + downdelay: 0 + lacp_rate: slow + lp_interval: 128 + miimon: 110 + min_links: 0 + num_grat_arp: 64 + primary_reselect: better + resend_igmp: 225 + updelay: 0 + use_carrier: true + xmit_hash_policy: encap2+3 + ip: + route_metric4: 65535 + + # add an ethernet to the bond + - name: "{{ port1_profile }}" + state: up + type: ethernet + interface_name: "{{ dhcp_interface1 }}" + controller: "{{ controller_profile }}" + # add a second ethernet to the bond + - name: "{{ port2_profile }}" + state: up + type: ethernet + interface_name: "{{ dhcp_interface2 }}" + controller: "{{ controller_profile }}" +- name: Show result + debug: + var: __network_connections_result +... diff --git a/tests/tasks/create_bond_profile_reconfigure.yml b/tests/tasks/create_bond_profile_reconfigure.yml new file mode 100644 index 00000000..323c2d0c --- /dev/null +++ b/tests/tasks/create_bond_profile_reconfigure.yml @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: BSD-3-Clause +--- +- name: Reconfigure the bond options + import_role: + name: linux-system-roles.network + vars: + network_connections: + # Create a bond controller + - name: "{{ controller_profile }}" + state: up + type: bond + interface_name: "{{ controller_device }}" + bond: + mode: active-backup + arp_interval: 60 + arp_ip_target: 192.0.2.128 + arp_validate: none + primary: "{{ dhcp_interface1 }}" + ip: + route_metric4: 65535 + # add an ethernet to the bond + - name: "{{ port1_profile }}" + state: up + type: ethernet + interface_name: "{{ dhcp_interface1 }}" + controller: "{{ controller_profile }}" + # add a second ethernet to the bond + - name: "{{ port2_profile }}" + state: up + type: ethernet + interface_name: "{{ dhcp_interface2 }}" + controller: "{{ controller_profile }}" +- name: Show result + debug: + var: __network_connections_result +... diff --git a/tests/tasks/create_test_interfaces_with_dhcp.yml b/tests/tasks/create_test_interfaces_with_dhcp.yml index 98f50612..1c42c34e 100644 --- a/tests/tasks/create_test_interfaces_with_dhcp.yml +++ b/tests/tasks/create_test_interfaces_with_dhcp.yml @@ -6,6 +6,14 @@ state: present use: "{{ (__network_is_ostree | d(false)) | ternary('ansible.posix.rhel_rpm_ostree', omit) }}" + register: __install_status + # sometimes the rpm download returns a 403 - I think it is when too + # many parallel jobs attempt the download from the same controller in + # too short a period of time, so the epel server throttles additional + # downloads - use a retry here to mitigate + until: __install_status is success + retries: 6 + delay: 10 - name: Install pgrep, sysctl package: diff --git a/tests/tasks/manage_test_interface.yml b/tests/tasks/manage_test_interface.yml index e4352e8f..c05ef824 100644 --- a/tests/tasks/manage_test_interface.yml +++ b/tests/tasks/manage_test_interface.yml @@ -19,6 +19,10 @@ state: present use: "{{ (__network_is_ostree | d(false)) | ternary('ansible.posix.rhel_rpm_ostree', omit) }}" + register: __install_status + until: __install_status is success + retries: 6 + delay: 10 # veth - name: Create veth interface {{ interface }} diff --git a/tests/tasks/setup_802_1x_server.yml b/tests/tasks/setup_802_1x_server.yml index a9949658..0041a5a5 100644 --- a/tests/tasks/setup_802_1x_server.yml +++ b/tests/tasks/setup_802_1x_server.yml @@ -19,6 +19,10 @@ state: present use: "{{ (__network_is_ostree | d(false)) | ternary('ansible.posix.rhel_rpm_ostree', omit) }}" + register: __install_status + until: __install_status is success + retries: 6 + delay: 10 - name: Create directory for test certificates file: diff --git a/tests/tasks/setup_mock_wifi.yml b/tests/tasks/setup_mock_wifi.yml index e8d7abc4..94a19f79 100644 --- a/tests/tasks/setup_mock_wifi.yml +++ b/tests/tasks/setup_mock_wifi.yml @@ -9,6 +9,10 @@ state: present use: "{{ (__network_is_ostree | d(false)) | ternary('ansible.posix.rhel_rpm_ostree', omit) }}" + register: __install_status + until: __install_status is success + retries: 6 + delay: 10 - name: Ensure NetworkManager is running service: diff --git a/tests/tasks/setup_mock_wifi_wpa3_owe.yml b/tests/tasks/setup_mock_wifi_wpa3_owe.yml index cba987f5..5d8048de 100644 --- a/tests/tasks/setup_mock_wifi_wpa3_owe.yml +++ b/tests/tasks/setup_mock_wifi_wpa3_owe.yml @@ -8,6 +8,10 @@ state: present use: "{{ (__network_is_ostree | d(false)) | ternary('ansible.posix.rhel_rpm_ostree', omit) }}" + register: __install_status + until: __install_status is success + retries: 6 + delay: 10 - name: Check if can test on CentOS and setup if possible when: ansible_distribution == 'CentOS' diff --git a/tests/tasks/setup_mock_wifi_wpa3_sae.yml b/tests/tasks/setup_mock_wifi_wpa3_sae.yml index 00418cd6..94078e69 100644 --- a/tests/tasks/setup_mock_wifi_wpa3_sae.yml +++ b/tests/tasks/setup_mock_wifi_wpa3_sae.yml @@ -8,6 +8,10 @@ state: present use: "{{ (__network_is_ostree | d(false)) | ternary('ansible.posix.rhel_rpm_ostree', omit) }}" + register: __install_status + until: __install_status is success + retries: 6 + delay: 10 - name: Configure CentOS system for testing, if possible when: ansible_distribution == 'CentOS' @@ -42,6 +46,10 @@ state: present when: - ansible_distribution == 'Fedora' + register: __install_status + until: __install_status is success + retries: 6 + delay: 10 # Since DNF package manager can not warrant installing the kernel module with # the same version as the kernel in target machine, install the kernel module diff --git a/tests/tests_unit.yml b/tests/tests_unit.yml index 44a4df30..af3ccab9 100644 --- a/tests/tests_unit.yml +++ b/tests/tests_unit.yml @@ -176,6 +176,9 @@ state: absent path: "{{ _rundir.path }}" + - name: Verify network state restored to default + include_tasks: tasks/check_network_dns.yml + - name: Ensure that at least one python unit test ran fail: msg: Tests did not run with python2 or python3