[Pkg-libvirt-commits] [libguestfs] 162/266: v2v: Add a test of --network and --bridge command line options.

Hilko Bengen bengen at moszumanska.debian.org
Fri Oct 3 14:41:56 UTC 2014


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to annotated tag debian/1%1.27.35-1
in repository libguestfs.

commit 6e1e9604b6da2ef8eeca2acb945bde6becad038e
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Thu Aug 21 21:47:22 2014 +0100

    v2v: Add a test of --network and --bridge command line options.
    
    This enhances commit aaf84abca9e19e6a358516b60cc8a49d0905aef5.
---
 .gitignore                                     |  1 +
 configure.ac                                   |  3 +-
 v2v/Makefile.am                                |  8 +++
 v2v/test-v2v-networks-and-bridges-expected.xml | 34 ++++++++++
 v2v/test-v2v-networks-and-bridges.sh           | 74 ++++++++++++++++++++++
 v2v/test-v2v-networks-and-bridges.xml.in       | 87 ++++++++++++++++++++++++++
 6 files changed, 206 insertions(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore
index 60c4217..59ae41d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -553,5 +553,6 @@ Makefile.in
 /v2v/rhel-6.5.img
 /v2v/rhel-7.0.img
 /v2v/stamp-virt-v2v.pod
+/v2v/test-v2v-networks-and-bridges.xml
 /v2v/virt-v2v
 /v2v/virt-v2v.1
diff --git a/configure.ac b/configure.ac
index 9f499d1..1a2cb72 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1736,7 +1736,8 @@ AC_CONFIG_FILES([Makefile
                  tests/xfs/Makefile
                  tests/xml/Makefile
                  tools/Makefile
-                 v2v/Makefile])
+                 v2v/Makefile
+                 v2v/test-v2v-networks-and-bridges.xml])
 AC_OUTPUT
 
 dnl Produce summary.
diff --git a/v2v/Makefile.am b/v2v/Makefile.am
index 3eec99a..b984073 100644
--- a/v2v/Makefile.am
+++ b/v2v/Makefile.am
@@ -20,6 +20,8 @@ include $(top_srcdir)/subdir-rules.mk
 EXTRA_DIST = \
 	$(SOURCES_MLI) $(SOURCES_ML) $(SOURCES_C) \
 	$(TESTS) $(SLOW_TESTS) \
+	test-v2v-networks-and-bridges-expected.xml \
+	test-v2v-networks-and-bridges.xml.in \
 	virt-v2v.pod
 
 CLEANFILES = *~ *.cmi *.cmo *.cmx *.cmxa *.o virt-v2v
@@ -181,6 +183,7 @@ if ENABLE_APPLIANCE
 TESTS = \
 	test-v2v-i-disk.sh \
 	test-v2v-machine-readable.sh \
+	test-v2v-networks-and-bridges.sh \
 	test-v2v-no-copy.sh \
 	test-v2v-o-libvirt.sh \
 	test-v2v-o-rhev.sh \
@@ -191,6 +194,11 @@ TESTS = \
 	test-v2v-windows-conversion.sh
 endif ENABLE_APPLIANCE
 
+# This forces the file to be updated before running the tests, in case
+# the .xml.in file has been changed.  Be nice if automake just did the
+# right thing here.
+check_DATA = test-v2v-networks-and-bridges.xml
+
 check-valgrind:
 	$(MAKE) VG="$(top_builddir)/run @VG@" check
 
