Skip to content

Commit 4fe08a6

Browse files
test: adjust playbook tasks for ostree test case
1 parent a2605c5 commit 4fe08a6

1 file changed

Lines changed: 66 additions & 162 deletions

File tree

tests/greenboot-ostree.yaml

Lines changed: 66 additions & 162 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@
3434
failed_counter: "{{ failed_counter | int + 1 }}"
3535

3636
# case: check greenboot* services
37-
- name: greenboot healthcheck service should be enabled
37+
- name: a list of greenboot* service should be enabled
3838
block:
39-
- name: greenboot healthcheck service should be enabled
40-
command: systemctl is-enabled greenboot-healthcheck
39+
- name: a list of greenboot* service should be enabled
40+
command: systemctl is-enabled greenboot-grub2-set-counter greenboot-grub2-set-success greenboot-healthcheck greenboot-rpm-ostree-grub2-check-fallback greenboot-status greenboot-task-runner redboot-auto-reboot redboot-task-runner
4141
register: result_greenboot_service
4242

4343
- assert:
4444
that:
45-
- result_greenboot_service.stdout == 'enabled'
45+
- result_greenboot_service.stdout == 'enabled\nenabled\nenabled\nenabled\nenabled\nenabled\nenabled\nenabled'
4646
fail_msg: "at least one greenboot service is not enabled"
4747
success_msg: "greenboot services are enabled"
4848
always:
@@ -53,18 +53,34 @@
5353
set_fact:
5454
failed_counter: "{{ failed_counter | int + 1 }}"
5555

56-
# case: check greenboot* service status
57-
- name: greenboot healthcheck service should be active
56+
# case: check greenboot* services log
57+
- name: all greenboot* service should run without error
5858
block:
59-
- name: greenboot healthcheck service should be active
60-
command: systemctl is-active greenboot-healthcheck.service
61-
register: result_greenboot_active
59+
# check service/target status instead of string matching messages
60+
- name: check boot-complete.target
61+
# will fail if the target was not reached
62+
command: systemctl --no-pager status boot-complete.target
63+
register: result
64+
retries: 10
65+
delay: 60
66+
until: "'inactive' not in result.stdout"
67+
68+
- name: all greenboot* service should run without error
69+
command: journalctl -b -0 -u greenboot -u greenboot-healthcheck -u greenboot-rpm-ostree-grub2-check-fallback -u greenboot-grub2-set-counter -u greenboot-grub2-set-success -u greenboot-status -u redboot -u redboot-auto-reboot -u redboot.target
70+
become: yes
71+
register: result_greenboot_log
6272

6373
- assert:
6474
that:
65-
- result_greenboot_active.stdout == "active"
66-
fail_msg: "greenboot healthcheck service is not active"
67-
success_msg: "greenboot healthcheck service is active"
75+
- "'Script \\'00_required_scripts_start.sh\\' SUCCESS' in result_greenboot_log.stdout"
76+
- "'Script \\'00_wanted_scripts_start.sh\\' SUCCESS' in result_greenboot_log.stdout"
77+
- "'greenboot Health Checks Runner' in result_greenboot_log.stdout"
78+
- "'Mark boot as successful in grubenv' in result_greenboot_log.stdout"
79+
- "'Boot Status is GREEN - Health Check SUCCESS' in result_greenboot_log.stdout"
80+
- "'greenboot MotD Generator' in result_greenboot_log.stdout"
81+
fail_msg: "Some errors happened in service boot"
82+
success_msg: "All greenboot services booted success"
83+
6884
always:
6985
- set_fact:
7086
total_counter: "{{ total_counter | int + 1 }}"
@@ -73,16 +89,26 @@
7389
set_fact:
7490
failed_counter: "{{ failed_counter | int + 1 }}"
7591

76-
# case: configure greenboot
77-
- name: configure greenboot
92+
# case: check grubenv variables
93+
- name: grubenv variables should contain boot_success=1
7894
block:
79-
- name: disable health-check
80-
shell: sed -i 's#DISABLED_HEALTHCHECKS=()#DISABLED_HEALTHCHECKS=("01_repository_dns_check.sh" "not_exit.sh")#g' /etc/greenboot/greenboot.conf
95+
- name: grubenv variables should contain boot_success=1
96+
command: grub2-editenv list
97+
register: result_grubenv
8198
become: yes
8299

