v2v: Use separate scripts for the slow tests of real guests.

Following the same style used for the firstboot tests in the
customize/ subdirectory, use a separate test script for each real
guest that we test.  This has two advantages: (a) the tests run in
parallel (and are thus faster) and (b) automake "knows" about each
test and reports the results separately.
This commit is contained in:
Richard W.M. Jones
2016-08-27 13:51:14 +01:00
parent 58c1f7f7e6
commit 823ecfef39
5 changed files with 149 additions and 127 deletions

12
.gitignore vendored
View File

@@ -594,22 +594,18 @@ Makefile.in
/utils/qemu-boot/qemu-boot
/utils/qemu-speed-test/qemu-speed-test
/v2v/.depend
/v2v/centos-6.img
/v2v/centos-7.0.img
/v2v/fedora-20.img
/v2v/fedora-23.img
/v2v/fake-virtio-win.iso
/v2v/oUnit-*
/v2v/rhel-5.10.img
/v2v/rhel-6.5.img
/v2v/rhel-7.0.img
/v2v/rhel-7.2.img
/v2v/real-*.d/
/v2v/real-*.img
/v2v/real-*.xml
/v2v/stamp-virt-v2v.pod
/v2v/stamp-virt-v2v-copy-to-local.pod
/v2v/test-harness/.depend
/v2v/test-harness/META
/v2v/test-harness/stamp-virt-v2v-test-harness.pod
/v2v/test-harness/virt-v2v-test-harness.1
/v2v/test-v2v-conversion-of-*.sh
/v2v/uefi.ml
/v2v/uefi.mli
/v2v/v2v_unit_tests

View File

@@ -292,36 +292,36 @@ check-valgrind:
$(MAKE) VG="$(abs_top_builddir)/run @VG@" check
SLOW_TESTS = \
test-v2v-real-conversions.sh \
$(real_guests_scripts) \
test-v2v-trim.sh
check-slow: $(real_guests:%=%.img)
check-slow:
$(MAKE) check TESTS="$(SLOW_TESTS)" SLOW=1
# A selection of real guests that test-v2v-real-conversions.sh will
# A selection of real guests that test-v2v-conversion-of.sh will
# try to convert. This is only used by 'make check-slow'.
real_guests = \
centos-6 \
centos-7.0 \
fedora-20 \
fedora-23 \
rhel-5.10 \
rhel-6.5 \
rhel-7.0 \
rhel-7.2
real_guests_scripts = \
test-v2v-conversion-of-centos-6.sh \
test-v2v-conversion-of-centos-7.0.sh \
test-v2v-conversion-of-fedora-20.sh \
test-v2v-conversion-of-fedora-23.sh \
test-v2v-conversion-of-rhel-5.10.sh \
test-v2v-conversion-of-rhel-6.8.sh \
test-v2v-conversion-of-rhel-7.0.sh \
test-v2v-conversion-of-rhel-7.2.sh
$(real_guests:%=%.img):
rm -f $@
n=`basename $@ .img`; \
vb="$(top_builddir)/run $(top_builddir)/builder/virt-builder"; \
if $$vb --help >/dev/null && $$vb --notes $$n >/dev/null; then \
$$vb $$n; \
else \
touch $$n.img; \
fi
test-v2v-conversion-of-%.sh:
rm -f $@ $@-t
f=`echo "$@" | $(SED) 's/test-v2v-conversion-of-\(.*\).sh/\1/'`; \
echo 'exec $$srcdir/test-v2v-conversion-of.sh' "$$f" > $@-t
chmod 0755 $@-t
mv $@-t $@
CLEANFILES += $(real_guests:%=%.img)
CLEANFILES += \
$(real_guests_scripts) \
real-*.img \
real-*.xml
EXTRA_DIST += \
test-v2v-bad-networks-and-bridges.sh \
@@ -365,7 +365,7 @@ EXTRA_DIST += \
test-v2v-of-option.sh \
test-v2v-on-option.sh \
test-v2v-print-source.sh \
test-v2v-real-conversions.sh \
test-v2v-conversion-of.sh \
test-v2v-sound.sh \
test-v2v-sound.xml \
test-v2v-trim.sh \

113
v2v/test-v2v-conversion-of.sh Executable file
View File

