tests: Port to Debian autopkgtest reboot API
authorColin Walters <walters@verbum.org>
Fri, 19 Jun 2020 12:55:33 +0000 (12:55 +0000)
committerColin Walters <walters@verbum.org>
Fri, 19 Jun 2020 13:04:22 +0000 (13:04 +0000)
See https://github.com/coreos/coreos-assembler/pull/1528

I think we can drop the old cosa reboot APIs after this,
though I've already forgotten where else I might have written
tests using it.

tests/kolainst/destructive/staged-delay.sh
tests/kolainst/destructive/staged-deploy.sh
tests/kolainst/destructive/var-mount.sh
tests/kolainst/libinsttest.sh

index a320202fc15b0a5296543025fccc857ffcb4dfa3..5671bbea852888565a88ec525b7b7591576178cb 100755 (executable)
@@ -9,9 +9,8 @@ set -xeuo pipefail
 require_writable_sysroot
 prepare_tmpdir
 
-n=$(nth_boot)
-case "${n}" in
-1)
+case "${AUTOPKGTEST_REBOOT_MARK:-}" in
+"")
 dropin=/etc/systemd/system/ostree-finalize-staged.service.d/delay.conf
 mkdir -p $(dirname ${dropin})
 cat >"${dropin}" << 'EOF'
@@ -21,10 +20,10 @@ ExecStop=/bin/sh -c 'sleep 10 && if ! test -d /boot/loader/entries; then echo er
 EOF
 systemctl daemon-reload
 rpm-ostree kargs --append=somedummykarg=1
-kola_reboot
+/tmp/autopkgtest-reboot 2
 ;;
 
-2)
+"2")
 journalctl -b -1 -u ostree-finalize-staged > logs.txt
 assert_file_has_content_literal logs.txt 'ostree-finalize-staged found /boot/loader/entries'
 # older systemd doesn't output the success message
@@ -36,5 +35,6 @@ else
 fi
 assert_file_has_content_literal /proc/cmdline somedummykarg=1 
 ;;
+*) fatal "Unexpected AUTOPKGTEST_REBOOT_MARK=${AUTOPKGTEST_REBOOT_MARK}" ;;
 esac
 echo ok
index cc3e7a7ed5591b5e11e6336b5530ea36bcd69fa1..a5da0119b538b3cef4282222004a526c1242e74c 100755 (executable)
@@ -6,9 +6,8 @@ set -xeuo pipefail
 require_writable_sysroot
 prepare_tmpdir
 
-n=$(nth_boot)
-case "${n}" in
-  1)
+case "${AUTOPKGTEST_REBOOT_MARK:-}" in
+  "")
   # Initial cleanup to handle the cosa fast-build case
     ## TODO remove workaround for https://github.com/coreos/rpm-ostree/pull/2021
     mkdir -p /var/lib/rpm-ostree/history
@@ -48,9 +47,9 @@ case "${n}" in
       fatal "Pinned staged deployment"
     fi
     assert_file_has_content err.txt 'Cannot pin staged deployment'
-    kola_reboot
+    /tmp/autopkgtest-reboot "2"
     ;;
-  2
+  "2"
     # Check that deploy-staged service worked
     rpm-ostree status
     # Assert that the previous boot had a journal entry for it
@@ -118,5 +117,5 @@ case "${n}" in
     ostree refs --delete staged-deploy nonstaged-deploy
     echo "ok cleanup refs"
     ;;
-  *) fatal "Unexpected boot count" ;;
+  *) fatal "Unexpected AUTOPKGTEST_REBOOT_MARK=${AUTOPKGTEST_REBOOT_MARK}" ;;
 esac
index b3fe3d9800c1aba4dc906165ce9aa136d4793a80..86c69fd19a33a28ec2d44252d35a33cf7881c89d 100755 (executable)
@@ -4,20 +4,19 @@ set -xeuo pipefail
 
 . ${KOLA_EXT_DATA}/libinsttest.sh
 
-n=$(nth_boot)
-case "${n}" in
-  1) 
+case "${AUTOPKGTEST_REBOOT_MARK:-}" in
+  "") 
     require_writable_sysroot
     # Hack this off for now
     chattr -i /sysroot
     cp -a /var /sysroot/myvar
     touch /sysroot/myvar/somenewfile
     echo '/sysroot/myvar /var none bind 0 0' >> /etc/fstab
-    kola_reboot
+    /tmp/autopkgtest-reboot "2"
     ;;
-  2)
+  "2")
     systemctl status var.mount
     test -f /var/somenewfile
     ;;
-  *) fatal "Unexpected boot count $n"
+  *) fatal "Unexpected AUTOPKGTEST_REBOOT_MARK=${AUTOPKGTEST_REBOOT_MARK}" ;;
 esac
index 2552cf78385800ecc8faa341d6918509bb8584c0..bf40a2852cf78530b85c02582a9eb8c71ef63dca 100644 (file)
@@ -66,13 +66,6 @@ nth_boot() {
     journalctl --list-boots | wc -l
 }
 
-kola_reboot() {
-    kill -TERM $$
-    sleep 2m
-    echo "failed to reboot?" 1>&2
-    exit 1
-}
-
 # Determine our origin refspec - we'll use this as a test base
 rpmostree=$(which rpm-ostree 2>/dev/null)
 if test -z "${rpmostree}"; then