diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-11-07 19:44:59 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-11-08 05:05:36 -0800 |
commit | 2f6db55c6743cdd568f1555b91017a6f2c09695d (patch) | |
tree | f022bb9bae68b89d3a682edeb2bfcdac7005eedb /test/scenario_test/bgp_router_test.py | |
parent | d53a5d11d9f3b0ee762a0510ff6608e69ed595ff (diff) |
scenario_test: test local-pref and med handling
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'test/scenario_test/bgp_router_test.py')
-rw-r--r-- | test/scenario_test/bgp_router_test.py | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/test/scenario_test/bgp_router_test.py b/test/scenario_test/bgp_router_test.py index 804003aa..7e985552 100644 --- a/test/scenario_test/bgp_router_test.py +++ b/test/scenario_test/bgp_router_test.py @@ -95,7 +95,7 @@ class GoBGPTestBase(unittest.TestCase): def test_03_check_gobgp_adj_out_rib(self): for q in self.quaggas.itervalues(): for path in self.gobgp.get_adj_rib_out(q): - asns = path['as_path'] + asns = path['aspath'] self.assertTrue(self.gobgp.asn in asns) # check routes are properly advertised to all BGP speaker @@ -219,7 +219,7 @@ class GoBGPTestBase(unittest.TestCase): self.assertTrue(len(dst[0]['paths']) == 1) path = dst[0]['paths'][0] self.assertTrue(path['nexthop'] == '0.0.0.0') - self.assertTrue(len(path['as_path']) == 0) + self.assertTrue(len(path['aspath']) == 0) def test_11_check_adj_rib_out(self): for q in self.quaggas.itervalues(): @@ -229,7 +229,7 @@ class GoBGPTestBase(unittest.TestCase): peer_info = self.gobgp.peers[q] local_addr = peer_info['local_addr'].split('/')[0] self.assertTrue(path['nexthop'] == local_addr) - self.assertTrue(path['as_path'] == [self.gobgp.asn]) + self.assertTrue(path['aspath'] == [self.gobgp.asn]) def test_12_disable_peer(self): q1 = self.quaggas['q1'] @@ -262,12 +262,37 @@ class GoBGPTestBase(unittest.TestCase): ctn_image_name=self.gobgp.image, log_level=parser_option.gobgp_log_level) g2.run() + self.quaggas['g2'] = g2 br01 = self.bridges['br01'] br01.addif(g2) g2.add_peer(g1, passive=True) g1.add_peer(g2) g1.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=g2) + def test_16_check_local_pref_and_med_handling(self): + g1 = self.gobgp + g1.add_route('10.20.0.0/24', local_pref=1000, med=2000) + # iBGP peer + g2 = self.quaggas['g2'] + paths = g2.get_global_rib('10.20.0.0/24') + self.assertTrue(len(paths) == 1) + self.assertTrue(len(paths[0]['paths']) == 1) + path = paths[0]['paths'][0] + local_pref = extract_path_attribute(path, BGP_ATTR_TYPE_LOCAL_PREF) + self.assertTrue(local_pref['value'] == 1000) + med = extract_path_attribute(path, BGP_ATTR_TYPE_MULTI_EXIT_DISC) + self.assertTrue(med['metric'] == 2000) + + # eBGP peer + q1 = self.quaggas['q1'] + paths = q1.get_global_rib('10.20.0.0/24') + self.assertTrue(len(paths) == 1) + path = paths[0] + local_pref = extract_path_attribute(path, BGP_ATTR_TYPE_LOCAL_PREF) + # local_pref's default value is 100 + self.assertTrue(local_pref['value'] == 100) + med = extract_path_attribute(path, BGP_ATTR_TYPE_MULTI_EXIT_DISC) + self.assertTrue(med['metric'] == 2000) if __name__ == '__main__': if os.geteuid() is not 0: |