diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-07-02 16:57:25 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-07-03 06:29:07 +0900 |
commit | 6d9f671f493e03ddad3f8abd03351f35dc0381ab (patch) | |
tree | fcb9bbff58ee8dab557b67115aec2edc4815aa23 | |
parent | 34c88c4771a5dd4fb687fe225cebfc6fc99381f0 (diff) |
test: check gobgp properly adds it's own asn to aspath
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
-rw-r--r-- | test/scenario_test/bgp_router_test.py | 10 | ||||
-rw-r--r-- | test/scenario_test/lib/base.py | 5 | ||||
-rw-r--r-- | test/scenario_test/lib/gobgp.py | 19 |
3 files changed, 32 insertions, 2 deletions
diff --git a/test/scenario_test/bgp_router_test.py b/test/scenario_test/bgp_router_test.py index a424d625..3bd5a82c 100644 --- a/test/scenario_test/bgp_router_test.py +++ b/test/scenario_test/bgp_router_test.py @@ -22,6 +22,7 @@ import os import time import nose from noseplugin import OptionParser, parser_option +from itertools import chain class GoBGPTestBase(unittest.TestCase): @@ -111,6 +112,15 @@ class GoBGPTestBase(unittest.TestCase): continue raise Exception('timeout') + # check gobgp properly add it's own asn to aspath + 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): + asps = (p['as_paths'] for p in path['attrs'] if p['type'] == BGP_ATTR_TYPE_AS_PATH) + asps = chain.from_iterable(asps) + asns = (asp['asns'] for asp in asps) + asns = chain.from_iterable(asns) + self.assertTrue(self.gobgp.asn in asns) # check routes are properly advertised to all BGP speaker def test_03_check_quagga_global_rib(self): diff --git a/test/scenario_test/lib/base.py b/test/scenario_test/lib/base.py index 35686973..119e188c 100644 --- a/test/scenario_test/lib/base.py +++ b/test/scenario_test/lib/base.py @@ -29,6 +29,11 @@ BGP_FSM_IDLE = 'BGP_FSM_IDLE' BGP_FSM_ACTIVE = 'BGP_FSM_ACTIVE' BGP_FSM_ESTABLISHED = 'BGP_FSM_ESTABLISHED' +BGP_ATTR_TYPE_ORIGIN = 1 +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 def get_bridges(): return local("brctl show | awk 'NR > 1{print $1}'", diff --git a/test/scenario_test/lib/gobgp.py b/test/scenario_test/lib/gobgp.py index d9115f1b..4e26b922 100644 --- a/test/scenario_test/lib/gobgp.py +++ b/test/scenario_test/lib/gobgp.py @@ -70,10 +70,25 @@ class GoBGPContainer(BGPContainer): gobgp, prefix, rf) + output = local(cmd, capture=True) + return json.loads(output) + def _get_adj_rib(self, adj_type, peer, prefix='', rf='ipv4'): + if peer not in self.peers: + raise Exception('not found peer {0}'.format(peer.router_id)) + peer_addr = self.peers[peer]['neigh_addr'].split('/')[0] + gobgp = '/go/bin/gobgp' + cmd = 'docker exec {0} {1} neighbor {2}'\ + ' adj-{3} {4} -a {5} -j'.format(self.name, gobgp, peer_addr, + adj_type, prefix, rf) output = local(cmd, capture=True) - n = json.loads(output) - return n + return json.loads(output) + + def get_adj_rib_in(self, peer, prefix='', rf='ipv4'): + return self._get_adj_rib('in', peer, prefix, rf) + + def get_adj_rib_out(self, peer, prefix='', rf='ipv4'): + return self._get_adj_rib('out', peer, prefix, rf) def get_neighbor_state(self, peer): if peer not in self.peers: |