diff options
| author | Ryan Harper <[email protected]> | 2016-08-18 13:04:50 -0500 |
|---|---|---|
| committer | Ryan Harper <[email protected]> | 2016-08-18 13:04:50 -0500 |
| commit | 62e91adf859f83272c9b5b2c16f6e2bff7d68600 (patch) | |
| tree | 5ff2ea64d8a7066776e9452189d56e4d9977ca32 /tests/vmtests/test_network_ipv6_vlan.py | |
| parent | 01797a68736a2d89eb3a3c0e79e4a960aabd9bf2 (diff) | |
vmtests: restructure ipv6 testing into separate files
The base ipv6 testing class was too large, break it out into
separate files. Re-use the base class and only add on tests
for specific features.
bzr-revno: 416.5.3
Diffstat (limited to 'tests/vmtests/test_network_ipv6_vlan.py')
| -rw-r--r-- | tests/vmtests/test_network_ipv6_vlan.py | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/tests/vmtests/test_network_ipv6_vlan.py b/tests/vmtests/test_network_ipv6_vlan.py new file mode 100644 index 00000000..a11a3a52 --- /dev/null +++ b/tests/vmtests/test_network_ipv6_vlan.py @@ -0,0 +1,78 @@ +from . import logger +from .releases import base_vm_classes as relbase +from .test_network_ipv6 import TestNetworkIPV6Abs + +import os +import textwrap +import yaml + + +class TestNetworkIPV6VlanAbs(TestNetworkIPV6Abs): + conf_file = "examples/tests/vlan_network_ipv6.yaml" + collect_scripts = TestNetworkIPV6Abs.collect_scripts + [textwrap.dedent(""" + cd OUTPUT_COLLECT_D + dpkg-query -W -f '${Status}' vlan > vlan_installed + ip -d link show interface1.2667 > ip_link_show_interface1.2667 + ip -d link show interface1.2668 > ip_link_show_interface1.2668 + ip -d link show interface1.2669 > ip_link_show_interface1.2669 + ip -d link show interface1.2670 > ip_link_show_interface1.2670 + """)] + + def get_vlans(self): + network_state = self.get_network_state() + logger.debug('get_vlans ns:\n%s', yaml.dump(network_state, + default_flow_style=False, + indent=4)) + interfaces = network_state.get('interfaces') + return [iface for iface in interfaces.values() + if iface['type'] == 'vlan'] + + def test_output_files_exist_vlan(self): + link_files = ["ip_link_show_%s" % vlan['name'] + for vlan in self.get_vlans()] + self.output_files_exist(["vlan_installed"] + link_files) + + def test_vlan_installed(self): + with open(os.path.join(self.td.collect, "vlan_installed")) as fp: + status = fp.read().strip() + logger.debug('vlan installed?: %s', status) + self.assertEqual('install ok installed', status) + + def test_vlan_enabled(self): + + # we must have at least one + self.assertGreaterEqual(len(self.get_vlans()), 1) + + # did they get configured? + for vlan in self.get_vlans(): + link_file = "ip_link_show_" + vlan['name'] + vlan_msg = "vlan protocol 802.1Q id " + str(vlan['vlan_id']) + self.check_file_regex(link_file, vlan_msg) + + +class PreciseTestNetworkIPV6Vlan(relbase.precise, TestNetworkIPV6VlanAbs): + __test__ = True + + # precise ip -d link show output is different (of course) + def test_vlan_enabled(self): + + # we must have at least one + self.assertGreaterEqual(len(self.get_vlans()), 1) + + # did they get configured? + for vlan in self.get_vlans(): + link_file = "ip_link_show_" + vlan['name'] + vlan_msg = "vlan id " + str(vlan['vlan_id']) + self.check_file_regex(link_file, vlan_msg) + + +class TrustyTestNetworkIPV6Vlan(relbase.trusty, TestNetworkIPV6VlanAbs): + __test__ = True + + +class XenialTestNetworkIPV6Vlan(relbase.xenial, TestNetworkIPV6VlanAbs): + __test__ = True + + +class YakketyTestNetworkIPV6Vlan(relbase.yakkety, TestNetworkIPV6VlanAbs): + __test__ = True |
