summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/lib/base.py6
-rw-r--r--test/lib/gobgp.py1
-rw-r--r--test/scenario_test/aspath_test.py34
3 files changed, 39 insertions, 2 deletions
diff --git a/test/lib/base.py b/test/lib/base.py
index ef8e7ab7..86a339c7 100644
--- a/test/lib/base.py
+++ b/test/lib/base.py
@@ -310,7 +310,8 @@ class BGPContainer(Container):
is_rr_client=False, cluster_id=None,
flowspec=False, bridge='', reload_config=True, as2=False,
graceful_restart=None, local_as=None, prefix_limit=None,
- v6=False, llgr=None, vrf='', interface='', allow_as_in=0):
+ v6=False, llgr=None, vrf='', interface='', allow_as_in=0,
+ remove_private_as=None):
neigh_addr = ''
local_addr = ''
it = itertools.product(self.ip_addrs, peer.ip_addrs)
@@ -352,7 +353,8 @@ class BGPContainer(Container):
'prefix_limit': prefix_limit,
'llgr': llgr,
'vrf': vrf,
- 'allow_as_in': allow_as_in}
+ 'allow_as_in': allow_as_in,
+ 'remove_private_as': remove_private_as}
if self.is_running and reload_config:
self.create_config()
self.reload_config()
diff --git a/test/lib/gobgp.py b/test/lib/gobgp.py
index 15264bfb..92e19f07 100644
--- a/test/lib/gobgp.py
+++ b/test/lib/gobgp.py
@@ -345,6 +345,7 @@ class GoBGPContainer(BGPContainer):
'peer-as': peer.asn,
'auth-password': info['passwd'],
'vrf': info['vrf'],
+ 'remove-private-as': info['remove_private_as'],
},
'afi-safis': afi_safi_list,
'timers': {
diff --git a/test/scenario_test/aspath_test.py b/test/scenario_test/aspath_test.py
index 699a1ab3..5539cfde 100644
--- a/test/scenario_test/aspath_test.py
+++ b/test/scenario_test/aspath_test.py
@@ -81,6 +81,40 @@ class GoBGPTestBase(unittest.TestCase):
time.sleep(1)
self.assertTrue(len(self.g2.get_global_rib()) == 1)
+ def test_05_check_remove_private_as_peer_all(self):
+ g3 = GoBGPContainer(name='g3', asn=100, router_id='192.168.0.4',
+ ctn_image_name=parser_option.gobgp_image,
+ log_level=parser_option.gobgp_log_level)
+ g4 = GoBGPContainer(name='g4', asn=200, router_id='192.168.0.5',
+ ctn_image_name=parser_option.gobgp_image,
+ log_level=parser_option.gobgp_log_level)
+ time.sleep(max(ctn.run() for ctn in [g3, g4]))
+
+ self.ctns['g3'] = g3
+ self.ctns['g4'] = g4
+
+ self.g2.add_peer(g3)
+ g3.add_peer(self.g2)
+
+ g3.add_peer(g4, remove_private_as='all')
+ g4.add_peer(g3)
+
+ self.g2.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=g3)
+ g3.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=g4)
+
+ time.sleep(1)
+ self.assertTrue(g4.get_global_rib()[0]['paths'][0]['aspath'] == [100])
+
+ def test_06_check_remove_private_as_peer_replace(self):
+ g3 = self.ctns['g3']
+ g4 = self.ctns['g4']
+ g3.update_peer(g4, remove_private_as='replace')
+
+ g3.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=g4)
+
+ time.sleep(1)
+ self.assertTrue(g4.get_global_rib()[0]['paths'][0]['aspath'] == [100, 100, 100, 100])
+
if __name__ == '__main__':
output = local("which docker 2>&1 > /dev/null ; echo $?", capture=True)