From d6dd4275c08f7eafa71e97ac29c78f430d4dcaed Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sat, 18 Oct 2014 21:45:10 +0100 Subject: [PATCH] v2v: -i ova: Add a test for ZIP as a container (RHBZ#1152998). (cherry picked from commit f27a582b6dd85a2810351cf7c2d2c98dc5ea6e9a) --- v2v/Makefile.am | 5 +- v2v/test-v2v-i-ova-zip.expected | 15 +++++ v2v/test-v2v-i-ova-zip.ovf | 138 ++++++++++++++++++++++++++++++++++++++++ v2v/test-v2v-i-ova-zip.sh | 77 ++++++++++++++++++++++ 4 files changed, 234 insertions(+), 1 deletion(-) create mode 100644 v2v/test-v2v-i-ova-zip.expected create mode 100644 v2v/test-v2v-i-ova-zip.ovf create mode 100755 v2v/test-v2v-i-ova-zip.sh diff --git a/v2v/Makefile.am b/v2v/Makefile.am index 2092621..e9856fd 100644 --- a/v2v/Makefile.am +++ b/v2v/Makefile.am @@ -25,6 +25,8 @@ EXTRA_DIST = \ test-v2v-i-ova.xml \ test-v2v-i-ova-two-disks.expected \ test-v2v-i-ova-two-disks.ovf \ + test-v2v-i-ova-zip.expected \ + test-v2v-i-ova-zip.ovf \ test-v2v-networks-and-bridges-expected.xml \ test-v2v-networks-and-bridges.xml.in \ virt-v2v.pod @@ -218,7 +220,8 @@ CLEANFILES += stamp-virt-v2v.pod TESTS_ENVIRONMENT = $(top_builddir)/run --test TESTS = \ - test-v2v-i-ova-two-disks.sh + test-v2v-i-ova-two-disks.sh \ + test-v2v-i-ova-zip.sh if ENABLE_APPLIANCE TESTS += \ diff --git a/v2v/test-v2v-i-ova-zip.expected b/v2v/test-v2v-i-ova-zip.expected new file mode 100644 index 0000000..a835f00 --- /dev/null +++ b/v2v/test-v2v-i-ova-zip.expected @@ -0,0 +1,15 @@ +Source guest information (--print-source option): + + source name: 2K8R2EESP1_2_Medium +hypervisor type: vmware + memory: 1073741824 (bytes) + nr vCPUs: 1 + CPU features: + display: +disks: + disk1.vmdk (vmdk) [hda] +removable media: + CD-ROM [hda] +NICs: + Network "Network adapter 1" + diff --git a/v2v/test-v2v-i-ova-zip.ovf b/v2v/test-v2v-i-ova-zip.ovf new file mode 100644 index 0000000..3c685f4 --- /dev/null +++ b/v2v/test-v2v-i-ova-zip.ovf @@ -0,0 +1,138 @@ + + + + + + + Virtual disk information + + + + The list of logical networks + + The PG-VLAN60 network + + + + A virtual machine + 2K8R2EESP1_2_Medium + + The kind of installed guest operating system + Microsoft Windows Server 2008 R2 (64-bit) + + + Virtual hardware requirements + + Virtual Hardware Family + 0 + 2K8R2EESP1_2_Medium + vmx-10 + + + hertz * 10^6 + Number of Virtual CPUs + 1 virtual CPU(s) + 1 + 3 + 1 + + + byte * 2^20 + Memory Size + 1024MB of memory + 2 + 4 + 1024 + + + 0 + SCSI Controller + SCSI controller 0 + 3 + lsilogicsas + 6 + + + + 1 + IDE Controller + IDE 1 + 4 + 5 + + + 0 + IDE Controller + IDE 0 + 5 + 5 + + + false + Video card + 6 + 24 + + + + + + + false + VMCI device + 7 + vmware.vmci + 1 + + + + + 0 + false + CD/DVD drive 1 + 8 + 4 + vmware.cdrom.atapi + 15 + + + 0 + Hard disk 1 + ovf:/disk/vmdisk1 + 9 + 3 + 17 + + + + 7 + true + PG-VLAN60 + E1000 ethernet adapter on "PG-VLAN60" + Network adapter 1 + 11 + E1000 + 10 + + + + + + + + + + + + + + + + + + + + + + + diff --git a/v2v/test-v2v-i-ova-zip.sh b/v2v/test-v2v-i-ova-zip.sh new file mode 100755 index 0000000..cd1e258 --- /dev/null +++ b/v2v/test-v2v-i-ova-zip.sh @@ -0,0 +1,77 @@ +#!/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 -i ova option with a zip file. + +unset CDPATH +export LANG=C +set -e + +if [ -n "$SKIP_TEST_V2V_I_OVA_ZIP_SH" ]; then + echo "$0: test skipped because environment variable is set" + exit 77 +fi + +if ! zip --version >/dev/null 2>&1; then + echo "$0: test skipped because 'zip' utility is not available" + exit 77 +fi + +if ! unzip --help >/dev/null 2>&1; then + echo "$0: test skipped because 'unzip' utility is not available" + exit 77 +fi + +if [ "$(guestfish get-backend)" = "uml" ]; then + echo "$0: test skipped because UML backend does not support network" + exit 77 +fi + +virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools} +if ! test -r $virt_tools_data_dir/rhsrvany.exe; then + echo "$0: test skipped because rhsrvany.exe is not installed" + exit 77 +fi + +d=test-v2v-i-ova-zip.d +rm -rf $d +mkdir $d + +pushd $d + +# Create a phony OVA. This is only a test of source parsing, not +# conversion, so the contents of the disks doesn't matter. +truncate -s 10k disk1.vmdk +sha=`sha1sum disk1.vmdk | awk '{print $1}'` +echo -e "SHA1(disk1.vmdk)=$sha\r" > disk1.mf + +zip -r test ../test-v2v-i-ova-zip.ovf disk1.vmdk disk1.mf +mv test.zip test.ova +popd + +# Run virt-v2v but only as far as the --print-source stage, and +# normalize the output. +$VG virt-v2v --debug-gc --quiet \ + -i ova $d/test.ova \ + --print-source | +sed 's,[^ \t]*\(disk.*.vmdk\),\1,' > $d/source + +# Check the parsed source is what we expect. +diff -u test-v2v-i-ova-zip.expected $d/source + +rm -rf $d -- 1.8.3.1