diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2018-07-10 14:06:08 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2018-08-08 21:24:48 +0900 |
commit | 71e56c542e6a167dc3cd983aae2881a3c24c162a (patch) | |
tree | a449e3ed0889940fe47bb5f4ffca91228a4cc7e8 /test | |
parent | 3dc23d3075f13f2976afd255ef2fd9b1410acc77 (diff) |
rpc cleanup
- clean up RPC function names
- rewrite gobgp command to use the api instead of config package
- delete unused client package
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'test')
-rw-r--r-- | test/lib/gobgp.py | 12 | ||||
-rw-r--r-- | test/scenario_test/aspath_test.py | 18 | ||||
-rw-r--r-- | test/scenario_test/route_server_softreset_test.py | 11 | ||||
-rw-r--r-- | test/scenario_test/route_server_test2.py | 8 | ||||
-rw-r--r-- | test/scenario_test/rtc_test.py | 4 |
5 files changed, 32 insertions, 21 deletions
diff --git a/test/lib/gobgp.py b/test/lib/gobgp.py index bc1f96e9..72a9bc2d 100644 --- a/test/lib/gobgp.py +++ b/test/lib/gobgp.py @@ -42,6 +42,9 @@ from lib.base import ( BGP_ATTR_TYPE_MP_REACH_NLRI, GRACEFUL_RESTART_TIME, LONG_LIVED_GRACEFUL_RESTART_TIME, + BGP_FSM_IDLE, + BGP_FSM_ACTIVE, + BGP_FSM_ESTABLISHED, ) @@ -299,7 +302,14 @@ class GoBGPContainer(BGPContainer): return json.loads(self.local(cmd, capture=True)) def get_neighbor_state(self, peer): - return self.get_neighbor(peer)['state']['session-state'] + s = self.get_neighbor(peer)['state']['session_state'] + if s == 1: + return BGP_FSM_IDLE + elif s == 3: + return BGP_FSM_ACTIVE + elif s == 6: + return BGP_FSM_ESTABLISHED + return "unknown" def clear_policy(self): self.policies = {} diff --git a/test/scenario_test/aspath_test.py b/test/scenario_test/aspath_test.py index 25518bfa..d6349efe 100644 --- a/test/scenario_test/aspath_test.py +++ b/test/scenario_test/aspath_test.py @@ -73,12 +73,12 @@ class GoBGPTestBase(unittest.TestCase): def test_02_check_reject_as_loop(self): def f(): - adj = self.g2.get_neighbor(self.q1)['state']['adj-table'] - self.assertTrue('received' in adj) - self.assertEqual(adj['received'], 1) + s = self.g2.get_neighbor(self.q1)['state'] + self.assertTrue('received' in s) + self.assertEqual(s.get('received', 0), 1) # hacky. 'accepted' is zero so the key was deleted due to # omitempty tag in bgp_configs.go. - self.assertFalse('accepted' in adj) + self.assertFalse('accepted' in s) assert_several_times(f) @@ -89,11 +89,11 @@ class GoBGPTestBase(unittest.TestCase): def test_04_check_accept_as_loop(self): def f(): - adj = self.g2.get_neighbor(self.q1)['state']['adj-table'] - self.assertTrue('received' in adj) - self.assertEqual(adj['received'], 1) - self.assertTrue('accepted' in adj) - self.assertEqual(adj['accepted'], 1) + s = self.g2.get_neighbor(self.q1)['state'] + self.assertTrue('received' in s) + self.assertEqual(s.get('received', 0), 1) + self.assertTrue('accepted' in s) + self.assertEqual(s.get('accepted', 0), 1) assert_several_times(f) diff --git a/test/scenario_test/route_server_softreset_test.py b/test/scenario_test/route_server_softreset_test.py index 23f646eb..90096be0 100644 --- a/test/scenario_test/route_server_softreset_test.py +++ b/test/scenario_test/route_server_softreset_test.py @@ -95,7 +95,8 @@ class GoBGPTestBase(unittest.TestCase): time.sleep(1) - num = g2.get_neighbor(g1)['state']['messages']['received']['update'] + num = g2.get_neighbor(g1)['state']['messages']['received'].get('update', 0) + num = g2.get_neighbor(g1)['state']['messages']['received'].get('update', 0) ps0 = {'prefix-set-name': 'ps0', 'prefix-list': [p1]} g1.set_prefix_set(ps0) @@ -105,14 +106,14 @@ class GoBGPTestBase(unittest.TestCase): time.sleep(1) - num2 = g2.get_neighbor(g1)['state']['messages']['received']['update'] + num2 = g2.get_neighbor(g1)['state']['messages']['received'].get('update', 0) self.assertTrue((num + 1) == num2) g3.softreset(g1, type='out') time.sleep(1) - num3 = g2.get_neighbor(g1)['state']['messages']['received']['update'] + num3 = g2.get_neighbor(g1)['state']['messages']['received'].get('update', 0) self.assertTrue(num2 == num3) def test_03_softresetin_test2(self): @@ -122,13 +123,13 @@ class GoBGPTestBase(unittest.TestCase): g2.add_route('10.0.10.0/24') time.sleep(1) - num = g2.get_neighbor(g1)['state']['messages']['received']['update'] + num = g2.get_neighbor(g1)['state']['messages']['received'].get('update', 0) time.sleep(3) g1.local('gobgp n all softresetin') time.sleep(3) - num1 = g2.get_neighbor(g1)['state']['messages']['received']['update'] + num1 = g2.get_neighbor(g1)['state']['messages']['received'].get('update', 0) self.assertTrue(num == num1) diff --git a/test/scenario_test/route_server_test2.py b/test/scenario_test/route_server_test2.py index 61c546b8..3bbfeada 100644 --- a/test/scenario_test/route_server_test2.py +++ b/test/scenario_test/route_server_test2.py @@ -89,10 +89,10 @@ class GoBGPTestBase(unittest.TestCase): def test_04_withdraw_path(self): self.clients['g2'].local('gobgp global rib del 10.0.0.0/24') time.sleep(1) - info = self.gobgp.get_neighbor(self.clients['g2'])['state']['adj-table'] - self.assertTrue(info['advertised'] == 1) - self.assertTrue('accepted' not in info) # means info['accepted'] == 0 - self.assertTrue('received' not in info) # means info['received'] == 0 + s = self.gobgp.get_neighbor(self.clients['g2'])['state'] + self.assertTrue(s.get('advertised', 0) == 1) + self.assertTrue(s.get('accepted') == None) # means info['accepted'] == 0 + self.assertTrue(s.get('received') == None) # means info['received'] == 0 if __name__ == '__main__': diff --git a/test/scenario_test/rtc_test.py b/test/scenario_test/rtc_test.py index 13bc8b25..98a91c70 100644 --- a/test/scenario_test/rtc_test.py +++ b/test/scenario_test/rtc_test.py @@ -38,8 +38,8 @@ class GoBGPTestBase(unittest.TestCase): def assert_upd_count(self, src, dst, sent, received): messages = src.get_neighbor(dst)['state']['messages'] - self.assertEqual(messages['sent']['update'], sent) - self.assertEqual(messages['received']['update'], received) + self.assertEqual(messages['sent'].get('update', 0), sent) + self.assertEqual(messages['received'].get('update', 0), received) @classmethod def setUpClass(cls): |