Blame SOURCES/network-tier1-tags.diff

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