@@ -0,0 +1,113 @@
#!/bin/bash -
# libguestfs virt-v2v test script
# Copyright (C) 2014-2016 Red Hat Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# Test virt-v2v on real guests.
unset CDPATH
export LANG=C
set -e
if [ -z "$SLOW" ]; then
echo "$0: use 'make check-slow' to run this test"
exit 77
fi
if [ -n "$SKIP_TEST_V2V_CONVERSION_OF_SH" ]; then
echo "$0: test skipped because environment variable is set"
exit 77
fi
guestname="$1"
if [ -z "$guestname" ]; then
echo "$0: guestname parameter not set, don't run this test directly."
exit 1
fi
disk="real-$guestname.img"
xml="real-$guestname.xml"
os="real-$guestname.d"
rm -f "$disk" "$xml"
rm -rf "$os"
mkdir "$os"
# If the guest doesn't exist in virt-builder, skip. This is because
# we test some RHEL guests which most users won't have access to.
if ! virt-builder -l "$guestname" >/dev/null 2>&1; then
echo "$0: test skipped because \"$guestname\" not known to virt-builder."
exit 77
fi
# We can only run the tests on x86_64.
if [ "$(uname -m)" != "x86_64" ]; then
echo "$0: test skipped because !x86_64."
exit 77
fi
# Some guests need special virt-builder parameters.
# See virt-builder --notes "$guestname"
declare -a extra
case "$guestname" in
fedora*|rhel*|centos*)
extra[${#extra[*]}]='--selinux-relabel'
;;
*)
;;
esac
# Build a guest (using virt-builder).
virt-builder "$guestname" --quiet -o "$disk" "${extra[@]}"
# Create some minimal test metadata.
cat > "$xml" <<EOF
<domain type='test'>
<name>$guestname</name>
<memory>1048576</memory>
<os>
<type>hvm</type>
<boot dev='hd'/>
</os>
<devices>
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='$(pwd)/$disk'/>
<target dev='vda' bus='virtio'/>
</disk>
</devices>
</domain>
EOF
virt-v2v --debug-gc -i libvirtxml "$xml" -o local -os "$os"
# Test the libvirt XML metadata and a disk was created.
# XXX We should check the XML.
test -f "$os/$guestname.xml"
test -f "$os/$guestname-sda"
# Test the disk has a similar size to the original.
size_before="$(du $disk | awk '{print $1}')"
size_after="$(du $os/$guestname-sda | awk '{print $1}')"
diff="$(( 100 * size_after / size_before ))"
if test $diff -lt 50; then
echo "$0: disk image may have been corrupted or truncated"
echo "size_before=$size_before size_after=$size_after diff=$diff"
ls -l "$disk" "$os/$guestname-sda"
exit 1
fi
rm -f "$disk" "$xml"
rm -rf "$os"

View File

@@ -1,87 +0,0 @@
#!/bin/bash -
# libguestfs virt-v2v test script
# Copyright (C) 2014 Red Hat Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# Test virt-v2v on some real guests.
#
# The phony Fedora guest isn't sufficient for testing. The
# Makefile.am builds some real guests using virt-builder and we just
# run virt-v2v on those (to make sure it doesn't crash / assert).
unset CDPATH
export LANG=C
set -e
if [ -z "$SLOW" ]; then
echo "$0: use 'make check-slow' to run this test"
exit 77
fi
if [ -n "$SKIP_TEST_V2V_REAL_CONVERSIONS_SH" ]; then
echo "$0: test skipped because environment variable is set"
exit 77
fi
d=test-v2v-real-conversions.d
rm -rf $d
mkdir $d
for file in *.img; do
if test -f $file && test -s $file ; then
n=`basename $file .img`
# Create some minimal test metadata.
cat > $d/$n-input.xml <<EOF
<domain type='test'>
<name>$n</name>
<memory>1048576</memory>
<os>
<type>hvm</type>
<boot dev='hd'/>
</os>
<devices>
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='$(pwd)/$file'/>
<target dev='vda' bus='virtio'/>
</disk>
</devices>
</domain>
EOF
virt-v2v --debug-gc \
-i libvirtxml $d/$n-input.xml \
-o local -os $d
# Test the libvirt XML metadata and a disk was created.
test -f $d/$n.xml
test -f $d/$n-sda
# Test the disk has a similar size to the original.
size_before="$(du $file | awk '{print $1}')"
size_after="$(du $d/$n-sda | awk '{print $1}')"
diff="$(( 100 * size_after / size_before ))"
if test $diff -lt 50; then
echo "$0: disk image may have been corrupted or truncated"
echo "size_before=$size_before size_after=$size_after diff=$diff"
ls -l $file $d/$n-sda
exit 1
fi
fi
done
rm -r $d

View File

@@ -39,19 +39,19 @@ if [ "$(guestfish get-backend)" = "uml" ]; then
exit 77
fi
# This should be created by Makefile.am when doing 'make check-slow'.
# If this fails it's probably because you're not running the test with
# 'make check-slow' but running it directly.
f="$(pwd)/fedora-20.img"
if ! test -f "$f" || ! test -s "$f"; then
echo "$0: Fedora 20 guest image was not created by Makefile"
exit 1
fi
d=test-v2v-trim.d
rm -rf $d
mkdir $d
n=fedora-20
f="$(pwd)/$d/$n.img"
if ! virt-builder -l "$n"; then
echo "$0: virt-builder $n image not found"
exit 77
fi
virt-builder "$n" --quiet -o "$f"
qemu-img create -f qcow2 -b "$f" $d/fedora.qcow2
guestfish -a $d/fedora.qcow2 -i <<EOF