diff --git a/v2v/test-v2v-networks-and-bridges-expected.xml b/v2v/test-v2v-networks-and-bridges-expected.xml
new file mode 100644
index 0000000..37f66a7
--- /dev/null
+++ b/v2v/test-v2v-networks-and-bridges-expected.xml
@@ -0,0 +1,34 @@
+    <interface type='bridge'>
+      <source bridge='bridge1'/>
+      <model type='rtl8139'/>
+    </interface>
+    <interface type='bridge'>
+      <source bridge='bridge2'/>
+      <model type='rtl8139'/>
+      <mac address='52:54:00:01:02:03'/>
+    </interface>
+    <interface type='network'>
+      <source network='network1'/>
+      <model type='rtl8139'/>
+      <mac address='52:54:00:01:02:04'/>
+    </interface>
+    <interface type='network'>
+      <source network='network2'/>
+      <model type='rtl8139'/>
+      <mac address='52:54:00:01:02:05'/>
+    </interface>
+    <interface type='network'>
+      <source network='network3'/>
+      <model type='rtl8139'/>
+      <mac address='52:54:00:01:02:06'/>
+    </interface>
+    <interface type='network'>
+      <source network='network4'/>
+      <model type='rtl8139'/>
+      <mac address='52:54:00:01:02:07'/>
+    </interface>
+    <interface type='network'>
+      <source network='network4'/>
+      <model type='rtl8139'/>
+      <mac address='52:54:00:01:02:08'/>
+    </interface>
diff --git a/v2v/test-v2v-networks-and-bridges.sh b/v2v/test-v2v-networks-and-bridges.sh
new file mode 100755
index 0000000..d7b7749
--- /dev/null
+++ b/v2v/test-v2v-networks-and-bridges.sh
@@ -0,0 +1,74 @@
+#!/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 --network and --bridge parameters.
+
+unset CDPATH
+export LANG=C
+set -e
+
+if [ -n "$SKIP_TEST_V2V_NETWORKS_AND_BRIDGES_SH" ]; then
+    echo "$0: test skipped because environment variable is set"
+    exit 77
+fi
+
+if [ "$(../fish/guestfish get-backend)" = "uml" ]; then
+    echo "$0: test skipped because UML backend does not support network"
+    exit 77
+fi
+
+abs_builddir="$(pwd)"
+libvirt_uri="test://$abs_builddir/test-v2v-networks-and-bridges.xml"
+
+f=../tests/guests/windows.img
+if ! test -f $f || ! test -s $f; then
+    echo "$0: test skipped because phony Windows image was not created"
+    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-networks-and-bridges.d
+rm -rf $d
+mkdir $d
+
+# Use --no-copy because we only care about metadata for this test.
+$VG ./virt-v2v --debug-gc \
+    -i libvirt -ic "$libvirt_uri" windows \
+    -o local -os $d --no-copy \
+    --bridge "VM Network:bridge1" \
+    --bridge bridge2 \
+    --network default:network1 \
+    --network john:network2 \
+    --network paul:network3 \
+    --network network4
+
+# Test the libvirt XML metadata was created.
+test -f $d/windows.xml
+
+# Extract just the network interfaces from the XML.
+sed -n '/interface/,/\/interface/p' $d/windows.xml > $d/networks
+
+# Test that the output has mapped the networks and bridges correctly.
+diff -ur test-v2v-networks-and-bridges-expected.xml $d/networks
+
+rm -r $d
diff --git a/v2v/test-v2v-networks-and-bridges.xml.in b/v2v/test-v2v-networks-and-bridges.xml.in
new file mode 100644
index 0000000..2142c08
--- /dev/null
+++ b/v2v/test-v2v-networks-and-bridges.xml.in
@@ -0,0 +1,87 @@
+<!--
+libguestfs virt-v2v tool
+Copyright (C) 2009-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.
+
+ at configure_input@
+-->
+<node>
+  <domain type='test'>
+    <name>windows</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='@abs_top_builddir@/tests/guests/windows.img'/>
+        <target dev='vda' bus='virtio'/>
+      </disk>
+
+      <!-- various different networks and bridges which should
+           be renamed by the test -->
+
+      <!-- standard ESX bridge -->
+      <interface type='bridge'>
+        <mac address='00:00:00:00:00:00'/>
+        <source bridge='VM Network'/>
+        <model type='e1000'/>
+      </interface>
+
+      <!-- another bridge to be remapped -->
+      <interface type='bridge'>
+        <mac address='52:54:00:01:02:03'/>
+        <source bridge='bob'/>
+        <model type='e1000'/>
+      </interface>
+
+      <!-- typical libvirt network -->
+      <interface type='network'>
+        <mac address='52:54:00:01:02:04'/>
+        <source network='default'/>
+        <model type='virtio'/>
+      </interface>
+
+      <!-- some more random networks to map -->
+      <interface type='network'>
+        <mac address='52:54:00:01:02:05'/>
+        <source network='john'/>
+        <model type='virtio'/>
+      </interface>
+
+      <interface type='network'>
+        <source network='paul'/>
+        <model type='virtio'/>
+        <mac address='52:54:00:01:02:06'/>
+      </interface>
+
+      <interface type='network'>
+        <model type='rtl8139'/>
+        <source network='george'/>
+        <mac address='52:54:00:01:02:07'/>
+      </interface>
+
+      <interface type='network'>
+        <mac address='52:54:00:01:02:08'/>
+        <model type='virtio'/>
+        <source network='ringo'/>
+      </interface>
+
+    </devices>
+  </domain>
+</node>

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list