[Kimchi-devel] [PATCH v4] [Kimchi 7/8] VEPA network support: additional backend unit tests

dhbarboza82 at gmail.com dhbarboza82 at gmail.com
Thu Feb 18 10:56:30 UTC 2016


From: Daniel Henrique Barboza <dhbarboza82 at gmail.com>

Added extra tests to assert the resulting VEPA network
XML.

Signed-off-by: Daniel Henrique Barboza <dhbarboza82 at gmail.com>
---
 tests/test_networkxml.py | 44 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 43 insertions(+), 1 deletion(-)

diff --git a/tests/test_networkxml.py b/tests/test_networkxml.py
index d4e2c3f..8e83744 100644
--- a/tests/test_networkxml.py
+++ b/tests/test_networkxml.py
@@ -1,7 +1,7 @@
 #
 # Kimchi
 #
-# Copyright IBM, Corp. 2013-2014
+# Copyright IBM Corp, 2013-2016
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -153,6 +153,48 @@ class NetworkXmlTests(unittest.TestCase):
         self.assertEquals(netmask,
                           str(ipaddr.IPNetwork(params["net"]).netmask))
 
+    def test_vepa_network_singledev_xml(self):
+        expected_xml = """<network>\
+<name>test_vepa</name>\
+<forward mode="vepa" dev="vepa_switch_interface">\
+<interface dev="vepa_switch_interface"/>\
+</forward>\
+</network>"""
+
+        params = {
+            "name": "test_vepa",
+            "forward": {
+                "mode": "vepa",
+                "devs": ["vepa_switch_interface"]
+            }
+        }
+        xml_str = nxml.to_network_xml(**params)
+        self.assertEqual(xml_str, expected_xml)
+
+    def test_vepa_network_multipledevs_xml(self):
+        expected_xml = """<network>\
+<name>test_vepa</name>\
+<forward mode="vepa" dev="vepa_switch_interface1">\
+<interface dev="vepa_switch_interface1"/>\
+<interface dev="vepa_switch_interface2"/>\
+<interface dev="vepa_switch_interface3"/>\
+</forward>\
+</network>"""
+
+        params = {
+            "name": "test_vepa",
+            "forward": {
+                "mode": "vepa",
+                "devs": [
+                    "vepa_switch_interface1",
+                    "vepa_switch_interface2",
+                    "vepa_switch_interface3"
+                ]
+            }
+        }
+        xml_str = nxml.to_network_xml(**params)
+        self.assertEqual(xml_str, expected_xml)
+
 
 class InterfaceXmlTests(unittest.TestCase):
 
-- 
2.5.0




More information about the Kimchi-devel mailing list