Skip to content

Commit

Permalink
tests: add ignition.kargs.skipreboot test
Browse files Browse the repository at this point in the history
This test verifies that if a kernel argument that is set as "should_exist"
in the Ignition config already exists on the kernel command line of the machine
then we can skip the reboot when applying kernel arguments but we must still
update the BLS configs to make it permanent.
  • Loading branch information
dustymabe committed Feb 2, 2022
1 parent 65e8e55 commit 428d587
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/kola/ignition/kargs/skipreboot/config.bu
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
variant: fcos
version: 1.4.0
kernel_arguments:
should_exist:
- foobar
1 change: 1 addition & 0 deletions tests/kola/ignition/kargs/skipreboot/data/commonlib.sh
43 changes: 43 additions & 0 deletions tests/kola/ignition/kargs/skipreboot/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
set -xeuo pipefail
# kola: { "platforms": "qemu", "appendFirstbootKernelArgs": "foobar" }
# This test verifies that if a kernel argument that is set as "should_exist"
# in the Ignition config already exists on the kernel command line of the machine
# then we can skip the reboot when applying kernel arguments but we must still
# update the BLS configs to make it permanent. This is Scenario B from
# the documentation in 35coreos-ignition/coreos-kargs.sh.
#
# - platforms: qemu
# - appendFirstbootKernelArgs is only supported on qemu.
# - appendFirstbootKernelArgs: foobar
# - The kernel argument to apply transiently only on the first boot.

. $KOLA_EXT_DATA/commonlib.sh

kargchecks() {
if ! grep foobar /proc/cmdline; then
fatal "missing expected kernel arg in kernel cmdline"
fi
if ! grep foobar /boot/loader/entries/*.conf; then
fatal "missing expected kernel arg in BLS config"
fi
}

case "${AUTOPKGTEST_REBOOT_MARK:-}" in
"")
kargchecks
# If this file exists then reboot was skipped. See
# 35coreos-ignition/coreos-kargs.sh
if [ ! -e /run/coreos-kargs-changed ]; then
fatal "missing file that should exist if no reboot happened"
fi
# Now reboot the machine and verify the kernel argument persists
/tmp/autopkgtest-reboot nextboot
;;
nextboot)
kargchecks
;;
*) fatal "unexpected mark: ${AUTOPKGTEST_REBOOT_MARK}";;
esac

ok "Ignition kargs skip reboot"

0 comments on commit 428d587

Please sign in to comment.