Blame SOURCES/network-tier1-tags.diff

583029
diff --git a/tests/playbooks/tests_802_1x.yml b/tests/playbooks/tests_802_1x.yml
583029
index 9cce1ae..76d99e9 100644
583029
--- a/tests/playbooks/tests_802_1x.yml
583029
+++ b/tests/playbooks/tests_802_1x.yml
583029
@@ -1,5 +1,10 @@
cc4018
 # SPDX-License-Identifier: BSD-3-Clause
cc4018
 ---
583029
+- name: Save host state
583029
+  hosts: all
583029
+  tasks:
583029
+    - import_tasks: tasks/save_state.yml
583029
+
cc4018
 - hosts: all
583029
   vars:
583029
     interface: 802-1x-test
583029
@@ -122,3 +127,8 @@
583029
               command: update-ca-trust
583029
           tags:
583029
             - "tests::cleanup"
583029
+
583029
+- name: Restore host state
583029
+  hosts: all
583029
+  tasks:
583029
+    - import_tasks: tasks/restore_state.yml
e662d2
diff --git a/tests/playbooks/tests_bond.yml b/tests/playbooks/tests_bond.yml
e662d2
index 69f07f8..1e45788 100644
e662d2
--- a/tests/playbooks/tests_bond.yml
e662d2
+++ b/tests/playbooks/tests_bond.yml
e662d2
@@ -1,5 +1,10 @@
e662d2
 # SPDX-License-Identifier: BSD-3-Clause
e662d2
 ---
e662d2
+- name: Save host state
e662d2
+  hosts: all
e662d2
+  tasks:
e662d2
+    - import_tasks: tasks/save_state.yml
e662d2
+
e662d2
 - hosts: all
e662d2
   vars:
e662d2
     controller_profile: bond0
e662d2
@@ -95,3 +100,8 @@
e662d2
             - import_tasks: tasks/remove_test_interfaces_with_dhcp.yml
e662d2
           tags:
e662d2
             - "tests::cleanup"
e662d2
+
e662d2
+- name: Restore host state
e662d2
+  hosts: all
e662d2
+  tasks:
e662d2
+    - import_tasks: tasks/restore_state.yml
583029
diff --git a/tests/playbooks/tests_bridge.yml b/tests/playbooks/tests_bridge.yml
583029
index d79d6ad..c8cf3cd 100644
583029
--- a/tests/playbooks/tests_bridge.yml
583029
+++ b/tests/playbooks/tests_bridge.yml
583029
@@ -1,5 +1,10 @@
583029
 # SPDX-License-Identifier: BSD-3-Clause
583029
 ---
583029
+- name: Save host state
583029
+  hosts: all
583029
+  tasks:
583029
+    - import_tasks: tasks/save_state.yml
583029
+
583029
 - name: Test configuring bridges
583029
   hosts: all
583029
   vars:
583029
@@ -14,6 +19,8 @@
583029
 
583029
 - name: Add test bridge
583029
   hosts: all
cc4018
+  tags:
583029
+    - 'tests::net::bridge'
583029
   vars:
583029
     network_connections:
583029
       - name: "{{ interface }}"
583029
@@ -36,11 +43,15 @@
583029
     task: tasks/assert_profile_present.yml
583029
 
583029
 - import_playbook: down_profile.yml
583029
+  tags:
583029
+    - 'tests::net::bridge'
cc4018
   vars:
cc4018
     profile: "{{ interface }}"
583029
 # FIXME: assert profile/device down
cc4018
 
583029
 - import_playbook: remove_profile.yml
583029
+  tags:
583029
+    - 'tests::net::bridge'
583029
   vars:
583029
     profile: "{{ interface }}"
583029
 
583029
@@ -51,5 +62,19 @@
583029
 
583029
 # FIXME: Devices might still be left when profile is absent
583029
 # - import_playbook: run_tasks.yml
583029
-#   vars:
583029
+#  vars:
583029
 #     task: tasks/assert_device_absent.yml
583029
+
583029
+- name: Remove test bridge
583029
+  hosts: all
583029
+  tags:
583029
+    - 'tests::cleanup'
583029
+    - 'tests::net::bridge::cleanup'
583029
+  tasks:
583029
+    - command: 'ip link delete "{{ interface }}"'
583029
+      ignore_errors: yes
583029
+
583029
+- name: Restore host state
583029
+  hosts: all
583029
+  tasks:
583029
+    - import_tasks: tasks/restore_state.yml
583029
diff --git a/tests/playbooks/tests_checkpoint_cleanup.yml b/tests/playbooks/tests_checkpoint_cleanup.yml
583029
index 18e3fd7..3b5a41a 100644
583029
--- a/tests/playbooks/tests_checkpoint_cleanup.yml
583029
+++ b/tests/playbooks/tests_checkpoint_cleanup.yml
583029
@@ -4,6 +4,11 @@
583029
 # mark a device as unmanaged for NM and then tries to activiate it using NM.
