rhel-system-roles/SOURCES/kdump-tier1-tags.diff

143 lines
4.3 KiB
Diff

diff --git a/tests/commonvars.yml b/tests/commonvars.yml
new file mode 100644
index 0000000..2cd3566
--- /dev/null
+++ b/tests/commonvars.yml
@@ -0,0 +1,2 @@
+restore_services:
+ - kdump
diff --git a/tests/get_services_state.yml b/tests/get_services_state.yml
new file mode 100644
index 0000000..4fe5d36
--- /dev/null
+++ b/tests/get_services_state.yml
@@ -0,0 +1,4 @@
+- name: Get initial state of services
+ tags: tests::cleanup
+ service_facts:
+ register: initial_state
diff --git a/tests/restore_services_state.yml b/tests/restore_services_state.yml
new file mode 100644
index 0000000..2035dfc
--- /dev/null
+++ b/tests/restore_services_state.yml
@@ -0,0 +1,22 @@
+- block:
+ - name: load common vars
+ include_vars:
+ file: commonvars.yml
+
+ - name: Get final state of services
+ service_facts:
+ register: final_state
+
+ - name: Restore state of services
+ service:
+ name: "{{ item }}"
+ state: "{{ 'started' if
+ initial_state.ansible_facts.services[sname]['state']
+ == 'running' else 'stopped' }}"
+ when:
+ - sname in final_state.ansible_facts.services
+ - sname in initial_state.ansible_facts.services
+ vars:
+ sname: "{{ item + '.service' }}"
+ with_items: "{{ restore_services }}"
+ tags: tests::cleanup
diff --git a/tests/tests_default.yml b/tests/tests_default.yml
index 4c93830..9e7743a 100644
--- a/tests/tests_default.yml
+++ b/tests/tests_default.yml
@@ -4,3 +4,13 @@
roles:
- kdump
+
+ pre_tasks:
+ - name: Import tasks
+# tags: tests::tier1::cleanup
+ import_tasks: get_services_state.yml
+
+ post_tasks:
+ - name: Import tasks
+# tags: tests::tier1::cleanup
+ import_tasks: restore_services_state.yml
diff --git a/tests/tests_default_wrapper.yml b/tests/tests_default_wrapper.yml
index 2763fbd..95b3886 100644
--- a/tests/tests_default_wrapper.yml
+++ b/tests/tests_default_wrapper.yml
@@ -1,6 +1,9 @@
---
- name: Create static inventory from hostvars
hosts: all
+ tags:
+# - 'tests::tier1'
+ - 'tests::slow'
tasks:
- name: create temporary file
tempfile:
@@ -17,10 +20,16 @@
- name: Run tests_default.yml normally
+ tags:
+# - 'tests::tier1'
+ - 'tests::slow'
import_playbook: tests_default.yml
- name: Run tests_default.yml in check_mode
hosts: all
+ tags:
+# - 'tests::tier1'
+ - 'tests::slow'
tasks:
- name: Run ansible-playbook with tests_default.yml in check mode
command: ansible-playbook -vvv -i {{ tempinventory.path }} --check tests_default.yml
diff --git a/tests/tests_ssh.yml b/tests/tests_ssh.yml
index 14a59d9..23bc7eb 100644
--- a/tests/tests_ssh.yml
+++ b/tests/tests_ssh.yml
@@ -11,6 +11,13 @@
# this is the address at which the ssh dump server can be reached
# from the managed host. Dumps will be uploaded there.
kdump_ssh_server_inside: "{{ kdump_ssh_source if kdump_ssh_source in hostvars[kdump_ssh_server_outside]['ansible_all_ipv4_addresses'] + hostvars[kdump_ssh_server_outside]['ansible_all_ipv6_addresses'] else hostvars[kdump_ssh_server_outside]['ansible_default_ipv4']['address'] }}"
+ tags:
+ # this test executes some tasks on localhost and relies on
+ # localhost being a different host than the managed host
+ # (localhost is being used as a second host in multihost
+ # scenario). This also means that localhost must be capable
+ # enough (not just a container - must be runnign a sshd).
+ - 'tests::multihost_localhost'
tasks:
- name: gather facts from {{ kdump_ssh_server_outside }}
diff --git a/tests/tests_ssh_wrapper.yml b/tests/tests_ssh_wrapper.yml
index 9a8ecfd..1a6db73 100644
--- a/tests/tests_ssh_wrapper.yml
+++ b/tests/tests_ssh_wrapper.yml
@@ -1,6 +1,8 @@
---
- name: Create static inventory from hostvars
hosts: all
+ tags:
+ - 'tests::slow'
tasks:
- name: create temporary file
tempfile:
@@ -17,10 +19,15 @@
- name: Run tests_ssh.yml normally
+ tags:
+ - 'tests::slow'
import_playbook: tests_ssh.yml
- name: Run tests_ssh.yml in check_mode
hosts: all
+ tags:
+ - 'tests::slow'
+ - 'tests::multihost_localhost'
tasks:
- name: Run ansible-playbook with tests_ssh.yml in check mode
command: ansible-playbook -vvv -i {{ tempinventory.path }} --check tests_ssh.yml