def test_steiner_tree_with_loop(self): man = TopologyManager(STEINER_LOOP_CONFIG_FILE) topo = man.get_topology() # Get a tree connecting sw1, sw4, and sw7 nodes = ['sw1', 'sw4', 'sw7'] tree = man.find_valid_steiner_tree(nodes) expected_tree_nodes = ["sw1", "sw2", "sw5", "sw4", "sw7"] returned_tree_nodes = tree.nodes() self.failUnlessEqual(len(expected_tree_nodes), len(returned_tree_nodes)) for node in expected_tree_nodes: self.failUnless(node in returned_tree_nodes) # Get a tree connecting sw1, sw3, sw8, sw6 nodes = ["sw1", "sw3", "sw6", "sw8"] tree = man.find_valid_steiner_tree(nodes) expected_tree_nodes = ["sw1", "sw2", "sw3", "sw8", "sw7", "sw6"] returned_tree_nodes = tree.nodes() self.failUnlessEqual(len(expected_tree_nodes), len(returned_tree_nodes)) for node in expected_tree_nodes: self.failUnless(node in returned_tree_nodes) # Get a tree connecting sw1, sw3, sw8 nodes = ["sw1", "sw3", "sw8"] tree = man.find_valid_steiner_tree(nodes) expected_tree_nodes = ["sw1", "sw2", "sw3", "sw8"] returned_tree_nodes = tree.nodes() self.failUnlessEqual(len(expected_tree_nodes), len(returned_tree_nodes)) for node in expected_tree_nodes: self.failUnless(node in returned_tree_nodes)
def test_reserve_maximum(self): man = TopologyManager(STEINER_NO_LOOP_CONFIG_FILE) # Get a tree connecting sw1, sw8, and sw6 nodes = ['sw1', 'sw8', 'sw6'] tree = man.find_valid_steiner_tree(nodes) # Should work man.reserve_bw_on_tree(tree, 80000000000)
def test_reserve_too_much(self): man = TopologyManager(STEINER_NO_LOOP_CONFIG_FILE) # Get a tree connecting sw1, sw8, and sw6 nodes = ['sw1', 'sw8', 'sw6'] tree = man.find_valid_steiner_tree(nodes) # Should work self.failUnlessRaises(Exception, man.reserve_bw_on_tree, tree, 80000000001)
def test_find_vlan(self): man = TopologyManager(STEINER_NO_LOOP_CONFIG_FILE) topo = man.get_topology() # Get a tree connecting sw1, sw8, and sw6 nodes = ['sw1', 'sw8', 'sw6'] tree = man.find_valid_steiner_tree(nodes) # Should work vlan = man.find_vlan_on_tree(tree)
def test_reserve_on_invalid(self): man = TopologyManager(STEINER_NO_LOOP_CONFIG_FILE) topo = man.get_topology() # Get a tree connecting sw1, sw8, and sw6 nodes = ['sw1', 'sw8', 'sw6'] tree = man.find_valid_steiner_tree(nodes) # Should work vlan = man.find_vlan_on_tree(tree) # Should work man.reserve_vlan_on_tree(tree, vlan) # Should work self.failUnlessRaises(Exception, man.reserve_vlan_on_tree, tree, vlan)