Skip to content

Commit

Permalink
tests/root-reprovision: use ok and fatal helpers
Browse files Browse the repository at this point in the history
We should have those in a shared shell library.
  • Loading branch information
jlebon committed Mar 19, 2021
1 parent b9dca27 commit 1b11322
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 9 deletions.
16 changes: 13 additions & 3 deletions tests/kola/root-reprovision/filesystem-only/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,24 @@
# kola: {"platforms": "qemu", "minMemory": 4096}
set -xeuo pipefail

ok() {
echo "ok" "$@"
}

fatal() {
echo "$@" >&2
exit 1
}

fstype=$(findmnt -nvr / -o FSTYPE)
[[ $fstype == ext4 ]]
ok "source is ext4"

case "${AUTOPKGTEST_REBOOT_MARK:-}" in
"")
# check that the partition was grown
if [ ! -e /run/ignition-ostree-growfs.stamp ]; then
echo "ignition-ostree-growfs did not run"
exit 1
fatal "ignition-ostree-growfs did not run"
fi

# reboot once to sanity-check we can find root on second boot
Expand All @@ -19,6 +28,7 @@ case "${AUTOPKGTEST_REBOOT_MARK:-}" in

rebooted)
grep root=UUID= /proc/cmdline
ok "found root karg"
;;
*) echo "unexpected mark: ${AUTOPKGTEST_REBOOT_MARK}"; exit 1;;
*) fatal "unexpected mark: ${AUTOPKGTEST_REBOOT_MARK}";;
esac
16 changes: 13 additions & 3 deletions tests/kola/root-reprovision/luks/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
# kola: {"platforms": "qemu", "minMemory": 4096, "architectures": "!s390x"}
set -xeuo pipefail

ok() {
echo "ok" "$@"
}

fatal() {
echo "$@" >&2
exit 1
}

srcdev=$(findmnt -nvr / -o SOURCE)
[[ ${srcdev} == /dev/mapper/myluksdev ]]

Expand All @@ -10,13 +19,13 @@ blktype=$(lsblk -o TYPE "${srcdev}" --noheadings)

fstype=$(findmnt -nvr / -o FSTYPE)
[[ ${fstype} == xfs ]]
ok "source is XFS on LUKS device"

case "${AUTOPKGTEST_REBOOT_MARK:-}" in
"")
# check that ignition-ostree-growfs ran
if [ ! -e /run/ignition-ostree-growfs.stamp ]; then
echo "ignition-ostree-growfs did not run"
exit 1
fatal "ignition-ostree-growfs did not run"
fi

# reboot once to sanity-check we can find root on second boot
Expand All @@ -26,6 +35,7 @@ case "${AUTOPKGTEST_REBOOT_MARK:-}" in
rebooted)
grep root=UUID= /proc/cmdline
grep rd.luks.name= /proc/cmdline
ok "found root kargs"
;;
*) echo "unexpected mark: ${AUTOPKGTEST_REBOOT_MARK}"; exit 1;;
*) fatal "unexpected mark: ${AUTOPKGTEST_REBOOT_MARK}";;
esac
16 changes: 13 additions & 3 deletions tests/kola/root-reprovision/raid1/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
# kola: {"platforms": "qemu", "minMemory": 4096, "additionalDisks": ["5G", "5G"]}
set -xeuo pipefail

ok() {
echo "ok" "$@"
}

fatal() {
echo "$@" >&2
exit 1
}

srcdev=$(findmnt -nvr / -o SOURCE)
[[ ${srcdev} == $(realpath /dev/md/foobar) ]]

Expand All @@ -10,13 +19,13 @@ blktype=$(lsblk -o TYPE "${srcdev}" --noheadings)

fstype=$(findmnt -nvr / -o FSTYPE)
[[ ${fstype} == xfs ]]
ok "source is XFS on RAID1 device"

case "${AUTOPKGTEST_REBOOT_MARK:-}" in
"")
# check that ignition-ostree-growfs didn't run
if [ -e /run/ignition-ostree-growfs.stamp ]; then
echo "ignition-ostree-growfs ran"
exit 1
fatal "ignition-ostree-growfs ran"
fi

# reboot once to sanity-check we can find root on second boot
Expand All @@ -26,6 +35,7 @@ case "${AUTOPKGTEST_REBOOT_MARK:-}" in
rebooted)
grep root=UUID= /proc/cmdline
grep rd.md.uuid= /proc/cmdline
ok "found root kargs"
;;
*) echo "unexpected mark: ${AUTOPKGTEST_REBOOT_MARK}"; exit 1;;
*) fatal "unexpected mark: ${AUTOPKGTEST_REBOOT_MARK}";;
esac

0 comments on commit 1b11322

Please sign in to comment.