Skip to content

Commit

Permalink
Add root reprovisioning tests
Browse files Browse the repository at this point in the history
Add two basic tests: one where we reprovision in place to ext4, and one
where we reprovision onto a separate RAID1.
  • Loading branch information
jlebon committed Aug 18, 2020
1 parent 65f4b94 commit c02ddd4
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/kola/root-reprovision/filesystem-only/config.ign
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"ignition": {
"version": "3.0.0"
},
"storage": {
"filesystems": [
{
"device": "/dev/disk/by-label/root",
"wipeFilesystem": true,
"format": "ext4",
"label": "root"
}
]
}
}
24 changes: 24 additions & 0 deletions tests/kola/root-reprovision/filesystem-only/test.sh
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions tests/kola/root-reprovision/raid1/config.ign
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
}
31 changes: 31 additions & 0 deletions tests/kola/root-reprovision/raid1/test.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c02ddd4

Please sign in to comment.