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