[virt-tools-list] [virt-manager PATCH 2/3] tests: add test for network forward mode 'open'

Lin Ma lma at suse.com
Wed May 3 15:56:31 UTC 2017


Signed-off-by: Lin Ma <lma at suse.com>
---
 tests/xmlparse-xml/network-open-in.xml  | 10 ++++++++++
 tests/xmlparse-xml/network-open-out.xml | 10 ++++++++++
 tests/xmlparse.py                       | 26 ++++++++++++++++++++++++++
 3 files changed, 46 insertions(+)
 create mode 100644 tests/xmlparse-xml/network-open-in.xml
 create mode 100644 tests/xmlparse-xml/network-open-out.xml

diff --git a/tests/xmlparse-xml/network-open-in.xml b/tests/xmlparse-xml/network-open-in.xml
new file mode 100644
index 0000000..bd394ee
--- /dev/null
+++ b/tests/xmlparse-xml/network-open-in.xml
@@ -0,0 +1,10 @@
+<network>
+  <name>open</name>
+  <forward mode="open"/>
+  <domain name="open"/>
+  <ip address="192.168.100.1" netmask="255.255.255.0">
+    <dhcp>
+      <range start="192.168.100.128" end="192.168.100.254"/>
+    </dhcp>
+  </ip>
+</network>
diff --git a/tests/xmlparse-xml/network-open-out.xml b/tests/xmlparse-xml/network-open-out.xml
new file mode 100644
index 0000000..22c13b6
--- /dev/null
+++ b/tests/xmlparse-xml/network-open-out.xml
@@ -0,0 +1,10 @@
+<network>
+  <name>new-foo</name>
+  <forward mode="open"/>
+  <domain name="newdom"/>
+  <ip address="192.168.101.1" netmask="255.255.254.0">
+    <dhcp>
+      <range start="192.168.101.128" end="192.168.101.254"/>
+    </dhcp>
+  </ip>
+</network>
diff --git a/tests/xmlparse.py b/tests/xmlparse.py
index b8beebf..a305eff 100644
--- a/tests/xmlparse.py
+++ b/tests/xmlparse.py
@@ -1293,6 +1293,32 @@ class XMLParseTest(unittest.TestCase):
         utils.diff_compare(net.get_xml_config(), outfile)
         utils.test_create(conn, net.get_xml_config(), "networkDefineXML")
 
+    def testNetOpen(self):
+        basename = "network-open"
+        infile = "tests/xmlparse-xml/%s-in.xml" % basename
+        outfile = "tests/xmlparse-xml/%s-out.xml" % basename
+        net = virtinst.Network(conn, parsexml=file(infile).read())
+
+        check = self._make_checker(net)
+        check("name", "open", "new-foo")
+        check("domain_name", "open", "newdom")
+
+        check = self._make_checker(net.forward)
+        check("mode", "open")
+        check("dev", None)
+
+        self.assertEqual(len(net.ips), 1)
+        check = self._make_checker(net.ips[0])
+        check("address", "192.168.100.1", "192.168.101.1")
+        check("netmask", "255.255.255.0", "255.255.254.0")
+
+        check = self._make_checker(net.ips[0].ranges[0])
+        check("start", "192.168.100.128", "192.168.101.128")
+        check("end", "192.168.100.254", "192.168.101.254")
+
+        utils.diff_compare(net.get_xml_config(), outfile)
+        utils.test_create(conn, net.get_xml_config(), "networkDefineXML")
+
     def testNetVfPool(self):
         basename = "network-vf-pool"
         infile = "tests/xmlparse-xml/%s-in.xml" % basename
-- 
2.9.2




More information about the virt-tools-list mailing list