From a2a69e9948b10d18d013d68f8f1b908c74dfaf0b Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 15 Aug 2024 13:51:59 -0400 Subject: [PATCH] tests: Attempt to update auto-prune test We need to look in the journal since https://github.com/ostreedev/ostree/pull/3282/commits/3d07a808ce9a764c98560279fc444d2e4fb901db Signed-off-by: Colin Walters --- tests/kolainst/destructive/auto-prune.sh | 55 ++++++++++++++++++------ 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/tests/kolainst/destructive/auto-prune.sh b/tests/kolainst/destructive/auto-prune.sh index 5081275e07..5223602ce5 100755 --- a/tests/kolainst/destructive/auto-prune.sh +++ b/tests/kolainst/destructive/auto-prune.sh @@ -5,6 +5,35 @@ set -xeuo pipefail . ${KOLA_EXT_DATA}/libinsttest.sh +journal_cursor() { + journalctl -o json -n 1 | jq -r '.["__CURSOR"]' +} + +assert_journal_grep() { + local cursor re + cursor=$1 + shift + re=$1 + shift + + if ! journalctl --after-cursor "${cursor}" --grep="$re" >/dev/null; then + fatal "failed to find in journal: $re"; exit 1 + fi +} + +assert_not_journal_grep() { + local cursor re + cursor=$1 + shift + re=$1 + shift + + if journalctl --after-cursor "${cursor}" --grep="$re"; then + fatal "found in journal: $re"; exit 1 + fi +} + + # make two fake ostree commits with modified kernels of about the same size cd /root mkdir -p rootfs/usr/lib/modules/`uname -r` @@ -44,11 +73,12 @@ assert_bootfs_has_n_bootcsum_dirs 1 # the booted deployment is never pruned, so this is a hopeless case and auto-pruning can't save us consume_bootfs_space rpm-ostree rebase :modkernel1 +cursor=$(journal_cursor) if ostree admin finalize-staged |& tee out.txt; then assert_not_reached "successfully wrote to filled up bootfs" fi -assert_file_has_content out.txt "Disabling auto-prune optimization; insufficient space left in bootfs" assert_file_has_content out.txt "No space left on device" +assert_journal_grep "${cursor}" "Disabling auto-prune optimization.*insufficient space" rm out.txt unconsume_bootfs_space rpm-ostree cleanup -bpr @@ -58,9 +88,9 @@ rpm-ostree cleanup -bpr assert_bootfs_has_n_bootcsum_dirs 1 rpm-ostree rebase :modkernel1 -ostree admin finalize-staged |& tee out.txt -assert_not_file_has_content out.txt "updating bootloader in two steps" -rm out.txt +cursor=$(journal_cursor) +ostree admin finalize-staged +assert_not_journal_grep "$cursor" "updating bootloader in two steps" # and put it in rollback position; this is the deployment that'll get auto-pruned rpm-ostree rollback @@ -86,9 +116,9 @@ assert_streq "$bootloader_orig" "$(sha256sum /boot/loader/entries/*)" # now, try again but with auto-pruning enabled rpm-ostree rebase :modkernel2 -ostree admin finalize-staged |& tee out.txt -assert_file_has_content out.txt "updating bootloader in two steps" -rm out.txt +cursor=$(journal_cursor) +ostree admin finalize-staged +assert_not_journal_grep "$cursor" "updating bootloader in two steps" assert_bootfs_has_n_bootcsum_dirs 2 assert_not_streq "$bootloader_orig" "$(sha256sum /boot/loader/entries/*)" @@ -130,9 +160,9 @@ rm out.txt # now, try again but with (now default) auto-pruning enabled rpm-ostree rebase :modkernel1 -ostree admin finalize-staged |& tee out.txt -assert_file_has_content out.txt "updating bootloader in two steps" -rm out.txt +cursor=$(journal_cursor) +ostree admin finalize-staged +assert_journal_grep "$cursor" "updating bootloader in two steps" # Below, we test that the size estimator is blocksize aware. This catches the # case where the dtb contains many small files such that there's a lot of wasted @@ -158,8 +188,9 @@ rm out.txt # now, try again but with (now default) auto-pruning enabled rpm-ostree rebase :modkernel3 -ostree admin finalize-staged |& tee out.txt -assert_file_has_content out.txt "updating bootloader in two steps" +cursor=$(journal_cursor) +ostree admin finalize-staged +assert_journal_grep "$cursor" "updating bootloader in two steps" rm out.txt echo "ok bootfs auto-prune"