From 52d6f4e790787392e9e2246f3c552349fce5cca7 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 23 Jun 2022 17:23:45 -0400 Subject: [PATCH] tests/staged-deploy.sh: Hack around cosa systemd unit check https://github.com/coreos/coreos-assembler/pull/2921 broke this test which is intentionally causing a systemd unit to fail. As they say, necessity is the mother of invention. They don't say though that need always causes particularly *beautiful* things to be invented... --- tests/kolainst/destructive/staged-deploy.sh | 22 +++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/tests/kolainst/destructive/staged-deploy.sh b/tests/kolainst/destructive/staged-deploy.sh index 7e1991bb..af31078a 100755 --- a/tests/kolainst/destructive/staged-deploy.sh +++ b/tests/kolainst/destructive/staged-deploy.sh @@ -150,13 +150,27 @@ EOF # Now finally, try breaking staged updates and verify that ostree-boot-complete fails on the next boot unshare -m /bin/sh -c 'mount -o remount,rw /boot; chattr +i /boot' rpm-ostree kargs --append=foo=bar + + # Hack around https://github.com/coreos/coreos-assembler/pull/2921#issuecomment-1156592723 + # where coreos-assembler/kola check systemd unit status right after ssh. + cat >/etc/systemd/system/hackaround-cosa-systemd-unit-checks.service << 'EOF' +[Unit] +Before=systemd-user-sessions.service + +[Service] +Type=oneshot +ExecStart=/bin/sh -c '(systemctl status ostree-boot-complete.service || true) | tee /run/ostree-boot-complete-status.txt' +ExecStart=/bin/systemctl reset-failed ostree-boot-complete.service + +[Install] +WantedBy=multi-user.target +EOF + systemctl enable hackaround-cosa-systemd-unit-checks.service + /tmp/autopkgtest-reboot "3" ;; "3") - (systemctl status ostree-boot-complete.service || true) | tee out.txt - assert_file_has_content out.txt 'error: ostree-finalize-staged.service failed on previous boot.*Operation not permitted' - systemctl show -p Result ostree-boot-complete.service > out.txt - assert_file_has_content out.txt='Result=exit-code' + assert_file_has_content /run/ostree-boot-complete-status.txt 'error: ostree-finalize-staged.service failed on previous boot.*Operation not permitted' echo "ok boot-complete.service" ;; *) fatal "Unexpected AUTOPKGTEST_REBOOT_MARK=${AUTOPKGTEST_REBOOT_MARK}" ;;