From 428d5872adc2ccf516b54f47be3359d843a26f21 Mon Sep 17 00:00:00 2001 From: Dusty Mabe Date: Wed, 2 Feb 2022 13:23:50 -0500 Subject: [PATCH] tests: add ignition.kargs.skipreboot test 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. --- .../kola/ignition/kargs/skipreboot/config.bu | 5 +++ .../kargs/skipreboot/data/commonlib.sh | 1 + tests/kola/ignition/kargs/skipreboot/test.sh | 43 +++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 tests/kola/ignition/kargs/skipreboot/config.bu create mode 120000 tests/kola/ignition/kargs/skipreboot/data/commonlib.sh create mode 100755 tests/kola/ignition/kargs/skipreboot/test.sh diff --git a/tests/kola/ignition/kargs/skipreboot/config.bu b/tests/kola/ignition/kargs/skipreboot/config.bu new file mode 100644 index 0000000000..4c530b7fac --- /dev/null +++ b/tests/kola/ignition/kargs/skipreboot/config.bu @@ -0,0 +1,5 @@ +variant: fcos +version: 1.4.0 +kernel_arguments: + should_exist: + - foobar diff --git a/tests/kola/ignition/kargs/skipreboot/data/commonlib.sh b/tests/kola/ignition/kargs/skipreboot/data/commonlib.sh new file mode 120000 index 0000000000..7028449b11 --- /dev/null +++ b/tests/kola/ignition/kargs/skipreboot/data/commonlib.sh @@ -0,0 +1 @@ +../../../../data/commonlib.sh \ No newline at end of file diff --git a/tests/kola/ignition/kargs/skipreboot/test.sh b/tests/kola/ignition/kargs/skipreboot/test.sh new file mode 100755 index 0000000000..ab41bb423a --- /dev/null +++ b/tests/kola/ignition/kargs/skipreboot/test.sh @@ -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"