|
| 1 | + |
| 2 | +import unittest |
| 3 | + |
| 4 | +from dsatest.bench import bench |
| 5 | +from dsatest.tests.helpers import up_and_wait, get_address |
| 6 | + |
| 7 | +@unittest.skipIf(not bench.links, "Empty link list") |
| 8 | +class TestPingVlan(unittest.TestCase): |
| 9 | + |
| 10 | + VID_START = 0 |
| 11 | + VID_END = 10 |
| 12 | + |
| 13 | + def setUp(self): |
| 14 | + links = bench.links |
| 15 | + |
| 16 | + for i, link in enumerate(links): |
| 17 | + up_and_wait(link) |
| 18 | + link.host_if.flush_addresses() |
| 19 | + link.target_if.flush_addresses() |
| 20 | + for vid in range(TestPingVlan.VID_START, TestPingVlan.VID_END): |
| 21 | + link.host_if.add_vlan(vid) |
| 22 | + link.target_if.add_vlan(vid) |
| 23 | + |
| 24 | + |
| 25 | + def tearDown(self): |
| 26 | + links = bench.links |
| 27 | + |
| 28 | + for i, link in enumerate(links): |
| 29 | + for vid in range(TestPingVlan.VID_START, TestPingVlan.VID_END): |
| 30 | + link.target_if.del_vlan(vid) |
| 31 | + link.host_if.del_vlan(vid) |
| 32 | + link.host_if.down() |
| 33 | + link.target_if.down() |
| 34 | + |
| 35 | + |
| 36 | + def test_port_ping_vlan_all(self): |
| 37 | + for i, link in enumerate(bench.links): |
| 38 | + for vid in range(TestPingVlan.VID_START, TestPingVlan.VID_END): |
| 39 | + host_vlan = link.host_if.vlan_interfaces[vid] |
| 40 | + target_vlan = link.target_if.vlan_interfaces[vid] |
| 41 | + host_vlan.add_address(get_address(vid, "host", 24)) |
| 42 | + host_vlan.up() |
| 43 | + target_vlan.add_address(get_address(vid, "target", 24)) |
| 44 | + target_vlan.up() |
| 45 | + addr = get_address(vid, "target") |
| 46 | + host_vlan.ping(addr, count=1, deadline=10) |
| 47 | + host_vlan.flush_addresses() |
| 48 | + target_vlan.flush_addresses() |
| 49 | + host_vlan.down() |
| 50 | + target_vlan.down() |
0 commit comments