rhel-system-roles/timesync-tier1-tags.diff

336 lines
8.8 KiB
Diff
Raw Normal View History

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..3d48975
--- /dev/null
+++ b/tests/restore_services_state.yml
@@ -0,0 +1,19 @@
+- name: Get final state of services
+ tags: tests::cleanup
+ service_facts:
+ register: final_state
+
+- name: Restore state of services
+ tags: tests::cleanup
+ service:
+ name: "{{ item }}"
+ state: "{{ 'started' if initial_state.ansible_facts.services[item + '.service']['state'] == 'running' else 'stopped' }}"
+ when:
+ - item + '.service' in final_state.ansible_facts.services
+ - item + '.service' in initial_state.ansible_facts.services
+ with_items:
+ - chronyd
+ - ntpd
+ - ptp4l
+ - phc2sys
+ - timemaster
diff --git a/tests/tests_default.yml b/tests/tests_default.yml
index 856ebe5..fb298c9 100644
--- a/tests/tests_default.yml
+++ b/tests/tests_default.yml
@@ -3,4 +4,14 @@
hosts: all
roles:
- linux-system-roles.timesync
+
+ 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 a768f4c..b0c0ab3 100644
--- a/tests/tests_default_wrapper.yml
+++ b/tests/tests_default_wrapper.yml
@@ -1,5 +1,8 @@
---
- name: Create static inventory from hostvars
+ tags:
+# - 'tests::tier1'
+ - 'tests::slow'
hosts: all
tasks:
- name: create temporary file
@@ -17,9 +20,15 @@
- name: Run tests_default.yml normally
+ tags:
+# - 'tests::tier1'
+ - 'tests::slow'
import_playbook: tests_default.yml
- name: Run tests_default.yml in check_mode
+ tags:
+# - 'tests::tier1'
+ - 'tests::slow'
hosts: all
tasks:
- name: Run ansible-playbook with tests_default.yml in check mode
diff --git a/tests/tests_ntp.yml b/tests/tests_ntp.yml
index e4b1b5e..446f1dc 100644
--- a/tests/tests_ntp.yml
+++ b/tests/tests_ntp.yml
@@ -18,6 +19,11 @@
roles:
- linux-system-roles.timesync
+ pre_tasks:
+ - name: Import tasks
+# tags: tests::tier1::cleanup
+ import_tasks: get_services_state.yml
+
tasks:
- meta: flush_handlers
@@ -35,3 +41,8 @@
- "'172.16.123.1' in sources.stdout"
- "'172.16.123.2' in sources.stdout"
- "'172.16.123.3' in sources.stdout"
+
+ post_tasks:
+ - name: Import tasks
+# tags: tests::tier1::cleanup
+ import_tasks: restore_services_state.yml
diff --git a/tests/tests_ntp_provider1.yml b/tests/tests_ntp_provider1.yml
index 08ecab9..9fe0db3 100644
--- a/tests/tests_ntp_provider1.yml
+++ b/tests/tests_ntp_provider1.yml
@@ -8,6 +9,10 @@
- linux-system-roles.timesync
pre_tasks:
+ - name: Import tasks
+# tags: tests::tier1::cleanup
+ import_tasks: get_services_state.yml
+
- name: Remove NTP providers
package: name={{ item }} state=absent
with_items:
@@ -27,3 +32,7 @@
assert:
that:
- "'172.16.123.1' in sources.stdout"
+
+ - name: Import tasks
+# tags: tests::tier1::cleanup
+ import_tasks: restore_services_state.yml
diff --git a/tests/tests_ntp_provider2.yml b/tests/tests_ntp_provider2.yml
index 5476ae4..e0d5c96 100644
--- a/tests/tests_ntp_provider2.yml
+++ b/tests/tests_ntp_provider2.yml
@@ -8,6 +9,10 @@
- linux-system-roles.timesync
pre_tasks:
+ - name: Import tasks
+# tags: tests::tier1::cleanup
+ import_tasks: get_services_state.yml
+
- name: Remove ntp
package: name=ntp state=absent
@@ -29,3 +34,7 @@
- name: Check chronyd service
shell: chronyc -n tracking
+
+ - name: Import tasks
+# tags: tests::tier1::cleanup
+ import_tasks: restore_services_state.yml
diff --git a/tests/tests_ntp_provider3.yml b/tests/tests_ntp_provider3.yml
index 44ca101..d440a64 100644
--- a/tests/tests_ntp_provider3.yml
+++ b/tests/tests_ntp_provider3.yml
@@ -8,6 +9,10 @@
- linux-system-roles.timesync
pre_tasks:
+ - name: Import tasks
+# tags: tests::tier1::cleanup
+ import_tasks: get_services_state.yml
+
- name: Remove chrony
package: name=chrony state=absent
@@ -29,3 +34,7 @@
- name: Check ntpd service
shell: ntpq -c rv | grep 'associd=0'
+
+ - name: Import tasks
+ tags: tests::tier1::cleanup
+ import_tasks: restore_services_state.yml
diff --git a/tests/tests_ntp_provider4.yml b/tests/tests_ntp_provider4.yml
index 8b452b8..8bccba0 100644
--- a/tests/tests_ntp_provider4.yml
+++ b/tests/tests_ntp_provider4.yml
@@ -9,6 +10,10 @@
- linux-system-roles.timesync
pre_tasks:
+ - name: Import tasks
+# tags: tests::tier1::cleanup
+ import_tasks: get_services_state.yml
+
- name: Install chrony
package: name=chrony state=present
register: package_install
@@ -27,3 +32,7 @@
- name: Check chronyd service
shell: chronyc -n tracking
+
+ - name: Import tasks
+# tags: tests::tier1::cleanup
+ import_tasks: restore_services_state.yml
diff --git a/tests/tests_ntp_provider5.yml b/tests/tests_ntp_provider5.yml
index 1740164..98a054f 100644
--- a/tests/tests_ntp_provider5.yml
+++ b/tests/tests_ntp_provider5.yml
@@ -9,6 +10,10 @@
- linux-system-roles.timesync
pre_tasks:
+ - name: Import tasks
+# tags: tests::tier1::cleanup
+ import_tasks: get_services_state.yml
+
- name: Install ntp
package: name=ntp state=present
register: package_install
@@ -27,3 +32,7 @@
- name: Check ntpd service
shell: ntpq -c rv | grep 'associd=0'
+
+ - name: Import tasks
+# tags: tests::tier1::cleanup
+ import_tasks: restore_services_state.yml
diff --git a/tests/tests_ntp_provider6.yml b/tests/tests_ntp_provider6.yml
index 21a2039..fb41824 100644
--- a/tests/tests_ntp_provider6.yml
+++ b/tests/tests_ntp_provider6.yml
@@ -6,6 +7,10 @@
both_avail: true
tasks:
+ - name: Import tasks
+# tags: tests::tier1::cleanup
+ import_tasks: get_services_state.yml
+
- name: Check for availability of both NTP providers
package: name={{ item }} state=present
register: package_install
@@ -71,3 +76,7 @@
shell: chronyc -n tracking
when:
- not is_ntp_default
+
+ - name: Import tasks
+# tags: tests::tier1::cleanup
+ import_tasks: restore_services_state.yml
diff --git a/tests/tests_ntp_ptp.yml b/tests/tests_ntp_ptp.yml
index cab706f..7f4cdfc 100644
--- a/tests/tests_ntp_ptp.yml
+++ b/tests/tests_ntp_ptp.yml
@@ -22,6 +23,11 @@
roles:
- linux-system-roles.timesync
+ pre_tasks:
+ - name: Import tasks
+# tags: tests::tier1::cleanup
+ import_tasks: get_services_state.yml
+
tasks:
- meta: flush_handlers
@@ -48,3 +54,8 @@
- "'PTP1' in sources.stdout"
when: "'SOF_TIMESTAMPING_TX_' in ethtool.stdout"
+
+ post_tasks:
+ - name: Import tasks
+# tags: tests::tier1::cleanup
+ import_tasks: restore_services_state.yml
diff --git a/tests/tests_ptp_multi.yml b/tests/tests_ptp_multi.yml
index d52d439..936e467 100644
--- a/tests/tests_ptp_multi.yml
+++ b/tests/tests_ptp_multi.yml
@@ -1,5 +1,6 @@
- name: Configure time synchronization with multiple PTP domains
+ tags: tests::expfail
hosts: all
vars:
timesync_ptp_domains:
@@ -16,6 +17,11 @@
roles:
- linux-system-roles.timesync
+ pre_tasks:
+ - name: Import tasks
+# tags: tests::tier1::cleanup
+ import_tasks: get_services_state.yml
+
tasks:
- meta: flush_handlers
@@ -58,3 +64,8 @@
- "'domainNumber 1' in pmc.stdout"
when: "'SOF_TIMESTAMPING_TX_' in ethtool.stdout"
+
+ post_tasks:
+ - name: Import tasks
+# tags: tests::tier1::cleanup
+ import_tasks: restore_services_state.yml
diff --git a/tests/tests_ptp_single.yml b/tests/tests_ptp_single.yml
index 74da310..36d141e 100644
--- a/tests/tests_ptp_single.yml
+++ b/tests/tests_ptp_single.yml
@@ -1,5 +1,6 @@
- name: Configure time synchronization with single PTP domain
+ tags: tests::expfail
hosts: all
vars:
timesync_ptp_domains:
@@ -8,6 +9,11 @@
roles:
- linux-system-roles.timesync
+ pre_tasks:
+ - name: Import tasks
+# tags: tests::tier1::cleanup
+ import_tasks: get_services_state.yml
+
tasks:
- meta: flush_handlers
@@ -31,3 +37,8 @@
- "'domainNumber 3' in pmc.stdout"
when: "'SOF_TIMESTAMPING_TX_' in ethtool.stdout"
+
+ post_tasks:
+ - name: Import tasks
+# tags: tests::tier1::cleanup
+ import_tasks: restore_services_state.yml