Skip to content

Commit

Permalink
tests/kola: move LUKS checks to shared file
Browse files Browse the repository at this point in the history
Prep for adding another LUKS where we want the same checks.
  • Loading branch information
jlebon committed Mar 22, 2023
1 parent 96e2f90 commit 5c90e83
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 44 deletions.
47 changes: 47 additions & 0 deletions tests/kola/root-reprovision/luks/data/luks-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
. $KOLA_EXT_DATA/commonlib.sh

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

blktype=$(lsblk -o TYPE "${srcdev}" --noheadings)
[[ ${blktype} == crypt ]]

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

rootflags=$(findmnt /sysroot -no OPTIONS)
if ! grep prjquota <<< "${rootflags}"; then
fatal "missing prjquota in root mount flags: ${rootflags}"
fi
ok "root mounted with prjquota"

# while we're here, sanity-check that boot is mounted by UUID
if ! systemctl cat boot.mount | grep -q What=/dev/disk/by-uuid; then
systemctl cat boot.mount
fatal "boot mounted not by UUID"
fi
ok "boot mounted by UUID"

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

# reboot once to sanity-check we can find root on second boot
/tmp/autopkgtest-reboot rebooted
;;

rebooted)
grep root=UUID= /proc/cmdline
grep rd.luks.name= /proc/cmdline
ok "found root kargs"

# while we're here, sanity-check that we have a boot=UUID karg too
grep boot=UUID= /proc/cmdline
ok "found boot karg"
;;
*) fatal "unexpected mark: ${AUTOPKGTEST_REBOOT_MARK}";;
esac
46 changes: 2 additions & 44 deletions tests/kola/root-reprovision/luks/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,48 +14,6 @@ set -xeuo pipefail

. $KOLA_EXT_DATA/commonlib.sh

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

blktype=$(lsblk -o TYPE "${srcdev}" --noheadings)
[[ ${blktype} == crypt ]]

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

rootflags=$(findmnt /sysroot -no OPTIONS)
if ! grep prjquota <<< "${rootflags}"; then
fatal "missing prjquota in root mount flags: ${rootflags}"
fi
ok "root mounted with prjquota"

# while we're here, sanity-check that boot is mounted by UUID
if ! systemctl cat boot.mount | grep -q What=/dev/disk/by-uuid; then
systemctl cat boot.mount
fatal "boot mounted not by UUID"
fi
ok "boot mounted by UUID"

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

# reboot once to sanity-check we can find root on second boot
/tmp/autopkgtest-reboot rebooted
;;

rebooted)
grep root=UUID= /proc/cmdline
grep rd.luks.name= /proc/cmdline
ok "found root kargs"

# while we're here, sanity-check that we have a boot=UUID karg too
grep boot=UUID= /proc/cmdline
ok "found boot karg"
;;
*) fatal "unexpected mark: ${AUTOPKGTEST_REBOOT_MARK}";;
esac
# run the tests
. $KOLA_EXT_DATA/luks-test.sh

0 comments on commit 5c90e83

Please sign in to comment.