summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/scenario_test/bgp_router_test.py6
-rw-r--r--test/scenario_test/constant.py4
-rw-r--r--test/scenario_test/evpn_test.py6
-rw-r--r--test/scenario_test/gobgp_test.py5
-rw-r--r--test/scenario_test/ibgp_router_test.py8
-rw-r--r--test/scenario_test/lib/base.py1
-rw-r--r--test/scenario_test/lib/gobgp.py29
-rw-r--r--test/scenario_test/route_server_policy_test.py64
8 files changed, 74 insertions, 49 deletions
diff --git a/test/scenario_test/bgp_router_test.py b/test/scenario_test/bgp_router_test.py
index a5ce3d7e..804003aa 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 = self.gobgp._get_as_path(path)
+ asns = path['as_path']
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(self.gobgp._get_as_path(path)) == 0)
+ self.assertTrue(len(path['as_path']) == 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(self.gobgp._get_as_path(path) == [self.gobgp.asn])
+ self.assertTrue(path['as_path'] == [self.gobgp.asn])
def test_12_disable_peer(self):
q1 = self.quaggas['q1']
diff --git a/test/scenario_test/constant.py b/test/scenario_test/constant.py
index 65908a4f..33572c8d 100644
--- a/test/scenario_test/constant.py
+++ b/test/scenario_test/constant.py
@@ -67,3 +67,7 @@ LOCAL_RIB = "local"
GLOBAL_RIB = "global rib"
NEIGHBOR = "neighbor"
POLICY = "policy"
+
+BGP_ATTR_TYPE_AS_PATH= 2
+BGP_ATTR_TYPE_MED = 4
+BGP_ATTR_TYPE_COMMUNITIES = 8
diff --git a/test/scenario_test/evpn_test.py b/test/scenario_test/evpn_test.py
index 270773bb..b3e893c5 100644
--- a/test/scenario_test/evpn_test.py
+++ b/test/scenario_test/evpn_test.py
@@ -26,11 +26,11 @@ from noseplugin import OptionParser, parser_option
from itertools import combinations
def get_mac_mobility_sequence(pattr):
- for ecs in [p['extended_communities'] for p in pattr
+ for ecs in [p['value'] for p in pattr
if 'type' in p and \
p['type'] == BGP_ATTR_TYPE_EXTENDED_COMMUNITIES]:
- for ec in [e for e in ecs if 'type' in e and e['type'] == 4]:
- if ec['subtype'] == 5:
+ for ec in [e for e in ecs if 'type' in e and e['type'] == 6]:
+ if ec['subtype'] == 0:
if 'sequence' not in ec:
return 0
else:
diff --git a/test/scenario_test/gobgp_test.py b/test/scenario_test/gobgp_test.py
index 03443777..45f36f1e 100644
--- a/test/scenario_test/gobgp_test.py
+++ b/test/scenario_test/gobgp_test.py
@@ -260,11 +260,12 @@ class GoBGPTestBase(unittest.TestCase):
retry_count = 0
while True:
rib = self.ask_gobgp(type, neighbor_address, af)
- paths = [p for p in rib if p['nlri']['prefix'] == target_prefix]
+ paths = [p for p in rib if p['prefix'] == target_prefix]
if len(paths) > 0:
assert len(paths) == 1
- return paths[0]
+ assert len(paths[0]['paths']) == 1
+ return paths[0]['paths'][0]
else:
retry_count += 1
if retry_count > retry:
diff --git a/test/scenario_test/ibgp_router_test.py b/test/scenario_test/ibgp_router_test.py
index 2fad2da3..65d6cb99 100644
--- a/test/scenario_test/ibgp_router_test.py
+++ b/test/scenario_test/ibgp_router_test.py
@@ -104,7 +104,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(self.gobgp._get_as_path(path)) == 0)
+ self.assertTrue(len(path['as_path']) == 0)
def test_05_check_gobgp_adj_rib_out(self):
for q in self.quaggas.itervalues():
@@ -115,7 +115,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(len(self.gobgp._get_as_path(path)) == 0)
+ self.assertTrue(len(path['as_path']) == 0)
# check routes are properly advertised to all BGP speaker
def test_06_check_quagga_global_rib(self):
@@ -181,7 +181,7 @@ class GoBGPTestBase(unittest.TestCase):
peer_info = self.gobgp.peers[q3]
local_addr = peer_info['local_addr'].split('/')[0]
self.assertTrue(path['nexthop'] == local_addr)
- self.assertTrue(self.gobgp._get_as_path(path) == [self.gobgp.asn])
+ self.assertTrue(path['as_path'] == [self.gobgp.asn])
def test_10_check_gobgp_ibgp_adj_rib_out(self):
q1 = self.quaggas['q1']
@@ -198,7 +198,7 @@ class GoBGPTestBase(unittest.TestCase):
self.assertTrue(path['nexthop'] == neigh_addr)
# bgp router mustn't change aspath of routes from eBGP peers
# which are sent to iBGP peers
- self.assertTrue(self.gobgp._get_as_path(path) == [q3.asn])
+ self.assertTrue(path['as_path'] == [q3.asn])
# disable ebgp peer, check ebgp routes are removed
def test_11_disable_ebgp_peer(self):
diff --git a/test/scenario_test/lib/base.py b/test/scenario_test/lib/base.py
index 274a68cf..7bb7b79f 100644
--- a/test/scenario_test/lib/base.py
+++ b/test/scenario_test/lib/base.py
@@ -36,6 +36,7 @@ BGP_ATTR_TYPE_AS_PATH = 2
BGP_ATTR_TYPE_NEXT_HOP = 3
BGP_ATTR_TYPE_MULTI_EXIT_DISC = 4
BGP_ATTR_TYPE_LOCAL_PREF = 5
+BGP_ATTR_TYPE_MP_REACH_NLRI = 14
BGP_ATTR_TYPE_EXTENDED_COMMUNITIES = 16
diff --git a/test/scenario_test/lib/gobgp.py b/test/scenario_test/lib/gobgp.py
index c7a9631e..e1da72c8 100644
--- a/test/scenario_test/lib/gobgp.py
+++ b/test/scenario_test/lib/gobgp.py
@@ -51,11 +51,17 @@ class GoBGPContainer(BGPContainer):
def _get_as_path(self, path):
asps = (p['as_paths'] for p in path['attrs'] if
- p['type'] == BGP_ATTR_TYPE_AS_PATH and 'as_paths' in p)
+ p['type'] == BGP_ATTR_TYPE_AS_PATH and 'as_paths' in p
+ and p['as_paths'] != None)
asps = chain.from_iterable(asps)
asns = (asp['asns'] for asp in asps)
return list(chain.from_iterable(asns))
+ def _get_nexthop(self, path):
+ for p in path['attrs']:
+ if p['type'] == BGP_ATTR_TYPE_NEXT_HOP or p['type'] == BGP_ATTR_TYPE_MP_REACH_NLRI:
+ return p['nexthop']
+
def _trigger_peer_cmd(self, cmd, peer):
if peer not in self.peers:
raise Exception('not found peer {0}'.format(peer.router_id))
@@ -75,13 +81,22 @@ class GoBGPContainer(BGPContainer):
peer_addr = self.peers[peer]['neigh_addr'].split('/')[0]
cmd = 'gobgp -j neighbor {0} local -a {1}'.format(peer_addr, rf)
output = self.local(cmd, capture=True)
- n = json.loads(output)
- return n
+ ret = json.loads(output)
+ for d in ret:
+ for p in d["paths"]:
+ p["nexthop"] = self._get_nexthop(p)
+ p["as_path"] = self._get_as_path(p)
+ return ret
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)
- return json.loads(output)
+ ret = json.loads(output)
+ for d in ret:
+ for p in d["paths"]:
+ p["nexthop"] = self._get_nexthop(p)
+ p["as_path"] = self._get_as_path(p)
+ return ret
def _get_adj_rib(self, adj_type, peer, prefix='', rf='ipv4'):
if peer not in self.peers:
@@ -91,7 +106,11 @@ class GoBGPContainer(BGPContainer):
adj_type,
prefix, rf)
output = self.local(cmd, capture=True)
- return json.loads(output)
+ ret = [p["paths"][0] for p in json.loads(output)]
+ for p in ret:
+ p["nexthop"] = self._get_nexthop(p)
+ p["as_path"] = self._get_as_path(p)
+ return ret
def get_adj_rib_in(self, peer, prefix='', rf='ipv4'):
return self._get_adj_rib('in', peer, prefix, rf)
diff --git a/test/scenario_test/route_server_policy_test.py b/test/scenario_test/route_server_policy_test.py
index 1107eadb..3ff08a1e 100644
--- a/test/scenario_test/route_server_policy_test.py
+++ b/test/scenario_test/route_server_policy_test.py
@@ -1229,8 +1229,8 @@ class GoBGPTest(GoBGPTestBase):
# check adj-rib-out in peer2
path = self.get_paths_in_localrib(peer2, prefix1,retry=0)
self.assertIsNotNone(path)
- attrs = [x for x in path[0]['attrs'] if 'communites' in x ]
- self.assertTrue((65100 << 16 | 20) in attrs[0]['communites'])
+ attrs = [x for x in path[0]['attrs'] if 'communities' in x ]
+ self.assertTrue((65100 << 16 | 20) in attrs[0]['communities'])
# check show ip bgp on peer2(quagga2)
qpath = self.get_route(peer2, prefix1, retry=self.retry_count_common)
@@ -1283,9 +1283,9 @@ class GoBGPTest(GoBGPTestBase):
# check adj-rib-out in peer2
path = self.get_paths_in_localrib(peer2, prefix1,retry=0)
self.assertIsNotNone(path)
- attrs = [x for x in path[0]['attrs'] if 'communites' in x ]
- self.assertTrue((65100 << 16 | 20) in attrs[0]['communites'])
- self.assertTrue((65100 << 16 | 30) in attrs[0]['communites'])
+ attrs = [x for x in path[0]['attrs'] if 'communities' in x ]
+ self.assertTrue((65100 << 16 | 20) in attrs[0]['communities'])
+ self.assertTrue((65100 << 16 | 30) in attrs[0]['communities'])
# check show ip bgp on peer2(quagga2)
qpath = self.get_route(peer2,prefix1, retry=self.retry_count_common)
@@ -1339,9 +1339,9 @@ class GoBGPTest(GoBGPTestBase):
# check adj-rib-out in peer2
path = self.get_paths_in_localrib(peer2, prefix1,retry=0)
self.assertIsNotNone(path)
- attrs = [x for x in path[0]['attrs'] if 'communites' in x ]
- self.assertTrue((65100 << 16 | 20) not in attrs[0]['communites'])
- self.assertTrue((65100 << 16 | 30) not in attrs[0]['communites'])
+ attrs = [x for x in path[0]['attrs'] if 'communities' in x ]
+ self.assertTrue((65100 << 16 | 20) not in attrs[0]['communities'])
+ self.assertTrue((65100 << 16 | 30) not in attrs[0]['communities'])
# check show ip bgp on peer2(quagga2)
qpath = self.get_route(peer2,prefix1, retry=self.retry_count_common)
@@ -1397,8 +1397,8 @@ class GoBGPTest(GoBGPTestBase):
# check adj-rib-out in peer2
path = self.get_paths_in_localrib(peer2, prefix1,retry=0)
self.assertIsNotNone(path)
- attrs = [x for x in path[0]['attrs'] if 'communites' in x ]
- self.assertFalse('communites' in attrs)
+ attrs = [x for x in path[0]['attrs'] if 'communities' in x ]
+ self.assertFalse('communities' in attrs)
# check show ip bgp on peer2(quagga2)
qpath = self.get_route(peer2,prefix1, retry=self.retry_count_common)
@@ -1452,12 +1452,12 @@ class GoBGPTest(GoBGPTestBase):
# check adj-rib-out in peer2
path = self.get_paths_in_localrib(peer2, prefix1,retry=0)
self.assertIsNotNone(path)
- attrs = [x for x in path[0]['attrs'] if 'communites' in x ]
- self.assertFalse((65100 << 16 | 20) in attrs[0]['communites'])
+ attrs = [x for x in path[0]['attrs'] if 'communities' in x ]
+ self.assertFalse((65100 << 16 | 20) in attrs[0]['communities'])
# check out-rib
path = self.get_adj_rib_out(peer2, prefix1, retry=0)
- attrs = [x for x in path['attrs'] if 'communites' in x ]
- self.assertTrue((65100 << 16 | 20) in attrs[0]['communites'])
+ attrs = [x for x in path['attrs'] if 'communities' in x ]
+ self.assertTrue((65100 << 16 | 20) in attrs[0]['communities'])
# check show ip bgp on peer2(quagga2)
qpath = self.get_route(peer2,prefix1, retry=self.retry_count_common)
@@ -1511,14 +1511,14 @@ class GoBGPTest(GoBGPTestBase):
# check adj-rib-out in peer2
path = self.get_paths_in_localrib(peer2, prefix1, retry=0)
self.assertIsNotNone(path)
- attrs = [x for x in path[0]['attrs'] if 'communites' in x ]
- self.assertFalse((65100 << 16 | 20) in attrs[0]['communites'])
- self.assertFalse((65100 << 16 | 30) in attrs[0]['communites'])
+ attrs = [x for x in path[0]['attrs'] if 'communities' in x ]
+ self.assertFalse((65100 << 16 | 20) in attrs[0]['communities'])
+ self.assertFalse((65100 << 16 | 30) in attrs[0]['communities'])
# check out-rib
path = self.get_adj_rib_out(peer2, prefix1, retry=1)
- attrs = [x for x in path['attrs'] if 'communites' in x ]
- self.assertTrue((65100 << 16 | 20) in attrs[0]['communites'])
- self.assertTrue((65100 << 16 | 30) in attrs[0]['communites'])
+ attrs = [x for x in path['attrs'] if 'communities' in x ]
+ self.assertTrue((65100 << 16 | 20) in attrs[0]['communities'])
+ self.assertTrue((65100 << 16 | 30) in attrs[0]['communities'])
# check show ip bgp on peer2(quagga2)
@@ -1574,14 +1574,14 @@ class GoBGPTest(GoBGPTestBase):
# check adj-rib-out in peer2
path = self.get_paths_in_localrib(peer2, prefix1, retry=1)
self.assertIsNotNone(path)
- attrs = [x for x in path[0]['attrs'] if 'communites' in x ]
- self.assertTrue((65100 << 16 | 20) in attrs[0]['communites'])
- self.assertTrue((65100 << 16 | 30) in attrs[0]['communites'])
+ attrs = [x for x in path[0]['attrs'] if 'communities' in x ]
+ self.assertTrue((65100 << 16 | 20) in attrs[0]['communities'])
+ self.assertTrue((65100 << 16 | 30) in attrs[0]['communities'])
# check out-rib
path = self.get_adj_rib_out(peer2, prefix1, retry=1)
- attrs = [x for x in path['attrs'] if 'communites' in x ]
- self.assertFalse((65100 << 16 | 20) in attrs[0]['communites'])
- self.assertFalse((65100 << 16 | 30) in attrs[0]['communites'])
+ attrs = [x for x in path['attrs'] if 'communities' in x ]
+ self.assertFalse((65100 << 16 | 20) in attrs[0]['communities'])
+ self.assertFalse((65100 << 16 | 30) in attrs[0]['communities'])
# check show ip bgp on peer2(quagga2)
@@ -1638,14 +1638,14 @@ class GoBGPTest(GoBGPTestBase):
# check adj-rib-out in peer2
path = self.get_paths_in_localrib(peer2, prefix1, retry=0)
self.assertIsNotNone(path)
- attrs = [x for x in path[0]['attrs'] if 'communites' in x ]
- self.assertTrue((65100 << 16 | 10) in attrs[0]['communites'])
- self.assertTrue((65100 << 16 | 20) in attrs[0]['communites'])
- self.assertTrue((65100 << 16 | 30) in attrs[0]['communites'])
+ attrs = [x for x in path[0]['attrs'] if 'communities' in x ]
+ self.assertTrue((65100 << 16 | 10) in attrs[0]['communities'])
+ self.assertTrue((65100 << 16 | 20) in attrs[0]['communities'])
+ self.assertTrue((65100 << 16 | 30) in attrs[0]['communities'])
# check out-rib
path = self.get_adj_rib_out(peer2, prefix1, retry=1)
- attrs = [x for x in path['attrs'] if 'communites' in x ]
- self.assertFalse('communites' in attrs)
+ attrs = [x for x in path['attrs'] if 'communities' in x ]
+ self.assertFalse('communities' in attrs)
# check show ip bgp on peer2(quagga2)
qpath = self.get_route(peer2,prefix1, retry=self.retry_count_common)