583029
 # This failed without removing the checkpoint.
583029
 ---
583029
+- name: Save host state
583029
+  hosts: all
583029
+  tasks:
583029
+    - import_tasks: tasks/save_state.yml
583029
+
583029
 - hosts: all
583029
   vars:
583029
     interface: cptstbr
583029
@@ -80,3 +85,8 @@
583029
           ignore_errors: true
583029
           tags:
583029
             - "tests::cleanup"
583029
+
583029
+- name: Restore host state
583029
+  hosts: all
583029
+  tasks:
583029
+    - import_tasks: tasks/restore_state.yml
583029
diff --git a/tests/playbooks/tests_ethernet.yml b/tests/playbooks/tests_ethernet.yml
583029
index cd02579..adcffee 100644
583029
--- a/tests/playbooks/tests_ethernet.yml
583029
+++ b/tests/playbooks/tests_ethernet.yml
583029
@@ -1,5 +1,10 @@
583029
 # SPDX-License-Identifier: BSD-3-Clause
583029
 ---
583029
+- name: Save host state
583029
+  hosts: all
583029
+  tasks:
583029
+    - import_tasks: tasks/save_state.yml
583029
+
583029
 - hosts: all
583029
   tasks:
583029
     - debug:
583029
@@ -9,6 +14,8 @@
583029
 
583029
 - name: Test configuring ethernet devices
583029
   hosts: all
583029
+  tags:
583029
+    - 'tests::net::veth'
583029
   vars:
583029
     type: veth
583029
     interface: lsr27
583029
@@ -26,6 +33,8 @@
583029
 
583029
 - name: Test static interface up
583029
   hosts: all
583029
+  tags:
583029
+    - 'tests::net::reconf'
583029
   vars:
583029
     network_connections:
583029
       - name: "{{ interface }}"
583029
@@ -48,17 +57,29 @@
583029
 # FIXME: assert profile present
583029
 # FIXME: assert profile/device up + IP address
583029
 - import_playbook: down_profile.yml
583029
+  tags:
583029
+    - 'tests::cleanup'
583029
   vars:
583029
     profile: "{{ interface }}"
583029
 # FIXME: assert profile/device down
583029
 - import_playbook: remove_profile.yml
583029
+  tags:
583029
+    - 'tests::cleanup'
583029
   vars:
583029
     profile: "{{ interface }}"
583029
 # FIXME: assert profile away
583029
 - name: Remove interfaces
583029
   hosts: all
583029
+  tags:
583029
+    - 'tests::cleanup'
583029
+    - 'tests::net::veth::cleanup'
583029
   tasks:
583029
     - include_tasks: tasks/manage_test_interface.yml
583029
       vars:
583029
         state: absent
583029
     - include_tasks: tasks/assert_device_absent.yml
583029
+
583029
+- name: Restore host state
583029
+  hosts: all
583029
+  tasks:
583029
+    - import_tasks: tasks/restore_state.yml
583029
diff --git a/tests/playbooks/tests_ethtool_features.yml b/tests/playbooks/tests_ethtool_features.yml
e662d2
index 43fddc3..d1a87fe 100644
583029
--- a/tests/playbooks/tests_ethtool_features.yml
583029
+++ b/tests/playbooks/tests_ethtool_features.yml
583029
@@ -1,5 +1,10 @@
583029
 # SPDX-License-Identifier: BSD-3-Clause
583029
 ---
583029
+- name: Save host state
583029
+  hosts: all
583029
+  tasks:
583029
+    - import_tasks: tasks/save_state.yml
583029
+
583029
 - hosts: all
583029
   vars:
e662d2
     interface: testnic1
e662d2
@@ -198,3 +203,8 @@
583029
                 state: absent
583029
           tags:
583029
             - "tests::cleanup"
583029
+
583029
+- name: Restore host state
583029
+  hosts: all
583029
+  tasks:
583029
+    - import_tasks: tasks/restore_state.yml
e662d2
diff --git a/tests/playbooks/tests_provider.yml b/tests/playbooks/tests_provider.yml
e662d2
index 1db2d08..e097b4b 100644
e662d2
--- a/tests/playbooks/tests_provider.yml
e662d2
+++ b/tests/playbooks/tests_provider.yml
e662d2
@@ -1,5 +1,10 @@
e662d2
 # SPDX-License-Identifier: BSD-3-Clause
