Blame SOURCES/timesync-tier1-tags.diff

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