From 3e5c4536c1845f249d3cb1754195144b7aee3ba3 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Wed, 15 Apr 2015 15:24:12 +0200 Subject: [PATCH] v2v: generalize test-v2v-i-ova-zip.sh Rename test-v2v-i-ova-zip.sh (and associated data) to test-v2v-i-ova-formats, and generalize it a bit so it can test different compression types for the ova "envelope". (cherry picked from commit 454220ab43403ad97f02edcb2b5f71c5d21c0c25) --- v2v/Makefile.am | 8 +-- v2v/test-v2v-i-ova-formats.expected | 15 ++++ v2v/test-v2v-i-ova-formats.ovf | 138 ++++++++++++++++++++++++++++++++++++ v2v/test-v2v-i-ova-formats.sh | 94 ++++++++++++++++++++++++ v2v/test-v2v-i-ova-zip.expected | 15 ---- v2v/test-v2v-i-ova-zip.ovf | 138 ------------------------------------ v2v/test-v2v-i-ova-zip.sh | 77 -------------------- 7 files changed, 251 insertions(+), 234 deletions(-) create mode 100644 v2v/test-v2v-i-ova-formats.expected create mode 100644 v2v/test-v2v-i-ova-formats.ovf create mode 100755 v2v/test-v2v-i-ova-formats.sh delete mode 100644 v2v/test-v2v-i-ova-zip.expected delete mode 100644 v2v/test-v2v-i-ova-zip.ovf delete mode 100755 v2v/test-v2v-i-ova-zip.sh diff --git a/v2v/Makefile.am b/v2v/Makefile.am index 921fb93..731e51b 100644 --- a/v2v/Makefile.am +++ b/v2v/Makefile.am @@ -23,12 +23,12 @@ EXTRA_DIST = \ HACKING README.RHEV-M \ test-v2v-i-ova.ovf \ test-v2v-i-ova.xml \ + test-v2v-i-ova-formats.expected \ + test-v2v-i-ova-formats.ovf \ test-v2v-i-ova-gz.expected \ test-v2v-i-ova-gz.ovf \ 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 @@ -224,9 +224,9 @@ CLEANFILES += stamp-virt-v2v.pod TESTS_ENVIRONMENT = $(top_builddir)/run --test TESTS = \ + test-v2v-i-ova-formats.sh \ test-v2v-i-ova-gz.sh \ - test-v2v-i-ova-two-disks.sh \ - test-v2v-i-ova-zip.sh + test-v2v-i-ova-two-disks.sh if ENABLE_APPLIANCE TESTS += \ diff --git a/v2v/test-v2v-i-ova-formats.expected b/v2v/test-v2v-i-ova-formats.expected new file mode 100644 index 0000000..8b3d62c --- /dev/null +++ b/v2v/test-v2v-i-ova-formats.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) [scsi] +removable media: + CD-ROM [ide] +NICs: + Network "Network adapter 1" + diff --git a/v2v/test-v2v-i-ova-formats.ovf b/v2v/test-v2v-i-ova-formats.ovf new file mode 100644 index 0000000..3c685f4 --- /dev/null +++ b/v2v/test-v2v-i-ova-formats.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-formats.sh b/v2v/test-v2v-i-ova-formats.sh new file mode 100755 index 0000000..a9b2a96 --- /dev/null +++ b/v2v/test-v2v-i-ova-formats.sh @@ -0,0 +1,94 @@ +#!/bin/bash - +# libguestfs virt-v2v test script +# Copyright (C) 2014-2015 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 ova file compressed in different ways + +unset CDPATH +export LANG=C +set -e + +formats="tar zip" + +if [ -n "$SKIP_TEST_V2V_I_OVA_FORMATS_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-formats.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 + +for format in $formats; do + case "$format" in + tar) + tar -cf test-$format.ova ../test-v2v-i-ova-formats.ovf disk1.vmdk disk1.mf + ;; + zip) + zip -r test ../test-v2v-i-ova-formats.ovf disk1.vmdk disk1.mf + mv test.zip test-$format.ova + ;; + *) + echo "Unhandled format '$format'" + exit 1 + esac +done + +popd + +for format in $formats; do + # 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-$format.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-formats.expected $d/source +done + +rm -rf $d diff --git a/v2v/test-v2v-i-ova-zip.expected b/v2v/test-v2v-i-ova-zip.expected deleted file mode 100644 index 8b3d62c..0000000 --- a/v2v/test-v2v-i-ova-zip.expected +++ /dev/null @@ -1,15 +0,0 @@ -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) [scsi] -removable media: - CD-ROM [ide] -NICs: - Network "Network adapter 1" - diff --git a/v2v/test-v2v-i-ova-zip.ovf b/v2v/test-v2v-i-ova-zip.ovf deleted file mode 100644 index 3c685f4..0000000 --- a/v2v/test-v2v-i-ova-zip.ovf +++ /dev/null @@ -1,138 +0,0 @@ - - - - - - - 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 deleted file mode 100755 index cd1e258..0000000 --- a/v2v/test-v2v-i-ova-zip.sh +++ /dev/null @@ -1,77 +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 -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