diff options
author | mageshgv <mageshgv@gmail.com> | 2019-10-16 15:18:38 -0700 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@gmail.com> | 2019-10-18 07:28:10 +0900 |
commit | 29412028a7ab41fd953a0ea5cc87a728b212ab17 (patch) | |
tree | 1c4bf290cac55484119820373f331967fc06eb61 /test | |
parent | 0794811562fdad2affbf48200b88e36cad88a578 (diff) |
Fix adj-out display with add path enabled
Diffstat (limited to 'test')
-rw-r--r-- | test/lib/gobgp.py | 13 | ||||
-rw-r--r-- | test/scenario_test/addpath_test.py | 34 |
2 files changed, 34 insertions, 13 deletions
diff --git a/test/lib/gobgp.py b/test/lib/gobgp.py index 1abdb782..6ffa6024 100644 --- a/test/lib/gobgp.py +++ b/test/lib/gobgp.py @@ -277,12 +277,15 @@ class GoBGPContainer(BGPContainer): t.daemon = True t.start() - def _get_adj_rib(self, adj_type, peer, prefix='', rf='ipv4'): + def _get_adj_rib(self, adj_type, peer, prefix='', rf='ipv4', add_path_enabled=False): peer_addr = self.peer_name(peer) cmd = 'gobgp neighbor {0} adj-{1} {2} -a {3} -j'.format(peer_addr, adj_type, prefix, rf) output = self.local(cmd, capture=True) + if add_path_enabled: + return self._get_rib(json.loads(output)) + ret = [p[0] for p in json.loads(output).values()] for p in ret: p["nexthop"] = self._get_nexthop(p) @@ -292,11 +295,11 @@ class GoBGPContainer(BGPContainer): p["med"] = self._get_med(p) return ret - def get_adj_rib_in(self, peer, prefix='', rf='ipv4'): - return self._get_adj_rib('in', peer, prefix, rf) + def get_adj_rib_in(self, peer, prefix='', rf='ipv4', add_path_enabled=False): + return self._get_adj_rib('in', peer, prefix, rf, add_path_enabled) - def get_adj_rib_out(self, peer, prefix='', rf='ipv4'): - return self._get_adj_rib('out', peer, prefix, rf) + def get_adj_rib_out(self, peer, prefix='', rf='ipv4', add_path_enabled=False): + return self._get_adj_rib('out', peer, prefix, rf, add_path_enabled) def get_neighbor(self, peer): cmd = 'gobgp -j neighbor {0}'.format(self.peer_name(peer)) diff --git a/test/scenario_test/addpath_test.py b/test/scenario_test/addpath_test.py index c8a8491b..23d3b5cb 100644 --- a/test/scenario_test/addpath_test.py +++ b/test/scenario_test/addpath_test.py @@ -164,8 +164,17 @@ class GoBGPTestBase(unittest.TestCase): assert_several_times(f) + def test_11_check_g1_adj_out(self): + adj_out = self.g1.get_adj_rib_out(self.g2, add_path_enabled=True) + self.assertEqual(len(adj_out), 1) + self.assertEqual(len(adj_out[0]['paths']), 1) + + adj_out = self.g1.get_adj_rib_out(self.g3, add_path_enabled=True) + self.assertEqual(len(adj_out), 1) + self.assertEqual(len(adj_out[0]['paths']), 3) + # test the best path is replaced due to the CLI route from g1 rib - def test_11_check_g2_global_rib(self): + def test_12_check_g2_global_rib(self): def f(): rib = self.g2.get_global_rib() self.assertEqual(len(rib), 1) @@ -175,7 +184,7 @@ class GoBGPTestBase(unittest.TestCase): assert_several_times(f) # test the route from CLI is advertised from g1 - def test_12_check_g3_global_rib(self): + def test_13_check_g3_global_rib(self): def f(): rib = self.g3.get_global_rib() self.assertEqual(len(rib), 1) @@ -190,13 +199,13 @@ class GoBGPTestBase(unittest.TestCase): assert_several_times(f) # remove non-existing route with path_id via GoBGP CLI (no error check) - def test_13_remove_non_existing_add_paths_route_via_cli(self): + def test_14_remove_non_existing_add_paths_route_via_cli(self): # specify locally non-existing identifier which has the same value # with the identifier of the route from e1 self.g1.del_route(route='192.168.100.0/24', identifier=20) # test none of route is removed by non-existing path_id via CLI - def test_14_check_g1_global_rib(self): + def test_15_check_g1_global_rib(self): def f(): rib = self.g1.get_global_rib() self.assertEqual(len(rib), 1) @@ -211,11 +220,20 @@ class GoBGPTestBase(unittest.TestCase): assert_several_times(f) # remove route with path_id via GoBGP CLI (no error check) - def test_15_remove_add_paths_route_via_cli(self): + def test_16_remove_add_paths_route_via_cli(self): self.g1.del_route(route='192.168.100.0/24', identifier=10) + def test_17_check_g1_adj_out(self): + adj_out = self.g1.get_adj_rib_out(self.g2, add_path_enabled=True) + self.assertEqual(len(adj_out), 1) + self.assertEqual(len(adj_out[0]['paths']), 1) + + adj_out = self.g1.get_adj_rib_out(self.g3, add_path_enabled=True) + self.assertEqual(len(adj_out), 1) + self.assertEqual(len(adj_out[0]['paths']), 2) + # test the route is removed from the rib via CLI - def test_16_check_g1_global_rib(self): + def test_18_check_g1_global_rib(self): def f(): rib = self.g1.get_global_rib() self.assertEqual(len(rib), 1) @@ -227,7 +245,7 @@ class GoBGPTestBase(unittest.TestCase): assert_several_times(f) # test the best path is replaced the removal from g1 rib - def test_17_check_g2_global_rib(self): + def test_19_check_g2_global_rib(self): def f(): rib = self.g2.get_global_rib() self.assertEqual(len(rib), 1) @@ -237,7 +255,7 @@ class GoBGPTestBase(unittest.TestCase): assert_several_times(f) # test the removed route from CLI is withdrawn by g1 - def test_18_check_g3_global_rib(self): + def test_20_check_g3_global_rib(self): def f(): rib = self.g3.get_global_rib() self.assertEqual(len(rib), 1) |