Exemplo n.º 1
0
 def test_build(self):
     """Test the topology is built correctly"""
     host_links = {0: [0], 1: [1]}
     host_vlans = {0: 0, 1: [0, 1]}
     switch_links = [(0, 1), (0, 1), (0, 1)]
     link_vlans = {(0, 1): [0, 1]}
     topo = FaucetFakeOFTopoGenerator(
         '', '', '',
         2, False,
         host_links, host_vlans, switch_links, link_vlans,
         start_port=self.START_PORT, port_order=self.PORT_ORDER,
         get_serialno=self.get_serialno)
     self.assertEqual(len(topo.dpids_by_id), 2)
     self.assertEqual(len(topo.hosts_by_id), 2)
     self.assertEqual(len(topo.switches_by_id), 2)
     _, host_port_maps, link_port_maps = topo.create_port_maps()
     self.assertEqual(len(link_port_maps[(0, 1)]), 3)
     self.assertEqual(len(host_port_maps[0]), 1)
     self.assertEqual(len(host_port_maps[1]), 1)
     host0, host1 = topo.hosts_by_id.values()
     dp0, dp1 = topo.switches_by_id.values()
     links = topo.links()
     self.assertIn((dp0, host0), links)
     self.assertIn((dp1, host1), links)
     self.assertIn((dp0, dp1), links)
     self.assertEqual(links.count((dp0, dp1)), 3)
Exemplo n.º 2
0
 def test_no_links(self):
     """Test single switch topology"""
     host_links = {0: [0]}
     host_vlans = {0: 0}
     switch_links = {}
     link_vlans = {}
     topo = FaucetFakeOFTopoGenerator(
         '', '', '',
         2, False,
         host_links, host_vlans, switch_links, link_vlans,
         start_port=self.START_PORT, port_order=self.PORT_ORDER,
         get_serialno=self.get_serialno)
     self.assertEqual(len(topo.hosts()), 1)
     self.assertEqual(len(topo.switches()), 1)
     self.assertEqual(len(topo.links()), 1)
     host_name = topo.hosts_by_id[0]
     switch_name = topo.switches_by_id[0]
     self.assertEqual((switch_name, host_name), topo.links()[0])