tests: add test for network forward mode 'open'

Signed-off-by: Lin Ma <lma@suse.com>
This commit is contained in:
Lin Ma 2017-05-03 23:56:31 +08:00 committed by Cole Robinson
parent be6566a134
commit ea85a3c680
3 changed files with 46 additions and 0 deletions

View File

@ -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>

View File

@ -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>

View File

@ -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