|
34 | 34 | failed_counter: "{{ failed_counter | int + 1 }}" |
35 | 35 |
|
36 | 36 | # case: check greenboot* services |
37 | | - - name: greenboot healthcheck service should be enabled |
| 37 | + - name: a list of greenboot* service should be enabled |
38 | 38 | 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 |
41 | 41 | register: result_greenboot_service |
42 | 42 |
|
43 | 43 | - assert: |
44 | 44 | that: |
45 | | - - result_greenboot_service.stdout == 'enabled' |
| 45 | + - result_greenboot_service.stdout == 'enabled\nenabled\nenabled\nenabled\nenabled\nenabled\nenabled\nenabled' |
46 | 46 | fail_msg: "at least one greenboot service is not enabled" |
47 | 47 | success_msg: "greenboot services are enabled" |
48 | 48 | always: |
|
53 | 53 | set_fact: |
54 | 54 | failed_counter: "{{ failed_counter | int + 1 }}" |
55 | 55 |
|
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 |
58 | 58 | 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 |
62 | 72 |
|
63 | 73 | - assert: |
64 | 74 | 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 | + |
68 | 84 | always: |
69 | 85 | - set_fact: |
70 | 86 | total_counter: "{{ total_counter | int + 1 }}" |
|
73 | 89 | set_fact: |
74 | 90 | failed_counter: "{{ failed_counter | int + 1 }}" |
75 | 91 |
|
76 | | - # case: configure greenboot |
77 | | - - name: configure greenboot |
| 92 | + # case: check grubenv variables |
| 93 | + - name: grubenv variables should contain boot_success=1 |
78 | 94 | 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 |
81 | 98 | become: yes |
82 | 99 |
|
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 }}" |
86 | 112 |
|
87 | 113 | # case: check rollback function if boot error found |
88 | 114 | - name: install sanely failing health check unit to test red boot status behavior |
|
126 | 152 | set_fact: |
127 | 153 | failed_counter: "{{ failed_counter | int + 1 }}" |
128 | 154 |
|
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 |
131 | 157 | block: |
| 158 | + # check service/target status instead of string matching messages |
132 | 159 | - name: check boot-complete.target |
| 160 | + # will fail if the target was not reached |
133 | 161 | command: systemctl --no-pager status boot-complete.target |
134 | 162 | become: yes |
135 | 163 | register: result |
136 | 164 | retries: 10 |
137 | 165 | delay: 60 |
138 | 166 | until: "'inactive' not in result.stdout" |
139 | 167 |
|
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: |
151 | 168 | - 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 |
153 | 170 | become: yes |
154 | 171 | register: result_greenboot_log |
155 | 172 |
|
156 | 173 | - assert: |
157 | 174 | 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" |
159 | 182 | fail_msg: "Fallback log not found" |
160 | 183 | success_msg: "Found fallback log" |
161 | 184 |
|
|
166 | 189 | - name: failed count + 1 |
167 | 190 | set_fact: |
168 | 191 | failed_counter: "{{ failed_counter | int + 1 }}" |
| 192 | + when: result_rollback is succeeded |
169 | 193 |
|
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 |
265 | 196 | 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 |
268 | 199 | 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" |
300 | 204 |
|
301 | 205 | always: |
302 | 206 | - set_fact: |
|
0 commit comments