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