diff options
Diffstat (limited to 'test/scenario_test')
-rw-r--r-- | test/scenario_test/bgp_router_test.py | 5 | ||||
-rw-r--r-- | test/scenario_test/gobgp_test.py | 16 | ||||
-rw-r--r-- | test/scenario_test/route_server_policy_test.py | 149 | ||||
-rw-r--r-- | test/scenario_test/route_server_test.py | 2 |
4 files changed, 82 insertions, 90 deletions
diff --git a/test/scenario_test/bgp_router_test.py b/test/scenario_test/bgp_router_test.py index 268f468d..f965d224 100644 --- a/test/scenario_test/bgp_router_test.py +++ b/test/scenario_test/bgp_router_test.py @@ -69,7 +69,6 @@ class GoBGPTest(GoBGPTestBase): self.assert_global_rib() - # Test of advertising route to each quagga form gobgp def test_03_advertising_route(self): print "test_advertising_route" @@ -157,7 +156,7 @@ class GoBGPTest(GoBGPTestBase): still_exists = False for dst in rib: for path in dst['paths']: - if path['network'] == removed_prefix: + if path['nlri']['prefix'] == removed_prefix: still_exists = True if not still_exists: @@ -236,7 +235,7 @@ class GoBGPTest(GoBGPTestBase): print "please wait " + str(self.initial_wait_time) + " second" time.sleep(self.initial_wait_time) - target_network = "192.168.20.0" + target_network = "192.168.20.0/24" ans_nexthop = "10.0.0.3" print "check whether target network %s 's nexthop is %s" % (target_network, ans_nexthop) diff --git a/test/scenario_test/gobgp_test.py b/test/scenario_test/gobgp_test.py index 2e998178..d3bcdc21 100644 --- a/test/scenario_test/gobgp_test.py +++ b/test/scenario_test/gobgp_test.py @@ -100,7 +100,7 @@ class GoBGPTestBase(unittest.TestCase): for g_path in g_paths: print "best_path_Idx: " + str(best_path_idx) + ", idx: " + str(idx) print g_dest - print "pre: ", g_dest['prefix'], "net: ", g_path['network'], "next: ", g_path['nexthop'] + print "pre: ", g_dest['prefix'], "net: ", g_path['nlri']['prefix'], "next: ", g_path['nexthop'] if str(best_path_idx) == str(idx): rep_nexthop = g_path['nexthop'] idx += 1 @@ -146,13 +146,12 @@ class GoBGPTestBase(unittest.TestCase): continue for network in networks: elems = network.text.split(" ") - prefix = elems[1].split("/")[0] network = elems[1] nexthop = peer_ip path = Path(network, nexthop) - dest = Destination(prefix) + dest = Destination(network) dest.paths.append(path) - quagga_config.destinations[prefix] = dest + quagga_config.destinations[network] = dest # print "prefix: " + prefix # print "network: " + network # print "nexthop: " + nexthop @@ -240,7 +239,7 @@ class GoBGPTestBase(unittest.TestCase): retry_count = 0 while True: rib = self.ask_gobgp(type, neighbor_address) - paths = [p for p in rib if p['network'] == target_prefix] + paths = [p for p in rib if p['nlri']['prefix'] == target_prefix] if len(paths) > 0: assert len(paths) == 1 @@ -264,12 +263,15 @@ class GoBGPTestBase(unittest.TestCase): interval = self.wait_per_retry print "check route %s on quagga : %s" % (target_prefix, neighbor_address) retry_count = 0 + + # quagga cli doesn't show prefix's netmask + quagga_prefix = target_prefix.split('/')[0] while True: tn = qaccess.login(neighbor_address) q_rib = qaccess.show_rib(tn) qaccess.logout(tn) for q_path in q_rib: - if target_prefix == q_path['Network']: + if quagga_prefix == q_path['Network']: return q_path retry_count += 1 @@ -342,7 +344,7 @@ class GoBGPTestBase(unittest.TestCase): exist = False for dst in rib: for path in dst['paths']: - if path['network'] == p.network: + if path['nlri']['prefix'] == p.network: exist = True if exist: is_nexthop_same = path['nexthop'] == p.nexthop diff --git a/test/scenario_test/route_server_policy_test.py b/test/scenario_test/route_server_policy_test.py index 9ae29a2b..7c2e0456 100644 --- a/test/scenario_test/route_server_policy_test.py +++ b/test/scenario_test/route_server_policy_test.py @@ -25,6 +25,13 @@ from noseplugin import parser_option from gobgp_test import GoBGPTestBase from constant import * +peer1 = "10.0.0.1" +peer2 = "10.0.0.2" +peer3 = "10.0.0.3" + +prefix1 = "192.168.2.0/24" +prefix2 = "192.168.20.0/24" +prefix3 = "192.168.200.0/24" class GoBGPTest(GoBGPTestBase): @@ -60,29 +67,25 @@ class GoBGPTest(GoBGPTestBase): addresses = self.get_neighbor_address(self.gobgp_config) self.retry_routine_for_state(addresses, "BGP_FSM_ESTABLISHED") - peer1 = "10.0.0.1" - peer2 = "10.0.0.2" - peer3 = "10.0.0.3" - - path = self.get_paths_in_localrib(peer1, "192.168.2.0", retry=3) + path = self.get_paths_in_localrib(peer1, prefix1, retry=3) self.assertIsNotNone(path) # check show ip bgp on peer1(quagga1) - qpath = self.get_routing_table(peer1,"192.168.2.0", retry=3) + qpath = self.get_routing_table(peer1,prefix1, retry=3) print qpath self.assertIsNotNone(qpath) # check adj-rib-out in peer2 - path = self.get_adj_rib_in(peer2, "192.168.2.0/24", retry=3) + path = self.get_adj_rib_in(peer2, prefix1, retry=3) # print path self.assertIsNotNone(path) - path = self.get_paths_in_localrib(peer3, "192.168.2.0",retry=0) + path = self.get_paths_in_localrib(peer3, prefix1,retry=0) # print path self.assertIsNone(path) # check show ip bgp on peer1(quagga3) - qpath = self.get_routing_table(peer3,"192.168.2.0", retry=3) + qpath = self.get_routing_table(peer3,prefix1, retry=3) # print qpath self.assertIsNone(qpath) @@ -104,34 +107,30 @@ class GoBGPTest(GoBGPTestBase): addresses = self.get_neighbor_address(self.gobgp_config) self.retry_routine_for_state(addresses, "BGP_FSM_ESTABLISHED") - peer1 = "10.0.0.1" - peer2 = "10.0.0.2" - peer3 = "10.0.0.3" - - paths = self.get_paths_in_localrib(peer1, "192.168.2.0", retry=3) + paths = self.get_paths_in_localrib(peer1, prefix1, retry=3) # print paths self.assertIsNotNone(paths) # check show ip bgp on peer1(quagga1) - qpath = self.get_routing_table(peer1, "192.168.2.0", retry=3) + qpath = self.get_routing_table(peer1, prefix1, retry=3) # print qpath self.assertIsNotNone(qpath) # check adj-rib-out in peer2 - path = self.get_adj_rib_in(peer2, "192.168.2.0/24", retry=1) + path = self.get_adj_rib_in(peer2, prefix1, retry=1) # print path self.assertIsNotNone(path) - path = self.get_paths_in_localrib(peer3, "192.168.2.0") + path = self.get_paths_in_localrib(peer3, prefix1) # print path self.assertIsNotNone(path) - path = self.get_adj_rib_out(peer3, "192.168.2.0", retry=1) + path = self.get_adj_rib_out(peer3, prefix1, retry=1) # print path self.assertIsNone(path) # check show ip bgp on peer1(quagga3) - qpath = self.get_routing_table(peer3,"192.168.2.0", retry=3) + qpath = self.get_routing_table(peer3,prefix1, retry=3) # print qpath self.assertIsNone(qpath) @@ -167,16 +166,12 @@ class GoBGPTest(GoBGPTestBase): # coming from peer2(10.0.0.2) to peer3(10.0.0.3)'s import-policy. self.initialize(policy_pattern="p3") - peer1 = "10.0.0.1" - peer2 = "10.0.0.2" - peer3 = "10.0.0.3" - # add other network tn = qaccess.login(peer2) print "add network 192.168.20.0/24" - qaccess.add_network(tn, 65002, "192.168.20.0/24") + qaccess.add_network(tn, 65002, prefix2) print "add network 192.168.200.0/24" - qaccess.add_network(tn, 65002, "192.168.200.0/24") + qaccess.add_network(tn, 65002, prefix3) qaccess.logout(tn) addresses = self.get_neighbor_address(self.gobgp_config) @@ -197,28 +192,28 @@ class GoBGPTest(GoBGPTestBase): return path is not None - self.assertTrue(path_exists_in_localrib(peer1,"192.168.2.0")) - self.assertTrue(path_exists_in_localrib(peer1,"192.168.20.0")) - self.assertTrue(path_exists_in_localrib(peer1,"192.168.200.0")) + self.assertTrue(path_exists_in_localrib(peer1,prefix1)) + self.assertTrue(path_exists_in_localrib(peer1,prefix2)) + self.assertTrue(path_exists_in_localrib(peer1,prefix3)) - self.assertTrue(path_exists_in_localrib(peer3,"192.168.2.0")) - self.assertFalse(path_exists_in_localrib(peer3,"192.168.20.0",r=3)) - self.assertFalse(path_exists_in_localrib(peer3,"192.168.200.0",r=0)) + self.assertTrue(path_exists_in_localrib(peer3,prefix1)) + self.assertFalse(path_exists_in_localrib(peer3,prefix2,r=3)) + self.assertFalse(path_exists_in_localrib(peer3,prefix3,r=0)) # check show ip bgp on peer1(quagga1) - self.assertTrue(path_exists_in_routing_table(peer1, "192.168.2.0")) - self.assertTrue(path_exists_in_routing_table(peer1, "192.168.20.0")) - self.assertTrue(path_exists_in_routing_table(peer1, "192.168.200.0")) + self.assertTrue(path_exists_in_routing_table(peer1, prefix1)) + self.assertTrue(path_exists_in_routing_table(peer1, prefix2)) + self.assertTrue(path_exists_in_routing_table(peer1, prefix3)) # check show ip bgp on peer3(quagga3) - self.assertTrue(path_exists_in_routing_table(peer3, "192.168.2.0")) - self.assertFalse(path_exists_in_routing_table(peer3, "192.168.20.0",r=3)) - self.assertFalse(path_exists_in_routing_table(peer3, "192.168.200.0",r=0)) + self.assertTrue(path_exists_in_routing_table(peer3, prefix1)) + self.assertFalse(path_exists_in_routing_table(peer3, prefix2,r=3)) + self.assertFalse(path_exists_in_routing_table(peer3, prefix3,r=0)) # check adj-rib-out in peer2 - self.assertTrue(path_exists_in_adj_rib_in(peer2, "192.168.2.0/24")) - self.assertTrue(path_exists_in_adj_rib_in(peer2, "192.168.20.0/24")) - self.assertTrue(path_exists_in_adj_rib_in(peer2, "192.168.200.0/24")) + self.assertTrue(path_exists_in_adj_rib_in(peer2, prefix1)) + self.assertTrue(path_exists_in_adj_rib_in(peer2, prefix2)) + self.assertTrue(path_exists_in_adj_rib_in(peer2, prefix3)) # update policy print "update_policy_config" @@ -230,14 +225,14 @@ class GoBGPTest(GoBGPTestBase): self.soft_reset(peer2, IPv4) # check local-rib - self.assertTrue(path_exists_in_localrib(peer3,"192.168.2.0")) - self.assertFalse(path_exists_in_localrib(peer3,"192.168.20.0",r=3)) - self.assertTrue(path_exists_in_localrib(peer3,"192.168.200.0")) + self.assertTrue(path_exists_in_localrib(peer3,prefix1)) + self.assertFalse(path_exists_in_localrib(peer3,prefix2,r=3)) + self.assertTrue(path_exists_in_localrib(peer3,prefix3)) # check show ip bgp on peer3(quagga3) - self.assertTrue(path_exists_in_routing_table(peer3, "192.168.2.0")) - self.assertFalse(path_exists_in_routing_table(peer3, "192.168.20.0",r=0)) - self.assertTrue(path_exists_in_routing_table(peer3, "192.168.200.0")) + self.assertTrue(path_exists_in_routing_table(peer3, prefix1)) + self.assertFalse(path_exists_in_routing_table(peer3, prefix2,r=0)) + self.assertTrue(path_exists_in_routing_table(peer3, prefix3)) """ @@ -272,16 +267,12 @@ class GoBGPTest(GoBGPTestBase): # coming from peer2(10.0.0.2) to peer3(10.0.0.3)'s export-policy. self.initialize(policy_pattern="p4") - peer1 = "10.0.0.1" - peer2 = "10.0.0.2" - peer3 = "10.0.0.3" - # add other network tn = qaccess.login(peer2) print "add network 192.168.20.0/24" - qaccess.add_network(tn, 65002, "192.168.20.0/24") + qaccess.add_network(tn, 65002, prefix2) print "add network 192.168.200.0/24" - qaccess.add_network(tn, 65002, "192.168.200.0/24") + qaccess.add_network(tn, 65002, prefix3) qaccess.logout(tn) addresses = self.get_neighbor_address(self.gobgp_config) @@ -306,35 +297,35 @@ class GoBGPTest(GoBGPTestBase): return path is not None - self.assertTrue(path_exists_in_localrib(peer1,"192.168.2.0")) - self.assertTrue(path_exists_in_localrib(peer1,"192.168.20.0")) - self.assertTrue(path_exists_in_localrib(peer1,"192.168.200.0")) + self.assertTrue(path_exists_in_localrib(peer1,prefix1)) + self.assertTrue(path_exists_in_localrib(peer1,prefix2)) + self.assertTrue(path_exists_in_localrib(peer1,prefix3)) # check peer3 local-rib - self.assertTrue(path_exists_in_localrib(peer3,"192.168.2.0")) - self.assertTrue(path_exists_in_localrib(peer3,"192.168.20.0")) - self.assertTrue(path_exists_in_localrib(peer3,"192.168.200.0")) + self.assertTrue(path_exists_in_localrib(peer3,prefix1)) + self.assertTrue(path_exists_in_localrib(peer3,prefix2)) + self.assertTrue(path_exists_in_localrib(peer3,prefix3)) # check peer3 rib-out - self.assertTrue(path_exists_in_adj_rib_out(peer3,"192.168.2.0/24")) - self.assertFalse(path_exists_in_adj_rib_out(peer3,"192.168.20.0/24",r=3)) - self.assertFalse(path_exists_in_adj_rib_out(peer3,"192.168.200.0/24",r=3)) + self.assertTrue(path_exists_in_adj_rib_out(peer3,prefix1)) + self.assertFalse(path_exists_in_adj_rib_out(peer3,prefix2,r=3)) + self.assertFalse(path_exists_in_adj_rib_out(peer3,prefix3,r=3)) # check show ip bgp on peer1(quagga1) - self.assertTrue(path_exists_in_routing_table(peer1, "192.168.2.0")) - self.assertTrue(path_exists_in_routing_table(peer1, "192.168.20.0")) - self.assertTrue(path_exists_in_routing_table(peer1, "192.168.200.0")) + self.assertTrue(path_exists_in_routing_table(peer1, prefix1)) + self.assertTrue(path_exists_in_routing_table(peer1, prefix2)) + self.assertTrue(path_exists_in_routing_table(peer1, prefix3)) # check show ip bgp on peer3(quagga3) - self.assertTrue(path_exists_in_routing_table(peer3, "192.168.2.0")) - self.assertFalse(path_exists_in_routing_table(peer3, "192.168.20.0",r=3)) - self.assertFalse(path_exists_in_routing_table(peer3, "192.168.200.0",r=0)) + self.assertTrue(path_exists_in_routing_table(peer3, prefix1)) + self.assertFalse(path_exists_in_routing_table(peer3, prefix2,r=3)) + self.assertFalse(path_exists_in_routing_table(peer3, prefix3,r=0)) # check adj-rib-out in peer2 peer2 = "10.0.0.2" - self.assertTrue(path_exists_in_adj_rib_in(peer2, "192.168.2.0/24")) - self.assertTrue(path_exists_in_adj_rib_in(peer2, "192.168.20.0/24")) - self.assertTrue(path_exists_in_adj_rib_in(peer2, "192.168.200.0/24")) + self.assertTrue(path_exists_in_adj_rib_in(peer2, prefix1)) + self.assertTrue(path_exists_in_adj_rib_in(peer2, prefix2)) + self.assertTrue(path_exists_in_adj_rib_in(peer2, prefix3)) # update policy print "update_policy_config" @@ -346,19 +337,19 @@ class GoBGPTest(GoBGPTestBase): self.soft_reset(peer2, IPv4) # check local-rib - self.assertTrue(path_exists_in_localrib(peer3,"192.168.2.0")) - self.assertTrue(path_exists_in_localrib(peer3,"192.168.20.0")) - self.assertTrue(path_exists_in_localrib(peer3,"192.168.200.0")) + self.assertTrue(path_exists_in_localrib(peer3,prefix1)) + self.assertTrue(path_exists_in_localrib(peer3,prefix2)) + self.assertTrue(path_exists_in_localrib(peer3,prefix3)) # check local-adj-out-rib - self.assertTrue(path_exists_in_adj_rib_out(peer3, "192.168.2.0/24")) - self.assertFalse(path_exists_in_adj_rib_out(peer3, "192.168.20.0/24",r=3)) - self.assertTrue(path_exists_in_adj_rib_out(peer3, "192.168.200.0/24")) + self.assertTrue(path_exists_in_adj_rib_out(peer3, prefix1)) + self.assertFalse(path_exists_in_adj_rib_out(peer3, prefix2,r=3)) + self.assertTrue(path_exists_in_adj_rib_out(peer3, prefix3)) # check show ip bgp on peer3(quagga3) - self.assertTrue(path_exists_in_routing_table(peer3, "192.168.2.0")) - self.assertFalse(path_exists_in_routing_table(peer3, "192.168.20.0",r=3)) - self.assertTrue(path_exists_in_routing_table(peer3, "192.168.200.0")) + self.assertTrue(path_exists_in_routing_table(peer3, prefix1)) + self.assertFalse(path_exists_in_routing_table(peer3, prefix2,r=3)) + self.assertTrue(path_exists_in_routing_table(peer3, prefix3)) if __name__ == '__main__': diff --git a/test/scenario_test/route_server_test.py b/test/scenario_test/route_server_test.py index 603ffecd..61c94eb0 100644 --- a/test/scenario_test/route_server_test.py +++ b/test/scenario_test/route_server_test.py @@ -188,7 +188,7 @@ class GoBGPTest(GoBGPTestBase): time.sleep(self.initial_wait_time) check_address = "10.0.0.1" - target_network = "192.168.20.0" + target_network = "192.168.20.0/24" ans_nexthop = "10.0.0.3" print "check of [ " + check_address + " ]" |