e662d2
 ---
e662d2
+- name: Save host state
e662d2
+  hosts: all
e662d2
+  tasks:
e662d2
+    - import_tasks: tasks/save_state.yml
e662d2
+
e662d2
 - hosts: all
e662d2
   vars:
e662d2
     interface: testnic1
e662d2
@@ -33,3 +38,8 @@
e662d2
               - tasks/cleanup_profile+device.yml
e662d2
       tags:
e662d2
         - tests::provider:initscripts_to_nm
e662d2
+
e662d2
+- name: Restore host state
e662d2
+  hosts: all
e662d2
+  tasks:
e662d2
+    - import_tasks: tasks/restore_state.yml
583029
diff --git a/tests/playbooks/tests_reapply.yml b/tests/playbooks/tests_reapply.yml
583029
index 4b1cb09..6995607 100644
583029
--- a/tests/playbooks/tests_reapply.yml
583029
+++ b/tests/playbooks/tests_reapply.yml
583029
@@ -4,6 +4,11 @@
583029
 # of via Ansible. Until there is better test support for this, just check the
583029
 # log output for the respective log message.
583029
 ---
583029
+- name: Save host state
583029
+  hosts: all
583029
+  tasks:
583029
+    - import_tasks: tasks/save_state.yml
583029
+
583029
 - hosts: all
583029
   vars:
583029
     interface: rpltstbr
583029
@@ -64,3 +69,8 @@
583029
           ignore_errors: true
583029
           tags:
583029
             - "tests::cleanup"
583029
+
583029
+- name: Restore host state
583029
+  hosts: all
583029
+  tasks:
583029
+    - import_tasks: tasks/restore_state.yml
583029
diff --git a/tests/playbooks/tests_states.yml b/tests/playbooks/tests_states.yml
e662d2
index eec27c0..a8d0ecd 100644
583029
--- a/tests/playbooks/tests_states.yml
583029
+++ b/tests/playbooks/tests_states.yml
e662d2
@@ -135,3 +135,23 @@
583029
               - tasks/cleanup_profile+device.yml
583029
       tags:
583029
         - tests::states:remove_down_twice
cc4018
+
cc4018
+  pre_tasks:
cc4018
+    - name: Save host state
583029
+      import_tasks: tasks/save_state.yml
cc4018
+
cc4018
+  post_tasks:
e662d2
+    - name: Remove test profile
cc4018
+      tags:
cc4018
+        - 'tests::cleanup'
cc4018
+        - 'tests::net::bridge::cleanup'
e662d2
+      import_role:
e662d2
+        name: linux-system-roles.network
e662d2
+      vars:
e662d2
+        network_connections:
e662d2
+          - name: statebr
e662d2
+            state: down
e662d2
+            persistent_state: absent
cc4018
+
cc4018
+    - name: Restore host state
583029
+      import_tasks: tasks/restore_state.yml
cc4018
diff --git a/tests/playbooks/tests_vlan_mtu.yml b/tests/playbooks/tests_vlan_mtu.yml
583029
index 029b599..378d5fe 100644
cc4018
--- a/tests/playbooks/tests_vlan_mtu.yml
cc4018
+++ b/tests/playbooks/tests_vlan_mtu.yml
583029
@@ -10,6 +10,8 @@
583029
     - include_tasks: tasks/manage_test_interface.yml
cc4018
       vars:
cc4018
         state: present
cc4018
+      tags:
cc4018
+        - 'tests::net::veth'
583029
     - include_tasks: tasks/assert_device_present.yml
583029
     - name: >-
583029
         TEST: I can configure the MTU for a vlan interface without autoconnect.
583029
@@ -38,6 +40,8 @@
cc4018
             ip:
cc4018
               dhcp4: false
cc4018
               auto6: false
cc4018
+      tags:
cc4018
+        - 'tests::net::reconf'
583029
     - include_tasks: tasks/assert_device_present.yml
cc4018
       vars:
cc4018
         interface: "{{ vlan_interface }}"
583029
@@ -62,6 +66,20 @@
cc4018
             persistent_state: absent
cc4018
             state: down
cc4018
       ignore_errors: true
cc4018
+      tags:
cc4018
+        - 'tests::cleanup'
cc4018
+        - 'tests::net::veth::cleanup'
583029
     - include_tasks: tasks/manage_test_interface.yml
