summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorWataru Ishida <ishida.wataru@lab.ntt.co.jp>2016-08-20 19:15:53 +0000
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-08-25 15:53:14 +0900
commit3235c0618cfc320c0ad751d83d850ec714fa1c49 (patch)
tree9bbc51cdb4e549dcb0567248d16c99dffd74e68d /test
parentb3c874da2581eb71d8c137d956e792565193ec0e (diff)
api/cli: kill cmd package custom path/destination structs
reuse table package Signed-off-by: Wataru Ishida <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'test')
-rw-r--r--test/lib/gobgp.py20
-rw-r--r--test/scenario_test/bgp_router_test.py8
-rw-r--r--test/scenario_test/graceful_restart_test.py2
-rw-r--r--test/scenario_test/monitor_test.py2
4 files changed, 19 insertions, 13 deletions
diff --git a/test/lib/gobgp.py b/test/lib/gobgp.py
index d16610f0..316e8535 100644
--- a/test/lib/gobgp.py
+++ b/test/lib/gobgp.py
@@ -121,23 +121,29 @@ class GoBGPContainer(BGPContainer):
cmd = 'gobgp -j neighbor {0} local {1} -a {2}'.format(peer_addr, prefix, rf)
output = self.local(cmd, capture=True)
ret = json.loads(output)
- for d in ret:
- for p in d["paths"]:
+ dsts = []
+ for k, v in ret.iteritems():
+ for p in v:
p["nexthop"] = self._get_nexthop(p)
p["aspath"] = self._get_as_path(p)
p["local-pref"] = self._get_local_pref(p)
- return ret
+ p["prefix"] = k
+ dsts.append({'paths': v, 'prefix': k})
+ return dsts
def get_global_rib(self, prefix='', rf='ipv4'):
cmd = 'gobgp -j global rib {0} -a {1}'.format(prefix, rf)
output = self.local(cmd, capture=True)
ret = json.loads(output)
- for d in ret:
- for p in d["paths"]:
+ dsts = []
+ for k, v in ret.iteritems():
+ for p in v:
p["nexthop"] = self._get_nexthop(p)
p["aspath"] = self._get_as_path(p)
p["local-pref"] = self._get_local_pref(p)
- return ret
+ p["prefix"] = k
+ dsts.append({'paths': v, 'prefix': k})
+ return dsts
def monitor_global_rib(self, queue, rf='ipv4'):
host = self.ip_addrs[0][1].split('/')[0]
@@ -168,7 +174,7 @@ class GoBGPContainer(BGPContainer):
adj_type,
prefix, rf)
output = self.local(cmd, capture=True)
- ret = [p["paths"][0] for p in json.loads(output)]
+ ret = [p[0] for p in json.loads(output).itervalues()]
for p in ret:
p["nexthop"] = self._get_nexthop(p)
p["aspath"] = self._get_as_path(p)
diff --git a/test/scenario_test/bgp_router_test.py b/test/scenario_test/bgp_router_test.py
index f6831f79..3154df21 100644
--- a/test/scenario_test/bgp_router_test.py
+++ b/test/scenario_test/bgp_router_test.py
@@ -333,10 +333,10 @@ class GoBGPTestBase(unittest.TestCase):
paths = g1.get_adj_rib_out(q1, '30.0.0.0/24')
self.assertTrue(len(paths) == 1)
- self.assertTrue(paths[0]['source-id'] == '<nil>')
+ self.assertTrue('source-id' not in paths[0])
paths = g1.get_adj_rib_out(q2, '30.0.0.0/24')
self.assertTrue(len(paths) == 1)
- self.assertTrue(paths[0]['source-id'] == '<nil>')
+ self.assertTrue('source-id' not in paths[0])
g1.local('gobgp global rib del 30.0.0.0/24')
@@ -405,8 +405,8 @@ class GoBGPTestBase(unittest.TestCase):
cnt2 = 0
g = next_prefix()
n = g.next()
- for path in g1.get_global_rib():
- if path['prefix'] == n:
+ for path in g1.local("gobgp global rib", capture=True).split('\n')[1:]:
+ if [elem for elem in path.split(' ') if elem != ''][1] == n:
try:
cnt2 += 1
n = g.next()
diff --git a/test/scenario_test/graceful_restart_test.py b/test/scenario_test/graceful_restart_test.py
index 9b97b82b..6f0f4211 100644
--- a/test/scenario_test/graceful_restart_test.py
+++ b/test/scenario_test/graceful_restart_test.py
@@ -82,7 +82,7 @@ class GoBGPTestBase(unittest.TestCase):
self.assertTrue(len(g2.get_global_rib('10.10.10.0/24')) == 0)
for d in g2.get_global_rib():
for p in d['paths']:
- self.assertFalse(p['stale'])
+ self.assertFalse(p.get('stale', False))
def test_04_add_non_graceful_restart_enabled_peer(self):
g1 = self.bgpds['g1']
diff --git a/test/scenario_test/monitor_test.py b/test/scenario_test/monitor_test.py
index 147391d1..4c5df7c1 100644
--- a/test/scenario_test/monitor_test.py
+++ b/test/scenario_test/monitor_test.py
@@ -87,7 +87,7 @@ class GoBGPTestBase(unittest.TestCase):
while True:
info = qu.get(timeout=120)
print 'monitor got {0}'.format(info)
- self.assertTrue(info['isWithdraw'])
+ self.assertTrue(info['withdrawal'])
break