This patch set is the follow up of patch set "Add lvm2 thin provision
support for kdump", it indroduces a selftest for lvm2 thinp.
v1 -> v2:
Removed the commented lines within lvm.conf, which making the file
size much smaller.
Tao Liu (3):
selftest: Add lvm2 thin provision for kdump test
selftest: Only iterate the .sh files for test execution
selftest: Add "-F qcow2" for qemu-img cmdline
tests/scripts/image-init-lib.sh | 2 +-
tests/scripts/run-test.sh | 4 +-
.../lvm2-thinp-kdump/0-local-lvm2-thinp.sh | 59 +++++++++++++++++++
.../testcases/lvm2-thinp-kdump/lvm.conf | 5 ++
4 files changed, 67 insertions(+), 3 deletions(-)
create mode 100755 tests/scripts/testcases/lvm2-thinp-kdump/0-local-lvm2-thinp.sh
create mode 100644 tests/scripts/testcases/lvm2-thinp-kdump/lvm.conf
--
2.33.1
Show replies by date
Signed-off-by: Tao Liu <ltao(a)redhat.com>
---
.../lvm2-thinp-kdump/0-local-lvm2-thinp.sh | 59 +++++++++++++++++++
.../testcases/lvm2-thinp-kdump/lvm.conf | 5 ++
2 files changed, 64 insertions(+)
create mode 100755 tests/scripts/testcases/lvm2-thinp-kdump/0-local-lvm2-thinp.sh
create mode 100644 tests/scripts/testcases/lvm2-thinp-kdump/lvm.conf
diff --git a/tests/scripts/testcases/lvm2-thinp-kdump/0-local-lvm2-thinp.sh
b/tests/scripts/testcases/lvm2-thinp-kdump/0-local-lvm2-thinp.sh
new file mode 100755
index 0000000..cec9ee9
--- /dev/null
+++ b/tests/scripts/testcases/lvm2-thinp-kdump/0-local-lvm2-thinp.sh
@@ -0,0 +1,59 @@
+on_build() {
+ TEST_DIR_PREFIX=/tmp/lvm_test.XXXXXX
+ # clear TEST_DIRs if any
+ rm -rf ${TEST_DIR_PREFIX%.*}.*
+ TEST_IMG="$(mktemp -d $TEST_DIR_PREFIX)/test.img"
+
+ img_inst_pkg "lvm2"
+ img_inst $TESTDIR/scripts/testcases/lvm2-thinp-kdump/lvm.conf /etc/lvm/
+ dd if=/dev/zero of=$TEST_IMG bs=300M count=1
+ # The test.img will be /dev/sdb
+ img_add_qemu_cmd "-hdb $TEST_IMG"
+}
+
+on_test() {
+ VG=vg00
+ LV_THINPOOL=thinpool
+ LV_VOLUME=thin
+ VMCORE_PATH=var/crash
+
+ local boot_count=$(get_test_boot_count)
+
+ if [ $boot_count -eq 1 ]; then
+
+ vgcreate $VG /dev/sdb
+ # Create a small thinpool which is definitely not enough for
+ # vmcore, then create a thin volume which is definitely enough
+ # for vmcore, so we can make sure thinpool should be autoextend
+ # during runtime.
+ lvcreate -L 10M -T $VG/$LV_THINPOOL
+ lvcreate -V 300M -T $VG/$LV_THINPOOL -n $LV_VOLUME
+ mkfs.ext4 /dev/$VG/$LV_VOLUME
+ mount /dev/$VG/$LV_VOLUME /mnt
+ mkdir -p /mnt/$VMCORE_PATH
+
+ cat << EOF > /etc/kdump.conf
+ext4 /dev/$VG/$LV_VOLUME
+path /$VMCORE_PATH
+core_collector makedumpfile -l --message-level 7 -d 31
+EOF
+ kdumpctl start || test_failed "Failed to start kdump"
+
+ sync
+
+ echo 1 > /proc/sys/kernel/sysrq
+ echo c > /proc/sysrq-trigger
+
+ elif [ $boot_count -eq 2 ]; then
+ mount /dev/$VG/$LV_VOLUME /mnt
+ if has_valid_vmcore_dir /mnt/$VMCORE_PATH; then
+ test_passed
+ else
+ test_failed "Vmcore missing"
+ fi
+
+ shutdown -h 0
+ else
+ test_failed "Unexpected reboot"
+ fi
+}
diff --git a/tests/scripts/testcases/lvm2-thinp-kdump/lvm.conf
b/tests/scripts/testcases/lvm2-thinp-kdump/lvm.conf
new file mode 100644
index 0000000..4d81fbd
--- /dev/null
+++ b/tests/scripts/testcases/lvm2-thinp-kdump/lvm.conf
@@ -0,0 +1,5 @@
+activation {
+ thin_pool_autoextend_threshold = 70
+ thin_pool_autoextend_percent = 20
+ monitoring = 1
+}
\ No newline at end of file
--
2.33.1
Previously, all files within $TESTCASEDIR/$test_case are regarded
as shell script files for testing. However there might be config
files under the directory. So let's only iterate the .sh files.
Signed-off-by: Tao Liu <ltao(a)redhat.com>
---
tests/scripts/run-test.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/scripts/run-test.sh b/tests/scripts/run-test.sh
index 1501db4..68df5fd 100755
--- a/tests/scripts/run-test.sh
+++ b/tests/scripts/run-test.sh
@@ -85,8 +85,8 @@ for test_case in $testcases; do
results[$test_case]="<Test Skipped>"
testdir=$TESTCASEDIR/$test_case
- script_num=$(ls -1 $testdir | wc -l)
- scripts=$(ls -r -1 $testdir | tr '\n' ' ')
+ script_num=$(ls -1 $testdir | egrep "\.sh$" | wc -l)
+ scripts=$(ls -r -1 $testdir | egrep "\.sh$" | tr '\n' ' ')
test_outputs=""
read main_script aux_script <<< "$scripts"
--
2.33.1
Without the "-F qcow2" parameter, the qemu-img will error
with "Backing file specified without backing format". Let's
add to suppress it.
Signed-off-by: Tao Liu <ltao(a)redhat.com>
---
tests/scripts/image-init-lib.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/scripts/image-init-lib.sh b/tests/scripts/image-init-lib.sh
index 0a1524b..f905c69 100644
--- a/tests/scripts/image-init-lib.sh
+++ b/tests/scripts/image-init-lib.sh
@@ -240,7 +240,7 @@ create_image_from_base_image() {
if [ "$image_fmt" != "raw" ]; then
if fmt_is_qcow2 "$image_fmt"; then
echo "Source image is qcow2, using snapshot..."
- qemu-img create -f qcow2 -b $image $output
+ qemu-img create -f qcow2 -F qcow2 -b $image $output
else
perror_exit "Unrecognized base image format '$image_mnt'"
fi
--
2.33.1