|
Harald Hoyer |
131b95 |
From 61a02caca422ddca0ee7c71e63d3cdfd786293c8 Mon Sep 17 00:00:00 2001
|
|
Harald Hoyer |
131b95 |
From: Harald Hoyer <harald@redhat.com>
|
|
Harald Hoyer |
131b95 |
Date: Mon, 16 Dec 2013 13:15:48 +0100
|
|
Harald Hoyer |
131b95 |
Subject: [PATCH] test/TEST-17-LVM-THIN: add test case for lvm thin pools
|
|
Harald Hoyer |
131b95 |
|
|
Harald Hoyer |
131b95 |
---
|
|
Harald Hoyer |
131b95 |
test/TEST-17-LVM-THIN/.testdir | 1 +
|
|
Harald Hoyer |
131b95 |
test/TEST-17-LVM-THIN/99-idesymlinks.rules | 8 +++
|
|
Harald Hoyer |
131b95 |
test/TEST-17-LVM-THIN/Makefile | 10 ++++
|
|
Harald Hoyer |
131b95 |
test/TEST-17-LVM-THIN/create-root.sh | 31 +++++++++++
|
|
Harald Hoyer |
131b95 |
test/TEST-17-LVM-THIN/finished-false.sh | 2 +
|
|
Harald Hoyer |
131b95 |
test/TEST-17-LVM-THIN/hard-off.sh | 3 +
|
|
Harald Hoyer |
131b95 |
test/TEST-17-LVM-THIN/test-init.sh | 17 ++++++
|
|
Harald Hoyer |
131b95 |
test/TEST-17-LVM-THIN/test.sh | 88 ++++++++++++++++++++++++++++++
|
|
Harald Hoyer |
131b95 |
8 files changed, 160 insertions(+)
|
|
Harald Hoyer |
131b95 |
create mode 100644 test/TEST-17-LVM-THIN/.testdir
|
|
Harald Hoyer |
131b95 |
create mode 100644 test/TEST-17-LVM-THIN/99-idesymlinks.rules
|
|
Harald Hoyer |
131b95 |
create mode 100644 test/TEST-17-LVM-THIN/Makefile
|
|
Harald Hoyer |
131b95 |
create mode 100755 test/TEST-17-LVM-THIN/create-root.sh
|
|
Harald Hoyer |
131b95 |
create mode 100755 test/TEST-17-LVM-THIN/finished-false.sh
|
|
Harald Hoyer |
131b95 |
create mode 100755 test/TEST-17-LVM-THIN/hard-off.sh
|
|
Harald Hoyer |
131b95 |
create mode 100755 test/TEST-17-LVM-THIN/test-init.sh
|
|
Harald Hoyer |
131b95 |
create mode 100755 test/TEST-17-LVM-THIN/test.sh
|
|
Harald Hoyer |
131b95 |
|
|
Harald Hoyer |
131b95 |
diff --git a/test/TEST-17-LVM-THIN/.testdir b/test/TEST-17-LVM-THIN/.testdir
|
|
Harald Hoyer |
131b95 |
new file mode 100644
|
|
Harald Hoyer |
131b95 |
index 0000000..9af2638
|
|
Harald Hoyer |
131b95 |
--- /dev/null
|
|
Harald Hoyer |
131b95 |
+++ b/test/TEST-17-LVM-THIN/.testdir
|
|
Harald Hoyer |
131b95 |
@@ -0,0 +1 @@
|
|
Harald Hoyer |
131b95 |
+TESTDIR="/var/tmp/dracut-test.uElZSK"
|
|
Harald Hoyer |
131b95 |
diff --git a/test/TEST-17-LVM-THIN/99-idesymlinks.rules b/test/TEST-17-LVM-THIN/99-idesymlinks.rules
|
|
Harald Hoyer |
131b95 |
new file mode 100644
|
|
Harald Hoyer |
131b95 |
index 0000000..d557790
|
|
Harald Hoyer |
131b95 |
--- /dev/null
|
|
Harald Hoyer |
131b95 |
+++ b/test/TEST-17-LVM-THIN/99-idesymlinks.rules
|
|
Harald Hoyer |
131b95 |
@@ -0,0 +1,8 @@
|
|
Harald Hoyer |
131b95 |
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hda", SYMLINK+="sda"
|
|
Harald Hoyer |
131b95 |
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hda*", SYMLINK+="sda$env{MINOR}"
|
|
Harald Hoyer |
131b95 |
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdb", SYMLINK+="sdb"
|
|
Harald Hoyer |
131b95 |
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdb*", SYMLINK+="sdb$env{MINOR}"
|
|
Harald Hoyer |
131b95 |
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdc", SYMLINK+="sdc"
|
|
Harald Hoyer |
131b95 |
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdc*", SYMLINK+="sdc$env{MINOR}"
|
|
Harald Hoyer |
131b95 |
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdd", SYMLINK+="sdd"
|
|
Harald Hoyer |
131b95 |
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdd*", SYMLINK+="sdd$env{MINOR}"
|
|
Harald Hoyer |
131b95 |
diff --git a/test/TEST-17-LVM-THIN/Makefile b/test/TEST-17-LVM-THIN/Makefile
|
|
Harald Hoyer |
131b95 |
new file mode 100644
|
|
Harald Hoyer |
131b95 |
index 0000000..aad2705
|
|
Harald Hoyer |
131b95 |
--- /dev/null
|
|
Harald Hoyer |
131b95 |
+++ b/test/TEST-17-LVM-THIN/Makefile
|
|
Harald Hoyer |
131b95 |
@@ -0,0 +1,10 @@
|
|
Harald Hoyer |
131b95 |
+all:
|
|
Harald Hoyer |
131b95 |
+ @$(MAKE) -s --no-print-directory -C ../.. all
|
|
Harald Hoyer |
131b95 |
+ @V=$(V) basedir=../.. testdir=../ ./test.sh --all
|
|
Harald Hoyer |
131b95 |
+setup:
|
|
Harald Hoyer |
131b95 |
+ @$(MAKE) --no-print-directory -C ../.. all
|
|
Harald Hoyer |
131b95 |
+ @basedir=../.. testdir=../ ./test.sh --setup
|
|
Harald Hoyer |
131b95 |
+clean:
|
|
Harald Hoyer |
131b95 |
+ @basedir=../.. testdir=../ ./test.sh --clean
|
|
Harald Hoyer |
131b95 |
+run:
|
|
Harald Hoyer |
131b95 |
+ @basedir=../.. testdir=../ ./test.sh --run
|
|
Harald Hoyer |
131b95 |
diff --git a/test/TEST-17-LVM-THIN/create-root.sh b/test/TEST-17-LVM-THIN/create-root.sh
|
|
Harald Hoyer |
131b95 |
new file mode 100755
|
|
Harald Hoyer |
131b95 |
index 0000000..740704f
|
|
Harald Hoyer |
131b95 |
--- /dev/null
|
|
Harald Hoyer |
131b95 |
+++ b/test/TEST-17-LVM-THIN/create-root.sh
|
|
Harald Hoyer |
131b95 |
@@ -0,0 +1,31 @@
|
|
Harald Hoyer |
131b95 |
+#!/bin/sh
|
|
Harald Hoyer |
131b95 |
+# don't let udev and this script step on eachother's toes
|
|
Harald Hoyer |
131b95 |
+for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
|
|
Harald Hoyer |
131b95 |
+ > "/etc/udev/rules.d/$x"
|
|
Harald Hoyer |
131b95 |
+done
|
|
Harald Hoyer |
131b95 |
+rm -f -- /etc/lvm/lvm.conf
|
|
Harald Hoyer |
131b95 |
+udevadm control --reload
|
|
Harald Hoyer |
131b95 |
+# save a partition at the beginning for future flagging purposes
|
|
Harald Hoyer |
131b95 |
+sfdisk -C 2560 -H 2 -S 32 -L /dev/sda <
|
|
Harald Hoyer |
131b95 |
+,1
|
|
Harald Hoyer |
131b95 |
+,800
|
|
Harald Hoyer |
131b95 |
+,800
|
|
Harald Hoyer |
131b95 |
+,800
|
|
Harald Hoyer |
131b95 |
+EOF
|
|
Harald Hoyer |
131b95 |
+for i in sda2 sda3 sda4; do
|
|
Harald Hoyer |
131b95 |
+lvm pvcreate -ff -y /dev/$i ;
|
|
Harald Hoyer |
131b95 |
+done && \
|
|
Harald Hoyer |
131b95 |
+lvm vgcreate dracut /dev/sda[234] && \
|
|
Harald Hoyer |
131b95 |
+lvm lvcreate -l 16 -T dracut/mythinpool && \
|
|
Harald Hoyer |
131b95 |
+lvm lvcreate -V1G -T dracut/mythinpool -n root && \
|
|
Harald Hoyer |
131b95 |
+lvm vgchange -ay && \
|
|
Harald Hoyer |
131b95 |
+mke2fs /dev/dracut/root && \
|
|
Harald Hoyer |
131b95 |
+mkdir -p /sysroot && \
|
|
Harald Hoyer |
131b95 |
+mount /dev/dracut/root /sysroot && \
|
|
Harald Hoyer |
131b95 |
+cp -a -t /sysroot /source/* && \
|
|
Harald Hoyer |
131b95 |
+umount /sysroot && \
|
|
Harald Hoyer |
131b95 |
+sleep 1 && \
|
|
Harald Hoyer |
131b95 |
+lvm lvchange -a n /dev/dracut/root && \
|
|
Harald Hoyer |
131b95 |
+sleep 1 && \
|
|
Harald Hoyer |
131b95 |
+echo "dracut-root-block-created" >/dev/sda1
|
|
Harald Hoyer |
131b95 |
+poweroff -f
|
|
Harald Hoyer |
131b95 |
diff --git a/test/TEST-17-LVM-THIN/finished-false.sh b/test/TEST-17-LVM-THIN/finished-false.sh
|
|
Harald Hoyer |
131b95 |
new file mode 100755
|
|
Harald Hoyer |
131b95 |
index 0000000..ecdbef9
|
|
Harald Hoyer |
131b95 |
--- /dev/null
|
|
Harald Hoyer |
131b95 |
+++ b/test/TEST-17-LVM-THIN/finished-false.sh
|
|
Harald Hoyer |
131b95 |
@@ -0,0 +1,2 @@
|
|
Harald Hoyer |
131b95 |
+#!/bin/sh
|
|
Harald Hoyer |
131b95 |
+exit 1
|
|
Harald Hoyer |
131b95 |
diff --git a/test/TEST-17-LVM-THIN/hard-off.sh b/test/TEST-17-LVM-THIN/hard-off.sh
|
|
Harald Hoyer |
131b95 |
new file mode 100755
|
|
Harald Hoyer |
131b95 |
index 0000000..12c3d5a
|
|
Harald Hoyer |
131b95 |
--- /dev/null
|
|
Harald Hoyer |
131b95 |
+++ b/test/TEST-17-LVM-THIN/hard-off.sh
|
|
Harald Hoyer |
131b95 |
@@ -0,0 +1,3 @@
|
|
Harald Hoyer |
131b95 |
+#!/bin/sh
|
|
Harald Hoyer |
131b95 |
+getarg rd.shell || poweroff -f
|
|
Harald Hoyer |
131b95 |
+getarg failme && poweroff -f
|
|
Harald Hoyer |
131b95 |
diff --git a/test/TEST-17-LVM-THIN/test-init.sh b/test/TEST-17-LVM-THIN/test-init.sh
|
|
Harald Hoyer |
131b95 |
new file mode 100755
|
|
Harald Hoyer |
131b95 |
index 0000000..fd03aa5
|
|
Harald Hoyer |
131b95 |
--- /dev/null
|
|
Harald Hoyer |
131b95 |
+++ b/test/TEST-17-LVM-THIN/test-init.sh
|
|
Harald Hoyer |
131b95 |
@@ -0,0 +1,17 @@
|
|
Harald Hoyer |
131b95 |
+#!/bin/sh
|
|
Harald Hoyer |
131b95 |
+export PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
|
Harald Hoyer |
131b95 |
+strstr() { [ "${1#*$2*}" != "$1" ]; }
|
|
Harald Hoyer |
131b95 |
+CMDLINE=$(while read line; do echo $line;done < /proc/cmdline)
|
|
Harald Hoyer |
131b95 |
+plymouth --quit
|
|
Harald Hoyer |
131b95 |
+exec >/dev/console 2>&1
|
|
Harald Hoyer |
131b95 |
+echo "dracut-root-block-success" >/dev/sda1
|
|
Harald Hoyer |
131b95 |
+export TERM=linux
|
|
Harald Hoyer |
131b95 |
+export PS1='initramfs-test:\w\$ '
|
|
Harald Hoyer |
131b95 |
+[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab
|
|
Harald Hoyer |
131b95 |
+[ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab
|
|
Harald Hoyer |
131b95 |
+stty sane
|
|
Harald Hoyer |
131b95 |
+echo "made it to the rootfs!"
|
|
Harald Hoyer |
131b95 |
+strstr "$CMDLINE" "rd.shell" && sh -i
|
|
Harald Hoyer |
131b95 |
+echo "Powering down."
|
|
Harald Hoyer |
131b95 |
+mount -n -o remount,ro /
|
|
Harald Hoyer |
131b95 |
+poweroff -f
|
|
Harald Hoyer |
131b95 |
diff --git a/test/TEST-17-LVM-THIN/test.sh b/test/TEST-17-LVM-THIN/test.sh
|
|
Harald Hoyer |
131b95 |
new file mode 100755
|
|
Harald Hoyer |
131b95 |
index 0000000..0cfce19
|
|
Harald Hoyer |
131b95 |
--- /dev/null
|
|
Harald Hoyer |
131b95 |
+++ b/test/TEST-17-LVM-THIN/test.sh
|
|
Harald Hoyer |
131b95 |
@@ -0,0 +1,88 @@
|
|
Harald Hoyer |
131b95 |
+#!/bin/bash
|
|
Harald Hoyer |
131b95 |
+TEST_DESCRIPTION="root filesystem on LVM PV with thin pool"
|
|
Harald Hoyer |
131b95 |
+
|
|
Harald Hoyer |
131b95 |
+KVERSION=${KVERSION-$(uname -r)}
|
|
Harald Hoyer |
131b95 |
+
|
|
Harald Hoyer |
131b95 |
+# Uncomment this to debug failures
|
|
Harald Hoyer |
131b95 |
+#DEBUGFAIL="rd.break rd.shell"
|
|
Harald Hoyer |
131b95 |
+
|
|
Harald Hoyer |
131b95 |
+test_run() {
|
|
Harald Hoyer |
131b95 |
+ $testdir/run-qemu \
|
|
Harald Hoyer |
131b95 |
+ -hda $TESTDIR/root.ext2 \
|
|
Harald Hoyer |
131b95 |
+ -m 256M -smp 2 -nographic \
|
|
Harald Hoyer |
131b95 |
+ -net none -kernel /boot/vmlinuz-$KVERSION \
|
|
Harald Hoyer |
131b95 |
+ -append "root=/dev/dracut/root rw rd.auto=1 quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \
|
|
Harald Hoyer |
131b95 |
+ -initrd $TESTDIR/initramfs.testing
|
|
Harald Hoyer |
131b95 |
+ grep -F -m 1 -q dracut-root-block-success $TESTDIR/root.ext2 || return 1
|
|
Harald Hoyer |
131b95 |
+}
|
|
Harald Hoyer |
131b95 |
+
|
|
Harald Hoyer |
131b95 |
+test_setup() {
|
|
Harald Hoyer |
131b95 |
+ # Create the blank file to use as a root filesystem
|
|
Harald Hoyer |
131b95 |
+ dd if=/dev/null of=$TESTDIR/root.ext2 bs=1M seek=80
|
|
Harald Hoyer |
131b95 |
+
|
|
Harald Hoyer |
131b95 |
+ kernel=$KVERSION
|
|
Harald Hoyer |
131b95 |
+ # Create what will eventually be our root filesystem onto an overlay
|
|
Harald Hoyer |
131b95 |
+ (
|
|
Harald Hoyer |
131b95 |
+ export initdir=$TESTDIR/overlay/source
|
|
Harald Hoyer |
131b95 |
+ . $basedir/dracut-functions.sh
|
|
Harald Hoyer |
131b95 |
+ inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip route \
|
|
Harald Hoyer |
131b95 |
+ mount dmesg ifconfig dhclient mkdir cp ping dhclient
|
|
Harald Hoyer |
131b95 |
+ for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
|
|
Harald Hoyer |
131b95 |
+ [ -f ${_terminfodir}/l/linux ] && break
|
|
Harald Hoyer |
131b95 |
+ done
|
|
Harald Hoyer |
131b95 |
+ inst_multiple -o ${_terminfodir}/l/linux
|
|
Harald Hoyer |
131b95 |
+ inst "$basedir/modules.d/40network/dhclient-script.sh" "/sbin/dhclient-script"
|
|
Harald Hoyer |
131b95 |
+ inst "$basedir/modules.d/40network/ifup.sh" "/sbin/ifup"
|
|
Harald Hoyer |
131b95 |
+ inst_multiple grep
|
|
Harald Hoyer |
131b95 |
+ inst_simple /etc/os-release
|
|
Harald Hoyer |
131b95 |
+ inst ./test-init.sh /sbin/init
|
|
Harald Hoyer |
131b95 |
+ find_binary plymouth >/dev/null && inst_multiple plymouth
|
|
Harald Hoyer |
131b95 |
+ (cd "$initdir"; mkdir -p dev sys proc etc var/run tmp )
|
|
Harald Hoyer |
131b95 |
+ cp -a /etc/ld.so.conf* $initdir/etc
|
|
Harald Hoyer |
131b95 |
+ mkdir $initdir/run
|
|
Harald Hoyer |
131b95 |
+ sudo ldconfig -r "$initdir"
|
|
Harald Hoyer |
131b95 |
+ )
|
|
Harald Hoyer |
131b95 |
+
|
|
Harald Hoyer |
131b95 |
+ # second, install the files needed to make the root filesystem
|
|
Harald Hoyer |
131b95 |
+ (
|
|
Harald Hoyer |
131b95 |
+ export initdir=$TESTDIR/overlay
|
|
Harald Hoyer |
131b95 |
+ . $basedir/dracut-functions.sh
|
|
Harald Hoyer |
131b95 |
+ inst_multiple sfdisk mke2fs poweroff cp umount
|
|
Harald Hoyer |
131b95 |
+ inst_hook initqueue 01 ./create-root.sh
|
|
Harald Hoyer |
131b95 |
+ inst_hook initqueue/finished 01 ./finished-false.sh
|
|
Harald Hoyer |
131b95 |
+ inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
|
|
Harald Hoyer |
131b95 |
+ )
|
|
Harald Hoyer |
131b95 |
+
|
|
Harald Hoyer |
131b95 |
+ # create an initramfs that will create the target root filesystem.
|
|
Harald Hoyer |
131b95 |
+ # We do it this way so that we do not risk trashing the host mdraid
|
|
Harald Hoyer |
131b95 |
+ # devices, volume groups, encrypted partitions, etc.
|
|
Harald Hoyer |
131b95 |
+ $basedir/dracut.sh -l -i $TESTDIR/overlay / \
|
|
Harald Hoyer |
131b95 |
+ -m "dash lvm mdraid udev-rules base rootfs-block kernel-modules" \
|
|
Harald Hoyer |
131b95 |
+ -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
|
|
Harald Hoyer |
131b95 |
+ -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
|
|
Harald Hoyer |
131b95 |
+ rm -rf -- $TESTDIR/overlay
|
|
Harald Hoyer |
131b95 |
+ # Invoke KVM and/or QEMU to actually create the target filesystem.
|
|
Harald Hoyer |
131b95 |
+ $testdir/run-qemu -hda $TESTDIR/root.ext2 -m 256M -smp 2 -nographic -net none \
|
|
Harald Hoyer |
131b95 |
+ -kernel "/boot/vmlinuz-$kernel" \
|
|
Harald Hoyer |
131b95 |
+ -append "root=/dev/fakeroot rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
|
|
Harald Hoyer |
131b95 |
+ -initrd $TESTDIR/initramfs.makeroot || return 1
|
|
Harald Hoyer |
131b95 |
+ grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.ext2 || return 1
|
|
Harald Hoyer |
131b95 |
+ (
|
|
Harald Hoyer |
131b95 |
+ export initdir=$TESTDIR/overlay
|
|
Harald Hoyer |
131b95 |
+ . $basedir/dracut-functions.sh
|
|
Harald Hoyer |
131b95 |
+ inst_multiple poweroff shutdown
|
|
Harald Hoyer |
131b95 |
+ inst_hook emergency 000 ./hard-off.sh
|
|
Harald Hoyer |
131b95 |
+ inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
|
|
Harald Hoyer |
131b95 |
+ )
|
|
Harald Hoyer |
131b95 |
+ sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
|
|
Harald Hoyer |
131b95 |
+ -o "plymouth network" \
|
|
Harald Hoyer |
131b95 |
+ -a "debug" -I lvs \
|
|
Harald Hoyer |
131b95 |
+ -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
|
|
Harald Hoyer |
131b95 |
+ -f $TESTDIR/initramfs.testing $KVERSION || return 1
|
|
Harald Hoyer |
131b95 |
+}
|
|
Harald Hoyer |
131b95 |
+
|
|
Harald Hoyer |
131b95 |
+test_cleanup() {
|
|
Harald Hoyer |
131b95 |
+ return 0
|
|
Harald Hoyer |
131b95 |
+}
|
|
Harald Hoyer |
131b95 |
+
|
|
Harald Hoyer |
131b95 |
+. $testdir/test-functions
|