From 521ec16605baf133411c4a981fed682c5b0513f7 Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Mon, 10 Aug 2020 20:22:25 -0400 Subject: [PATCH] Add root reprovisioning tests Add two basic tests: one where we reprovision in place to ext4, and one where we reprovision onto a separate RAID1. --- .../filesystem-only/config.ign | 15 +++++++++ .../root-reprovision/filesystem-only/test.sh | 24 ++++++++++++++ tests/kola/root-reprovision/raid1/config.ign | 25 +++++++++++++++ tests/kola/root-reprovision/raid1/test.sh | 31 +++++++++++++++++++ 4 files changed, 95 insertions(+) create mode 100644 tests/kola/root-reprovision/filesystem-only/config.ign create mode 100755 tests/kola/root-reprovision/filesystem-only/test.sh create mode 100644 tests/kola/root-reprovision/raid1/config.ign create mode 100755 tests/kola/root-reprovision/raid1/test.sh diff --git a/tests/kola/root-reprovision/filesystem-only/config.ign b/tests/kola/root-reprovision/filesystem-only/config.ign new file mode 100644 index 0000000000..3784c8cbfe --- /dev/null +++ b/tests/kola/root-reprovision/filesystem-only/config.ign @@ -0,0 +1,15 @@ +{ + "ignition": { + "version": "3.0.0" + }, + "storage": { + "filesystems": [ + { + "device": "/dev/disk/by-label/root", + "wipeFilesystem": true, + "format": "ext4", + "label": "root" + } + ] + } +} diff --git a/tests/kola/root-reprovision/filesystem-only/test.sh b/tests/kola/root-reprovision/filesystem-only/test.sh new file mode 100755 index 0000000000..10b2faf8b8 --- /dev/null +++ b/tests/kola/root-reprovision/filesystem-only/test.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# kola: {"platforms": "qemu", "minMemory": 4096} +set -xeuo pipefail + +fstype=$(findmnt -nvr / -o FSTYPE) +[[ $fstype == ext4 ]] + +case "${AUTOPKGTEST_REBOOT_MARK:-}" in + "") + # check that the partition was grown + if [ ! -e /run/coreos-growpart.stamp ]; then + echo "coreos-growpart did not run" + exit 1 + fi + + # reboot once to sanity-check we can find root on second boot + /tmp/autopkgtest-reboot rebooted + ;; + + rebooted) + grep root=UUID= /proc/cmdline + ;; + *) echo "unexpected mark: ${AUTOPKGTEST_REBOOT_MARK}"; exit 1;; +esac diff --git a/tests/kola/root-reprovision/raid1/config.ign b/tests/kola/root-reprovision/raid1/config.ign new file mode 100644 index 0000000000..5eca597dc4 --- /dev/null +++ b/tests/kola/root-reprovision/raid1/config.ign @@ -0,0 +1,25 @@ +{ + "ignition": { + "version": "3.0.0" + }, + "storage": { + "raid": [ + { + "devices": [ + "/dev/disk/by-id/virtio-disk1", + "/dev/disk/by-id/virtio-disk2" + ], + "level": "raid1", + "name": "foobar" + } + ], + "filesystems": [ + { + "device": "/dev/md/foobar", + "format": "xfs", + "wipeFilesystem": true, + "label": "root" + } + ] + } +} diff --git a/tests/kola/root-reprovision/raid1/test.sh b/tests/kola/root-reprovision/raid1/test.sh new file mode 100755 index 0000000000..7ecc340e60 --- /dev/null +++ b/tests/kola/root-reprovision/raid1/test.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# kola: {"platforms": "qemu", "minMemory": 4096, "additionalDisks": ["5G", "5G"]} +set -xeuo pipefail + +srcdev=$(findmnt -nvr / -o SOURCE) +[[ ${srcdev} == $(realpath /dev/md/foobar) ]] + +blktype=$(lsblk -o TYPE "${srcdev}" --noheadings) +[[ ${blktype} == raid1 ]] + +fstype=$(findmnt -nvr / -o FSTYPE) +[[ ${fstype} == xfs ]] + +case "${AUTOPKGTEST_REBOOT_MARK:-}" in + "") + # check that growpart didn't run + if [ -e /run/coreos-growpart.stamp ]; then + echo "coreos-growpart ran" + exit 1 + 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.md.uuid= /proc/cmdline + ;; + *) echo "unexpected mark: ${AUTOPKGTEST_REBOOT_MARK}"; exit 1;; +esac