rhel-system-roles/timesync-tier1-tags.diff
Rich Megginson 799866de2b rebase timesync role to latest upstream
Rebase to latest upstream (1937938)
timesync - add timesync_chrony_custom_settings variable for free-form local configs (1938023)
do not use ignore_errors in timesync role (1938014)
support for timesync_max_distance to configure maxdistance/maxdist parameter (1938016)
support for ntp xleave, filter, and hw timestamping (1938020)

Related: rhbz#1961404
2021-05-25 13:40:31 -07:00

363 lines
10 KiB
Diff

From e658f6f0e7906d220027c9a36bf16398fdca1564 Mon Sep 17 00:00:00 2001
From: Rich Megginson <rmeggins@redhat.com>
Date: Mon, 22 Mar 2021 13:45:01 -0600
Subject: [PATCH] add service cleanup for downstream testing
---
tests/get_services_state.yml | 4 ++++
tests/restore_services_state.yml | 23 +++++++++++++++++++++++
tests/tests_default.yml | 10 ++++++++++
tests/tests_default_wrapper.yml | 9 +++++++++
tests/tests_ntp.yml | 10 ++++++++++
tests/tests_ntp_provider1.yml | 8 ++++++++
tests/tests_ntp_provider2.yml | 8 ++++++++
tests/tests_ntp_provider3.yml | 8 ++++++++
tests/tests_ntp_provider4.yml | 8 ++++++++
tests/tests_ntp_provider5.yml | 8 ++++++++
tests/tests_ntp_provider6.yml | 8 ++++++++
tests/tests_ntp_ptp.yml | 10 ++++++++++
tests/tests_ptp_multi.yml | 11 +++++++++++
tests/tests_ptp_single.yml | 11 +++++++++++
14 files changed, 136 insertions(+)
create mode 100644 tests/get_services_state.yml
create mode 100644 tests/restore_services_state.yml
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..9cc9768
--- /dev/null
+++ b/tests/restore_services_state.yml
@@ -0,0 +1,23 @@
+- 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 9dc0e4c..61c1ea8 100644
--- a/tests/tests_default.yml
+++ b/tests/tests_default.yml
@@ -3,3 +3,13 @@
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 3090259..98be26f 100644
--- a/tests/tests_default_wrapper.yml
+++ b/tests/tests_default_wrapper.yml
@@ -1,4 +1,7 @@
- name: Create static inventory from hostvars
+ tags:
+# - 'tests::tier1'
+ - 'tests::slow'
hosts: all
tasks:
- name: create temporary file
@@ -15,9 +18,15 @@
delegate_to: localhost
- 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 9f39d24..c5768f4 100644
--- a/tests/tests_ntp.yml
+++ b/tests/tests_ntp.yml
@@ -20,6 +20,11 @@
roles:
- linux-system-roles.timesync
+ pre_tasks:
+ - name: Import tasks
+# tags: tests::tier1::cleanup
+ import_tasks: get_services_state.yml
+
tasks:
- block:
- meta: flush_handlers
@@ -67,3 +72,8 @@
__timesync_chrony_version is version('3.1', '>=')
when: chrony_conf is defined
tags: tests::verify
+
+ 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 988330a..e231b18 100644
--- a/tests/tests_ntp_provider1.yml
+++ b/tests/tests_ntp_provider1.yml
@@ -7,6 +7,10 @@
- linux-system-roles.timesync
pre_tasks:
+ - name: Import tasks
+# tags: tests::tier1::cleanup
+ import_tasks: get_services_state.yml
+
- block:
- name: Remove NTP providers
package: name={{ item }} state=absent
@@ -31,3 +35,7 @@
that:
- "'172.16.123.1' in sources.stdout"
tags: tests::verify
+
+ - 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 5a6284f..cf3e2a7 100644
--- a/tests/tests_ntp_provider2.yml
+++ b/tests/tests_ntp_provider2.yml
@@ -7,6 +7,10 @@
- linux-system-roles.timesync
pre_tasks:
+ - name: Import tasks
+# tags: tests::tier1::cleanup
+ import_tasks: get_services_state.yml
+
- block:
- name: Remove ntp
package: name=ntp state=absent
@@ -33,3 +37,7 @@
- name: Check chronyd service
shell: chronyc -n tracking
tags: tests::verify
+
+ - 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 d5117de..4b88991 100644
--- a/tests/tests_ntp_provider3.yml
+++ b/tests/tests_ntp_provider3.yml
@@ -7,6 +7,10 @@
- linux-system-roles.timesync
pre_tasks:
+ - name: Import tasks
+# tags: tests::tier1::cleanup
+ import_tasks: get_services_state.yml
+
- block:
- name: Remove chrony
package: name=chrony state=absent
@@ -33,3 +37,7 @@
- name: Check ntpd service
shell: ntpq -c rv | grep 'associd=0'
tags: tests::verify
+
+ - 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 c4e33c7..2e030c3 100644
--- a/tests/tests_ntp_provider4.yml
+++ b/tests/tests_ntp_provider4.yml
@@ -8,6 +8,10 @@
- linux-system-roles.timesync
pre_tasks:
+ - name: Import tasks
+# tags: tests::tier1::cleanup
+ import_tasks: get_services_state.yml
+
- block:
- name: Install chrony
package: name=chrony state=present
@@ -31,3 +35,7 @@
- name: Check chronyd service
shell: chronyc -n tracking
tags: tests::verify
+
+ - 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 09a855a..a4fbc2d 100644
--- a/tests/tests_ntp_provider5.yml
+++ b/tests/tests_ntp_provider5.yml
@@ -8,6 +8,10 @@
- linux-system-roles.timesync
pre_tasks:
+ - name: Import tasks
+# tags: tests::tier1::cleanup
+ import_tasks: get_services_state.yml
+
- block:
- name: Install ntp
package: name=ntp state=present
@@ -31,3 +35,7 @@
- name: Check ntpd service
shell: ntpq -c rv | grep 'associd=0'
tags: tests::verify
+
+ - 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 346b96a..31b55a1 100644
--- a/tests/tests_ntp_provider6.yml
+++ b/tests/tests_ntp_provider6.yml
@@ -7,6 +7,10 @@
both_avail: true
tasks:
+ - name: Import tasks
+# tags: tests::tier1::cleanup
+ import_tasks: get_services_state.yml
+
- block:
- name: Check for availability of both NTP providers
package: name={{ item }} state=present
@@ -81,3 +85,7 @@
when:
- not is_ntp_default
tags: tests::verify
+
+ - 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 56079a3..fba330d 100644
--- a/tests/tests_ntp_ptp.yml
+++ b/tests/tests_ntp_ptp.yml
@@ -21,6 +21,11 @@
roles:
- linux-system-roles.timesync
+ pre_tasks:
+ - name: Import tasks
+# tags: tests::tier1::cleanup
+ import_tasks: get_services_state.yml
+
tasks:
- block:
- meta: flush_handlers
@@ -49,3 +54,8 @@
when: "'SOF_TIMESTAMPING_TX_' in ethtool.stdout"
tags: tests::verify
+
+ 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 1d1cd8e..02b44cb 100644
--- a/tests/tests_ptp_multi.yml
+++ b/tests/tests_ptp_multi.yml
@@ -1,4 +1,5 @@
- name: Configure time synchronization with multiple PTP domains
+ tags: tests::expfail
hosts: all
vars:
timesync_ptp_domains:
@@ -15,6 +16,11 @@
roles:
- linux-system-roles.timesync
+ pre_tasks:
+ - name: Import tasks
+# tags: tests::tier1::cleanup
+ import_tasks: get_services_state.yml
+
tasks:
- block:
- meta: flush_handlers
@@ -61,3 +67,8 @@
when: "'SOF_TIMESTAMPING_TX_' in ethtool.stdout"
tags: tests::verify
+
+ 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 c7ba401..b96c34c 100644
--- a/tests/tests_ptp_single.yml
+++ b/tests/tests_ptp_single.yml
@@ -1,4 +1,5 @@
- name: Configure time synchronization with single PTP domain
+ tags: tests::expfail
hosts: all
vars:
timesync_ptp_domains:
@@ -7,6 +8,11 @@
roles:
- linux-system-roles.timesync
+ pre_tasks:
+ - name: Import tasks
+# tags: tests::tier1::cleanup
+ import_tasks: get_services_state.yml
+
tasks:
- block:
- meta: flush_handlers
@@ -32,3 +38,8 @@
when: "'SOF_TIMESTAMPING_TX_' in ethtool.stdout"
tags: tests::verify
+
+ post_tasks:
+ - name: Import tasks
+# tags: tests::tier1::cleanup
+ import_tasks: restore_services_state.yml
--
2.30.2