cc4018
       vars:
cc4018
         state: absent
cc4018
+      tags:
cc4018
+        - 'tests::cleanup'
cc4018
+        - 'tests::net::veth::cleanup'
cc4018
+
cc4018
+  pre_tasks:
cc4018
+    - name: Save host state
583029
+      import_tasks: tasks/save_state.yml
cc4018
+
cc4018
+  post_tasks:
cc4018
+    - name: Restore host state
583029
+      import_tasks: tasks/restore_state.yml
583029
diff --git a/tests/playbooks/tests_wireless.yml b/tests/playbooks/tests_wireless.yml
583029
index 822a15e..52661bd 100644
583029
--- a/tests/playbooks/tests_wireless.yml
583029
+++ b/tests/playbooks/tests_wireless.yml
583029
@@ -1,5 +1,10 @@
583029
 # SPDX-License-Identifier: BSD-3-Clause
583029
 ---
583029
+- name: Save host state
583029
+  hosts: all
583029
+  tasks:
583029
+    - import_tasks: tasks/save_state.yml
583029
+
583029
 - hosts: all
583029
   vars:
583029
     interface: wlan0
583029
@@ -86,3 +91,8 @@
583029
             - include_tasks: tasks/cleanup_mock_wifi.yml
583029
           tags:
583029
             - "tests::cleanup"
583029
+
583029
+- name: Restore host state
583029
+  hosts: all
583029
+  tasks:
583029
+    - import_tasks: tasks/restore_state.yml
583029
diff --git a/tests/tasks/commonvars.yml b/tests/tasks/commonvars.yml
583029
new file mode 100644
583029
index 0000000..50452f7
583029
--- /dev/null
583029
+++ b/tests/tasks/commonvars.yml
583029
@@ -0,0 +1,2 @@
583029
+restore_services:
583029
+  - NetworkManager
583029
diff --git a/tests/tasks/get_services_state.yml b/tests/tasks/get_services_state.yml
583029
new file mode 100644
583029
index 0000000..4fe5d36
583029
--- /dev/null
583029
+++ b/tests/tasks/get_services_state.yml
583029
@@ -0,0 +1,4 @@
583029
+- name: Get initial state of services
583029
+  tags: tests::cleanup
583029
+  service_facts:
583029
+  register: initial_state
583029
diff --git a/tests/tasks/restore_services_state.yml b/tests/tasks/restore_services_state.yml
cc4018
new file mode 100644
cc4018
index 0000000..2035dfc
cc4018
--- /dev/null
583029
+++ b/tests/tasks/restore_services_state.yml
cc4018
@@ -0,0 +1,22 @@
cc4018
+- block:
cc4018
+    - name: load common vars
cc4018
+      include_vars:
cc4018
+        file: commonvars.yml
cc4018
+
cc4018
+    - name: Get final state of services
cc4018
+      service_facts:
cc4018
+      register: final_state
cc4018
+
cc4018
+    - name: Restore state of services
cc4018
+      service:
cc4018
+        name: "{{ item }}"
cc4018
+        state: "{{ 'started' if
cc4018
+                   initial_state.ansible_facts.services[sname]['state']
cc4018
+                   == 'running' else 'stopped' }}"
cc4018
+      when:
cc4018
+         - sname in final_state.ansible_facts.services
cc4018
+         - sname in initial_state.ansible_facts.services
cc4018
+      vars:
cc4018
+        sname: "{{ item + '.service' }}"
cc4018
+      with_items: "{{ restore_services }}"
cc4018
+  tags: tests::cleanup
583029
diff --git a/tests/tasks/restore_state.yml b/tests/tasks/restore_state.yml
cc4018
new file mode 100644
cc4018
index 0000000..f4e3d5f
cc4018
--- /dev/null
583029
+++ b/tests/tasks/restore_state.yml
cc4018
@@ -0,0 +1,24 @@
cc4018
+---
cc4018
+- name: Remove /etc/sysconfig/network if there was no one
cc4018
+  tags:
cc4018
+    - 'tests::cleanup'
cc4018
+  file:
cc4018
+    path: /etc/sysconfig/network
cc4018
+    state: absent
cc4018
+  when:
cc4018
+    - etc_sysconfig_network_stat is defined
cc4018
+    - not etc_sysconfig_network_stat.stat.exists
cc4018
+
cc4018
+- name: Restore services
cc4018
+  import_tasks: restore_services_state.yml
cc4018
+
cc4018
+- name: reload NetworkManager
cc4018
+  tags:
cc4018
+    - 'tests::cleanup'
cc4018
+  command: nmcli connection reload
cc4018
+  when:
cc4018
+    - sname in final_state.ansible_facts.services
cc4018
+    - sname in initial_state.ansible_facts.services
cc4018
+    - final_state.ansible_facts.services[sname]['state'] == 'running'
cc4018
+  vars:
cc4018
+    sname: NetworkManager.service
583029
diff --git a/tests/tasks/save_state.yml b/tests/tasks/save_state.yml
cc4018
new file mode 100644
cc4018
index 0000000..5690aed
cc4018
--- /dev/null
583029
+++ b/tests/tasks/save_state.yml
cc4018
@@ -0,0 +1,11 @@
cc4018
+---
cc4018
+- name: Get services state
cc4018
+  import_tasks: get_services_state.yml
cc4018
+
cc4018
+- name: Investigate /etc/sysconfig/network presence
cc4018
+  tags:
cc4018
+    - 'tests::cleanup'
cc4018
+  stat:
cc4018
+    path: /etc/sysconfig/network
cc4018
+  register: etc_sysconfig_network_stat
cc4018
+  ignore_errors: yes
583029
diff --git a/tests/tests_802_1x_nm.yml b/tests/tests_802_1x_nm.yml
e662d2
index 288cd5d..840958d 100644
583029
--- a/tests/tests_802_1x_nm.yml
583029
+++ b/tests/tests_802_1x_nm.yml
583029
@@ -4,6 +4,8 @@
583029
 # set network provider and gather facts
