Blame SOURCES/kdump-tier1-tags.diff

48847c
diff --git a/tests/commonvars.yml b/tests/commonvars.yml
48847c
new file mode 100644
48847c
index 0000000..2cd3566
48847c
--- /dev/null
48847c
+++ b/tests/commonvars.yml
48847c
@@ -0,0 +1,2 @@
48847c
+restore_services:
48847c
+  - kdump
48847c
diff --git a/tests/get_services_state.yml b/tests/get_services_state.yml
48847c
new file mode 100644
48847c
index 0000000..4fe5d36
48847c
--- /dev/null
48847c
+++ b/tests/get_services_state.yml
48847c
@@ -0,0 +1,4 @@
48847c
+- name: Get initial state of services
48847c
+  tags: tests::cleanup
48847c
+  service_facts:
48847c
+  register: initial_state
48847c
diff --git a/tests/restore_services_state.yml b/tests/restore_services_state.yml
48847c
new file mode 100644
48847c
index 0000000..2035dfc
48847c
--- /dev/null
48847c
+++ b/tests/restore_services_state.yml
48847c
@@ -0,0 +1,22 @@
48847c
+- block:
48847c
+    - name: load common vars
48847c
+      include_vars:
48847c
+        file: commonvars.yml
48847c
+
48847c
+    - name: Get final state of services
48847c
+      service_facts:
48847c
+      register: final_state
48847c
+
48847c
+    - name: Restore state of services
48847c
+      service:
48847c
+        name: "{{ item }}"
48847c
+        state: "{{ 'started' if
48847c
+                   initial_state.ansible_facts.services[sname]['state']
48847c
+                   == 'running' else 'stopped' }}"
48847c
+      when:
48847c
+         - sname in final_state.ansible_facts.services
48847c
+         - sname in initial_state.ansible_facts.services
48847c
+      vars:
48847c
+        sname: "{{ item + '.service' }}"
48847c
+      with_items: "{{ restore_services }}"
48847c
+  tags: tests::cleanup
48847c
diff --git a/tests/tests_default.yml b/tests/tests_default.yml
48847c
index 4c93830..60d7967 100644
48847c
--- a/tests/tests_default.yml
48847c
+++ b/tests/tests_default.yml
48847c
@@ -1,6 +1,18 @@
48847c
 
48847c
 - name: Ensure that the rule runs with default parameters
48847c
+  tags:
48847c
+    - 'tests::tier1'
48847c
   hosts: all
48847c
 
48847c
   roles:
48847c
     - kdump
48847c
+
48847c
+  pre_tasks:
48847c
+    - name: Import tasks
48847c
+      tags: tests::tier1::cleanup
48847c
+      import_tasks: get_services_state.yml
48847c
+
48847c
+  post_tasks:
48847c
+    - name: Import tasks
48847c
+      tags: tests::tier1::cleanup
48847c
+      import_tasks: restore_services_state.yml
48847c
diff --git a/tests/tests_default_wrapper.yml b/tests/tests_default_wrapper.yml
48847c
index 2763fbd..617acb3 100644
48847c
--- a/tests/tests_default_wrapper.yml
48847c
+++ b/tests/tests_default_wrapper.yml
48847c
@@ -1,6 +1,9 @@
48847c
 ---
48847c
 - name: Create static inventory from hostvars
48847c
   hosts: all
48847c
+  tags:
48847c
+    - 'tests::tier1'
48847c
+    - 'tests::slow'
48847c
   tasks:
48847c
     - name: create temporary file
48847c
       tempfile:
48847c
@@ -17,10 +20,16 @@
48847c
 
48847c
 
48847c
 - name: Run tests_default.yml normally
48847c
+  tags:
48847c
+    - 'tests::tier1'
48847c
+    - 'tests::slow'
48847c
   import_playbook: tests_default.yml
48847c
 
48847c
 - name: Run tests_default.yml in check_mode
48847c
   hosts: all
48847c
+  tags:
48847c
+    - 'tests::tier1'
48847c
+    - 'tests::slow'
48847c
   tasks:
48847c
     - name: Run ansible-playbook with tests_default.yml in check mode
48847c
       command: ansible-playbook -vvv -i {{ tempinventory.path }} --check tests_default.yml