summaryrefslogtreecommitdiffhomepage
path: root/test/scenario_test
diff options
context:
space:
mode:
authorIWASE Yusuke <iwase.yusuke0@gmail.com>2017-07-28 09:50:50 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2017-07-30 15:18:35 +0900
commitd9d963e025b11a9e5ad1cc5dcf7efcf4517a3a2b (patch)
treec6ec138399d6e15f84be89ee03bb49236d7e6616 /test/scenario_test
parentb43809e46ae516a942083362da7487a097718f63 (diff)
addpath_test: Test cases for send add-paths
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Diffstat (limited to 'test/scenario_test')
-rw-r--r--test/scenario_test/addpath_test.py56
1 files changed, 43 insertions, 13 deletions
diff --git a/test/scenario_test/addpath_test.py b/test/scenario_test/addpath_test.py
index 2789c3b2..3c0e5d3c 100644
--- a/test/scenario_test/addpath_test.py
+++ b/test/scenario_test/addpath_test.py
@@ -40,14 +40,12 @@ class GoBGPTestBase(unittest.TestCase):
g2 = GoBGPContainer(name='g2', asn=65000, router_id='192.168.0.2',
ctn_image_name=gobgp_ctn_image_name,
log_level=parser_option.gobgp_log_level)
- e1 = ExaBGPContainer(name='e1', asn=65000, router_id='192.168.0.3')
-
- ctns = [g1, g2, e1]
-
- e1.add_route(route='192.168.100.0/24', identifier=10, aspath=[100, 200, 300])
- e1.add_route(route='192.168.100.0/24', identifier=20, aspath=[100, 200])
- e1.add_route(route='192.168.100.0/24', identifier=30, aspath=[100])
+ g3 = GoBGPContainer(name='g3', asn=65000, router_id='192.168.0.3',
+ ctn_image_name=gobgp_ctn_image_name,
+ log_level=parser_option.gobgp_log_level)
+ e1 = ExaBGPContainer(name='e1', asn=65000, router_id='192.168.0.4')
+ ctns = [g1, g2, g3, e1]
initial_wait_time = max(ctn.run() for ctn in ctns)
time.sleep(initial_wait_time)
@@ -58,15 +56,26 @@ class GoBGPTestBase(unittest.TestCase):
g1.add_peer(g2, addpath=False, is_rr_client=True)
g2.add_peer(g1, addpath=False)
+ g1.add_peer(g3, addpath=True, is_rr_client=True)
+ g3.add_peer(g1, addpath=True)
+
cls.g1 = g1
cls.g2 = g2
+ cls.g3 = g3
cls.e1 = e1
# test each neighbor state is turned establish
- def test_01_neighbor_established(self):
+ def test_00_neighbor_established(self):
self.g1.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=self.g2)
self.g1.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=self.e1)
+ # prepare routes with path_id (no error check)
+ def test_01_prepare_add_paths_routes(self):
+ self.e1.add_route(route='192.168.100.0/24', identifier=10, aspath=[100, 200, 300])
+ self.e1.add_route(route='192.168.100.0/24', identifier=20, aspath=[100, 200])
+ self.e1.add_route(route='192.168.100.0/24', identifier=30, aspath=[100])
+ time.sleep(1) # XXX: wait for routes re-calculated and advertised
+
# test three routes are installed to the rib due to add-path feature
def test_02_check_g1_global_rib(self):
rib = self.g1.get_global_rib()
@@ -78,22 +87,43 @@ class GoBGPTestBase(unittest.TestCase):
rib = self.g2.get_global_rib()
self.assertEqual(len(rib), 1)
self.assertEqual(len(rib[0]['paths']), 1)
- self.assertEqual(rib[0]['paths'][0]["aspath"], [100])
+ self.assertEqual(rib[0]['paths'][0]['aspath'], [100])
- # test a withdraw route with path_id is removed from the rib
- def test_04_withdraw_route_with_path_id(self):
+ # test three routes are advertised to g3
+ def test_04_check_g3_global_rib(self):
+ rib = self.g3.get_global_rib()
+ self.assertEqual(len(rib), 1)
+ self.assertEqual(len(rib[0]['paths']), 3)
+
+ # withdraw a route with path_id (no error check)
+ def test_05_withdraw_route_with_path_id(self):
self.e1.del_route(route='192.168.100.0/24', identifier=30)
+ time.sleep(1) # XXX: wait for routes re-calculated and advertised
+ # test the withdrawn route is removed from the rib
+ def test_06_check_g1_global_rib(self):
rib = self.g1.get_global_rib()
self.assertEqual(len(rib), 1)
self.assertEqual(len(rib[0]['paths']), 2)
+ for path in rib[0]['paths']:
+ self.assertTrue(path['aspath'] == [100, 200, 300] or
+ path['aspath'] == [100, 200])
# test the best path is replaced due to the removal from g1 rib
- def test_05_check_g2_global_rib(self):
+ def test_07_check_g2_global_rib(self):
rib = self.g2.get_global_rib()
self.assertEqual(len(rib), 1)
self.assertEqual(len(rib[0]['paths']), 1)
- self.assertEqual(rib[0]['paths'][0]["aspath"], [100, 200])
+ self.assertEqual(rib[0]['paths'][0]['aspath'], [100, 200])
+
+ # test the withdrawn route is removed from the rib of g3
+ def test_08_check_g3_global_rib(self):
+ rib = self.g3.get_global_rib()
+ self.assertEqual(len(rib), 1)
+ self.assertEqual(len(rib[0]['paths']), 2)
+ for path in rib[0]['paths']:
+ self.assertTrue(path['aspath'] == [100, 200, 300] or
+ path['aspath'] == [100, 200])
if __name__ == '__main__':