[Libguestfs] [PATCH 4/4] Add test for virt-resize.
Richard W.M. Jones
rjones at redhat.com
Mon Sep 27 16:17:19 UTC 2010
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top
-------------- next part --------------
>From 7d14ce68915df10c4581b7adfcf49f1bcff33bf5 Mon Sep 17 00:00:00 2001
From: Richard W.M. Jones <rjones at redhat.com>
Date: Mon, 27 Sep 2010 17:06:14 +0100
Subject: [PATCH 4/4] Add test for virt-resize.
This tests a number of things which have caused problems for us:
- resizing PVs and LV content
- handling GPT format disks
- using qcow2 as a target disk format
- shrinking disk images
Note that the disk content is empty (not a real VM), but this is
adequate since all we want to test are the operations and calculations
done by virt-resize. We are not interested here in whether e2fsprogs
and LVM actually works.
---
tools/Makefile.am | 1 +
tools/test-virt-resize.sh | 31 +++++++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 0 deletions(-)
create mode 100755 tools/test-virt-resize.sh
diff --git a/tools/Makefile.am b/tools/Makefile.am
index ab14fe0..b92243c 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -86,6 +86,7 @@ TESTS = test-virt-cat.sh \
test-virt-list-filesystems.sh \
test-virt-ls.sh \
test-virt-make-fs.sh \
+ test-virt-resize.sh \
test-virt-tar.sh
endif
diff --git a/tools/test-virt-resize.sh b/tools/test-virt-resize.sh
new file mode 100755
index 0000000..75d5147
--- /dev/null
+++ b/tools/test-virt-resize.sh
@@ -0,0 +1,31 @@
+#!/bin/bash -
+
+export LANG=C
+set -e
+
+# Test expanding.
+#
+# This exercises a number of interesting codepaths including resizing
+# LV content, handling GPT, and using qcow2 as a target.
+
+../fish/guestfish -N bootrootlv:/dev/VG/LV:ext2:ext4:400M:32M:gpt </dev/null
+
+qemu-img create -f qcow2 test2.img 500M
+./virt-resize -d --expand /dev/sda2 --lv-expand /dev/VG/LV test1.img test2.img
+
+# Test shrinking in a semi-realistic scenario. Although the disk
+# image created above contains no data, we will nevertheless use
+# similar operations to ones that might be used by a real admin.
+
+../fish/guestfish -a test1.img <<EOF
+run
+resize2fs-size /dev/VG/LV 190M
+lvresize /dev/VG/LV 190
+pvresize-size /dev/sda2 200M
+fsck ext4 /dev/VG/LV
+EOF
+
+rm -f test2.img; truncate -s 300M test2.img
+./virt-resize -d --shrink /dev/sda2 test1.img test2.img
+
+rm -f test1.img test2.img
--
1.7.3
More information about the Libguestfs
mailing list