83-
- name: change max boot attempts
84-
shell: sed -i "s/GREENBOOT_MAX_BOOT_ATTEMPTS=3/GREENBOOT_MAX_BOOT_ATTEMPTS=5/g" /etc/greenboot/greenboot.conf
85-
become: yes
100+
- assert:
101+
that:
102+
- "'boot_success=1' in result_grubenv.stdout"
103+
fail_msg: "Not found boot_success=1"
104+
success_msg: "Found boot_success=1"
105+
always:
106+
- set_fact:
107+
total_counter: "{{ total_counter | int + 1 }}"
108+
rescue:
109+
- name: failed count + 1
110+
set_fact:
111+
failed_counter: "{{ failed_counter | int + 1 }}"
86112

87113
# case: check rollback function if boot error found
88114
- name: install sanely failing health check unit to test red boot status behavior
@@ -126,36 +152,33 @@
126152
set_fact:
127153
failed_counter: "{{ failed_counter | int + 1 }}"
128154

129-
# case: check boot-complete.target status
130-
- name: boot-complete.target should be active
155+
# case: check greenboot* services log again
156+
- name: fallback log should be found here
131157
block:
158+
# check service/target status instead of string matching messages
132159
- name: check boot-complete.target
160+
# will fail if the target was not reached
133161
command: systemctl --no-pager status boot-complete.target
134162
become: yes
135163
register: result
136164
retries: 10
137165
delay: 60
138166
until: "'inactive' not in result.stdout"
139167

140-
always:
141-
- set_fact:
142-
total_counter: "{{ total_counter | int + 1 }}"
143-
rescue:
144-
- name: failed count + 1
145-
set_fact:
146-
failed_counter: "{{ failed_counter | int + 1 }}"
147-
148-
# case: check fallback log
149-
- name: fallback log should be found here
150-
block:
151168
- name: fallback log should be found here
152-
command: journalctl -b -0 -u greenboot -u greenboot-healthcheck
169+
command: journalctl -b -0 -u greenboot -u greenboot-healthcheck -u greenboot-rpm-ostree-grub2-check-fallback -u greenboot-grub2-set-counter -u greenboot-grub2-set-success -u greenboot-status -u redboot -u redboot-auto-reboot -u redboot.target
153170
become: yes
154171
register: result_greenboot_log
155172

156173
- assert:
157174
that:
158-
- "'FALLBACK BOOT DETECTED! Default bootc deployment has been rolled back' in result_greenboot_log.stdout"
175+
- "'FALLBACK BOOT DETECTED! Default rpm-ostree deployment has been rolled back' in result_greenboot_log.stdout"
176+
- "'Script \\'00_required_scripts_start.sh\\' SUCCESS' in result_greenboot_log.stdout"
177+
- "'Script \\'00_wanted_scripts_start.sh\\' SUCCESS' in result_greenboot_log.stdout"
178+
- "'greenboot Health Checks Runner' in result_greenboot_log.stdout"
179+
- "'Mark boot as successful in grubenv' in result_greenboot_log.stdout"
180+
- "'Boot Status is GREEN - Health Check SUCCESS' in result_greenboot_log.stdout"
181+
- "'greenboot MotD Generator' in result_greenboot_log.stdout"
159182
fail_msg: "Fallback log not found"
160183
success_msg: "Found fallback log"
161184

@@ -166,137 +189,18 @@
166189
- name: failed count + 1
167190
set_fact:
168191
failed_counter: "{{ failed_counter | int + 1 }}"
192+
when: result_rollback is succeeded
169193