583029
 - hosts: all
583029
   name: Run playbook 'playbooks/tests_802_1x.yml' with nm as provider
cc4018
+  tags:
583029
+    - tests::expfail
583029
   tasks:
583029
     - name: Set network provider to 'nm'
583029
       set_fact:
e662d2
@@ -17,3 +19,5 @@
583029
 - import_playbook: playbooks/tests_802_1x.yml
583029
   when:
583029
     - ansible_distribution_major_version != '6'
583029
+  tags:
583029
+    - tests::expfail
583029
diff --git a/tests/tests_802_1x_updated_nm.yml b/tests/tests_802_1x_updated_nm.yml
e662d2
index bd335e4..4ebcaf9 100644
583029
--- a/tests/tests_802_1x_updated_nm.yml
583029
+++ b/tests/tests_802_1x_updated_nm.yml
583029
@@ -4,6 +4,8 @@
583029
 # set network provider and gather facts
cc4018
 - hosts: all
583029
   name: Run playbook 'playbooks/tests_802_1x_updated.yml' with nm as provider
cc4018
+  tags:
583029
+    - tests::expfail
cc4018
   tasks:
583029
     - name: Set network provider to 'nm'
583029
       set_fact:
e662d2
@@ -17,3 +19,5 @@
583029
 - import_playbook: playbooks/tests_802_1x_updated.yml
583029
   when:
583029
     - ansible_distribution_major_version != '6'
583029
+  tags:
583029
+    - tests::expfail
cc4018
diff --git a/tests/tests_default.yml b/tests/tests_default.yml
583029
index f6f7550..98e3c7e 100644
cc4018
--- a/tests/tests_default.yml
cc4018
+++ b/tests/tests_default.yml
583029
@@ -10,3 +10,11 @@
583029
         that:
583029
           - "'warnings' not in __network_connections_result"
583029
         msg: "There are warnings"
cc4018
+
cc4018
+  pre_tasks:
cc4018
+    - name: Save host state
583029
+      import_tasks: tasks/save_state.yml
cc4018
+
cc4018
+  post_tasks:
cc4018
+    - name: Restore host state
583029
+      import_tasks: tasks/restore_state.yml
583029
diff --git a/tests/tests_helpers_and_asserts.yml b/tests/tests_helpers_and_asserts.yml
583029
index 5514182..d9bfa11 100644
583029
--- a/tests/tests_helpers_and_asserts.yml
583029
+++ b/tests/tests_helpers_and_asserts.yml
583029
@@ -15,6 +15,14 @@
cc4018
         type: dummy
cc4018
         interface: dummy1298
cc4018
 
cc4018
+  pre_tasks:
cc4018
+    - name: Save host state
583029
+      import_tasks: tasks/save_state.yml
cc4018
+
cc4018
+  post_tasks:
cc4018
+    - name: Restore host state
583029
+      import_tasks: tasks/restore_state.yml
cc4018
+
583029
 # FIXME: when: does not seem to work with include_tasks, therefore this cannot
583029
 # be safely tested for now
cc4018
 #    - name: test tap interfaces