Skip to content

Commit d77c4d3

Browse files
committed
ensure handlers are flushed and services are started before testing the services
1 parent 1a6b169 commit d77c4d3

11 files changed

Lines changed: 45 additions & 38 deletions

tests/tasks/cleanup.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,3 @@
55
timesync_ntp_provider: "{{ timesync_ntp_provider_os_default }}"
66
timesync_ptp_domains: []
77
timesync_ntp_servers: []
8-
9-
# Do this explicitly here to ensure all services are in the correct state
10-
# rather than relying on the handler to be called at the end of execution.
11-
- name: Flush handlers
12-
meta: flush_handlers

tests/tests_ntp.yml

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323
timesync_min_sources: 2
2424
timesync_ntp_hwts_interfaces: ["*"]
2525
tasks:
26-
- name: Debug0
27-
command: journalctl -ex
28-
2926
- name: Run the role
3027
include_tasks: tasks/run_role_with_clear_facts.yml
3128
vars:
@@ -34,28 +31,27 @@
3431
- name: Run test
3532
tags: tests::verify
3633
block:
37-
- name: Flush handlers
38-
meta: flush_handlers
34+
- name: Ensure services are running properly if booted
3935
when: __timesync_is_booted
36+
block:
37+
- name: Flush handlers
38+
meta: flush_handlers
4039

41-
- name: Wait for services to start
42-
wait_for:
43-
timeout: 2
44-
when: __timesync_is_booted
40+
- name: Wait for services to start
41+
wait_for:
42+
timeout: 2
4543

46-
- name: Get list of currently used time sources
47-
shell: chronyc -n sources || ntpq -pn
48-
register: sources
49-
changed_when: false
50-
when: __timesync_is_booted
44+
- name: Get list of currently used time sources
45+
shell: chronyc -n sources || ntpq -pn
46+
register: sources
47+
changed_when: false
5148

52-
- name: Check time sources
53-
assert:
54-
that:
55-
- "'172.16.123.1' in sources.stdout"
56-
- "'172.16.123.2' in sources.stdout"
57-
- "'172.16.123.3' in sources.stdout"
58-
when: __timesync_is_booted
49+
- name: Check time sources
50+
assert:
51+
that:
52+
- "'172.16.123.1' in sources.stdout"
53+
- "'172.16.123.2' in sources.stdout"
54+
- "'172.16.123.3' in sources.stdout"
5955

6056
- name: Fetch chrony.conf file
6157
slurp:

tests/tests_ntp_provider1.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
tags: tests::verify
3333
when: __timesync_is_booted
3434
block:
35+
- name: Flush handlers
36+
meta: flush_handlers
37+
3538
- name: Wait for services to start
3639
wait_for:
3740
timeout: 2

tests/tests_ntp_provider2.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646
tags: tests::verify
4747
when: __timesync_is_booted
4848
block:
49+
- name: Flush handlers
50+
meta: flush_handlers
51+
4952
- name: Wait for services to start
5053
wait_for:
5154
timeout: 2

tests/tests_ntp_provider3.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646
tags: tests::verify
4747
when: __timesync_is_booted
4848
block:
49+
- name: Flush handlers
50+
meta: flush_handlers
51+
4952
- name: Wait for services to start
5053
wait_for:
5154
timeout: 2

tests/tests_ntp_provider4.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
tags: tests::verify
4343
when: __timesync_is_booted
4444
block:
45+
- name: Flush handlers
46+
meta: flush_handlers
47+
4548
- name: Wait for services to start
4649
wait_for:
4750
timeout: 2

tests/tests_ntp_provider5.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
tags: tests::verify
4343
when: __timesync_is_booted
4444
block:
45+
- name: Flush handlers
46+
meta: flush_handlers
47+
4548
- name: Wait for services to start
4649
wait_for:
4750
timeout: 2

tests/tests_ntp_provider6.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@
9292

9393
- name: Verify provider set correctly - 2
9494
tags: tests::verify
95+
when: __timesync_is_booted
9596
block:
97+
- name: Flush handlers
98+
meta: flush_handlers
99+
96100
- name: Wait for services to start
97101
wait_for:
98102
timeout: 2

tests/tests_ntp_ptp.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@
3131
vars:
3232
__sr_public: true
3333

34-
- name: Flush handlers
35-
meta: flush_handlers
36-
when: __timesync_is_booted
37-
3834
- name: Ensure ethtool is installed
3935
package:
4036
name: ethtool
@@ -53,6 +49,9 @@
5349
- __timesync_is_booted
5450
- "'ware-transmit' in ethtool.stdout"
5551
block:
52+
- name: Flush handlers
53+
meta: flush_handlers
54+
5655
- name: Wait for services to start
5756
wait_for:
5857
timeout: 2

tests/tests_ptp_multi.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@
2525
- name: Run test
2626
tags: tests::verify
2727
block:
28-
- name: Flush handlers
29-
meta: flush_handlers
30-
when: __timesync_is_booted
31-
3228
- name: Ensure ethtool is installed
3329
package:
3430
name: ethtool
@@ -47,6 +43,9 @@
4743
- __timesync_is_booted
4844
- "'ware-transmit' in ethtool.stdout"
4945
block:
46+
- name: Flush handlers
47+
meta: flush_handlers
48+
5049
- name: Wait for services to start
5150
wait_for:
5251
timeout: 2

0 commit comments

Comments
 (0)