170-
# case: check disable health checks
171-
- name: check disable health checks
172-
block:
173-
- name: disable health checks log should be found here
174-
shell: journalctl -b -0 -u greenboot -u greenboot-healthcheck
175-
become: yes
176-
register: result_disable
177-
178-
- assert:
179-
that:
180-
- "'Skipping disabled script: 01_repository_dns_check.sh' in result_disable.stdout"
181-
- "'The following disabled scripts were not found in any directory: [\"not_exit.sh\"]' in result_disable.stdout"
182-
fail_msg: "Disable health checks log not found"
183-
success_msg: "Found disable health checks log"
184-
185-
always:
186-
- set_fact:
187-
total_counter: "{{ total_counter | int + 1 }}"
188-
rescue:
189-
- name: failed count + 1
190-
set_fact:
191-
failed_counter: "{{ failed_counter | int + 1 }}"
192-
193-
# case: fail early for any required script failure
194-
- name: check greenboot fail early for any required script failure
195-
block:
196-
- name: fail early log should be found here
197-
shell: journalctl -u greenboot-healthcheck.service
198-
become: yes
199-
register: result_early
200-
201-
- assert:
202-
that:
203-
- "'Greenboot error: required health-check failed, skipping remaining scripts' in result_early.stdout"
204-
fail_msg: "Fail early health checks log not found"
205-
success_msg: "Found fail early checks log"
206-
207-
always:
208-
- set_fact:
209-
total_counter: "{{ total_counter | int + 1 }}"
210-
rescue:
211-
- name: failed count + 1
212-
set_fact:
213-
failed_counter: "{{ failed_counter | int + 1 }}"
214-
215-
# case: check binary file support
216-
- name: check binary file support
217-
block:
218-
- name: binary file check result should be found here
219-
shell: journalctl -b -0 -u greenboot -u greenboot-healthcheck
220-
become: yes
221-
register: result_binary
222-
223-
- assert:
224-
that:
225-
- "'required script /etc/greenboot/check/required.d/passing_binary success!' in result_binary.stdout"
226-
- "'wanted script /etc/greenboot/check/wanted.d/failing_binary failed!' in result_binary.stdout"
227-
fail_msg: "Binary file check log not found"
228-
success_msg: "Found binary file check log"
229-
230-
always:
231-
- set_fact:
232-
total_counter: "{{ total_counter | int + 1 }}"
233-
rescue:
234-
- name: failed count + 1
235-
set_fact:
236-
failed_counter: "{{ failed_counter | int + 1 }}"
237-
238-
# case: check for red.d scripts and binaries running, both passing and failing
239-
- name: check red script execution after failed boot
240-
block:
241-
- name: red script execution logs should be found here after failed boot
242-
shell: journalctl -u greenboot-healthcheck.service
243-
become: yes
244-
register: result_red_scripts
245-
246-
- assert:
247-
that:
248-
- "'red script /etc/greenboot/red.d/passing_binary success!' in result_red_scripts.stdout"
249-
- "'red script /etc/greenboot/red.d/failing_binary failed!' in result_red_scripts.stdout"
250-
- "'red script /etc/greenboot/red.d/passing_script.sh success!' in result_red_scripts.stdout"
251-
- "'red script /etc/greenboot/red.d/failing_script.sh failed!' in result_red_scripts.stdout"
252-
fail_msg: "Red script execution logs not found"
253-
success_msg: "Found red script execution logs"
254-
255-
always:
256-
- set_fact:
257-
total_counter: "{{ total_counter | int + 1 }}"
258-
rescue:
259-
- name: failed count + 1
260-
set_fact:
261-
failed_counter: "{{ failed_counter | int + 1 }}"
262-
263-
# case: check for green.d scripts and binaries running, both passing and failing
264-
- name: check green script execution after successful boot
194+
# case: check boot-complete.target status
195+
- name: boot-complete.target should be active
265196
block:
266-
- name: green script execution logs should be found here after successful boot
267-
shell: journalctl -b -0 -u greenboot -u greenboot-healthcheck
197+
- name: check boot-complete.target
198+
command: systemctl --no-pager status boot-complete.target
268199
become: yes
269-
register: result_green_scripts
270-
271-
- assert:
272-
that:
273-
- "'green script /etc/greenboot/green.d/passing_binary success!' in result_green_scripts.stdout"
274-
- "'green script /etc/greenboot/green.d/failing_binary failed!' in result_green_scripts.stdout"
275-
- "'green script /etc/greenboot/green.d/passing_script.sh success!' in result_green_scripts.stdout"
276-
- "'green script /etc/greenboot/green.d/failing_script.sh failed!' in result_green_scripts.stdout"
277-
fail_msg: "Green script and binary execution logs not found"
278-
success_msg: "Found green script and binary execution logs"
279-
280-
always:
281-
- set_fact:
282-
total_counter: "{{ total_counter | int + 1 }}"
283-
rescue:
284-
- name: failed count + 1
285-
set_fact:
286-
failed_counter: "{{ failed_counter | int + 1 }}"
287-
288-
# case: check boot times
289-
- name: check boot times
290-
block:
291-
- name: check boot times
292-
shell: journalctl --list-boots | wc -l
293-
register: boot_time_log
294-
295-
- assert:
296-
that:
297-
- boot_time_log.stdout == '9'
298-
fail_msg: "boot times is not correct, please check configuration in /etc/greenboot/greenboot.conf"
299-
success_msg: "boot times is correct"
200+
register: result
201+
retries: 10
202+
delay: 60
203+
until: "'inactive' not in result.stdout"
300204

301205
always:
302206
- set_fact:

0 commit comments

Comments
 (0)