Skip to content

Commit 4b299bd

Browse files
author
Yi He
committed
add test case
1 parent 9b6f1d9 commit 4b299bd

4 files changed

Lines changed: 49 additions & 3 deletions

File tree

tests/greenboot-bootc-anaconda-iso.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,8 @@ podman push quay.io/${QUAY_USERNAME}/greenboot-bootc:${TEST_UUID}
330330
## Bootc upgrade and check if greenboot can rollback
331331
##
332332
###########################################################
333+
greenprint "Get /boot mount status"
334+
BOOT_MOUNT_STATUS=$(ssh "${SSH_OPTIONS[@]}" -i "${SSH_KEY}" ${EDGE_USER}@${GUEST_ADDRESS} "findmnt -r -o OPTIONS -n /boot | awk -F ',' '{print \$1}'")
333335
greenprint "Bootc upgrade and reboot"
334336
sudo ssh "${SSH_OPTIONS[@]}" -i "${SSH_KEY}" ${EDGE_USER}@${GUEST_ADDRESS} "echo ${EDGE_USER_PASSWORD} |sudo -S bootc upgrade"
335337
sudo ssh "${SSH_OPTIONS[@]}" -i "${SSH_KEY}" ${EDGE_USER}@${GUEST_ADDRESS} "echo ${EDGE_USER_PASSWORD} |nohup sudo -S systemctl reboot &>/dev/null & exit"
@@ -365,7 +367,7 @@ ansible_become_pass=${EDGE_USER_PASSWORD}
365367
EOF
366368

367369
# Test greenboot functionality
368-
ansible-playbook -v -i /${TEMPDIR}/inventory greenboot-bootc.yaml || RESULTS=0
370+
ansible-playbook -v -i /${TEMPDIR}/inventory -e boot_mount_status="${BOOT_MOUNT_STATUS}" greenboot-bootc.yaml || RESULTS=0
369371

370372
# Test result checking
371373
check_result

tests/greenboot-bootc-qcow2.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,8 @@ podman push quay.io/${QUAY_USERNAME}/greenboot-bootc:${TEST_UUID}
298298
## Bootc upgrade and check if greenboot can rollback
299299
##
300300
###########################################################
301+
greenprint "Get /boot mount status"
302+
BOOT_MOUNT_STATUS=$(ssh "${SSH_OPTIONS[@]}" -i "${SSH_KEY}" ${EDGE_USER}@${GUEST_ADDRESS} "findmnt -r -o OPTIONS -n /boot | awk -F ',' '{print \$1}'")
301303
greenprint "Bootc upgrade and reboot"
302304
sudo ssh "${SSH_OPTIONS[@]}" -i "${SSH_KEY}" ${EDGE_USER}@${GUEST_ADDRESS} "echo ${EDGE_USER_PASSWORD} |sudo -S bootc upgrade"
303305
sudo ssh "${SSH_OPTIONS[@]}" -i "${SSH_KEY}" ${EDGE_USER}@${GUEST_ADDRESS} "echo ${EDGE_USER_PASSWORD} |nohup sudo -S systemctl reboot &>/dev/null & exit"
@@ -333,7 +335,7 @@ ansible_become_pass=${EDGE_USER_PASSWORD}
333335
EOF
334336

335337
# Test greenboot functionality
336-
ansible-playbook -v -i ${TEMPDIR}/inventory greenboot-bootc.yaml || RESULTS=0
338+
ansible-playbook -v -i ${TEMPDIR}/inventory -e boot_mount_status="${BOOT_MOUNT_STATUS}" greenboot-bootc.yaml || RESULTS=0
337339

338340
# Test result checking
339341
check_result

tests/greenboot-bootc.yaml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
- hosts: greenboot_guest
33
become: no
44
vars:
5+
boot_mount_status: ""
56
total_counter: "0"
67
failed_counter: "0"
78

8-
99
tasks:
1010
# current target host's IP address
1111
- debug: var=ansible_all_ipv4_addresses
@@ -279,6 +279,25 @@
279279
set_fact:
280280
failed_counter: "{{ failed_counter | int + 1 }}"
281281

282+
- name: check /boot mount status after rollback
283+
shell: findmnt -r -o OPTIONS -n /boot | awk -F "," '{print $1}'
284+
register: result_boot_mount_after_rollback
285+
286+
- name: /boot status should be preserved
287+
block:
288+
- assert:
289+
that:
290+
- boot_mount_status == result_boot_mount_after_rollback.stdout
291+
fail_msg: "/boot status is not preserved"
292+
success_msg: "/boot status is preserved"
293+
always:
294+
- set_fact:
295+
total_counter: "{{ total_counter | int + 1 }}"
296+
rescue:
297+
- name: failed count + 1
298+
set_fact:
299+
failed_counter: "{{ failed_counter | int + 1 }}"
300+
282301
- assert:
283302
that:
284303
- failed_counter == "0"

tests/greenboot-ostree.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@
110110
set_fact:
111111
failed_counter: "{{ failed_counter | int + 1 }}"
112112

113+
- name: check /boot mount status
114+
shell: findmnt -r -o OPTIONS -n /boot | awk -F "," '{print $1}'
115+
register: result_boot_mount_before
116+
113117
# case: check rollback function if boot error found
114118
- name: install sanely failing health check unit to test red boot status behavior
115119
block:
@@ -231,6 +235,25 @@
231235
set_fact:
232236
failed_counter: "{{ failed_counter | int + 1 }}"
233237

238+
- name: check /boot mount status
239+
shell: findmnt -r -o OPTIONS -n /boot | awk -F "," '{print $1}'
240+
register: result_boot_mount_after
241+
242+
- name: /boot status should be preserved
243+
block:
244+
- assert:
245+
that:
246+
- result_boot_mount_before.stdout == result_boot_mount_after.stdout
247+
fail_msg: "/boot status is not preserved"
248+
success_msg: "/boot status is preserved"
249+
always:
250+
- set_fact:
251+
total_counter: "{{ total_counter | int + 1 }}"
252+
rescue:
253+
- name: failed count + 1
254+
set_fact:
255+
failed_counter: "{{ failed_counter | int + 1 }}"
256+
234257
- assert:
235258
that:
236259
- failed_counter == "0"

0 commit comments

Comments
 (0)