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) def f(): rib = g4.get_global_rib() self.assertEqual(len(rib), 1) self.assertEqual(len(rib[0]['paths']), 1) self.assertEqual(rib[0]['paths'][0]['aspath'], [100]) assert_several_times(f)
def test_30_ebgp_setup(self): # +----+ +----+ # | g6 |----(eBGP)----| g7 | # +----+ +----+ gobgp_ctn_image_name = parser_option.gobgp_image g6 = GoBGPContainer(name='g6', asn=65001, router_id='192.168.0.6', ctn_image_name=gobgp_ctn_image_name, log_level=parser_option.gobgp_log_level) g7 = GoBGPContainer(name='g7', asn=65002, router_id='192.168.0.7', ctn_image_name=gobgp_ctn_image_name, log_level=parser_option.gobgp_log_level) time.sleep(max(ctn.run() for ctn in [g6, g7])) g6.local("gobgp vrf add vrf1 rd 100:100 rt both 100:100") g6.local("gobgp vrf add vrf2 rd 200:200 rt both 200:200") g7.local("gobgp vrf add vrf1 rd 100:100 rt both 100:100") g7.local("gobgp vrf add vrf3 rd 300:300 rt both 300:300") g6.local("gobgp vrf vrf1 rib add 60.0.0.0/24") g6.local("gobgp vrf vrf2 rib add 60.0.0.0/24") g7.local("gobgp vrf vrf1 rib add 70.0.0.0/24") g7.local("gobgp vrf vrf3 rib add 70.0.0.0/24") for a, b in combinations([g6, g7], 2): a.add_peer(b, vpn=True, passwd='rtc', graceful_restart=True) b.add_peer(a, vpn=True, passwd='rtc', graceful_restart=True) g6.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=g7) self.__class__.g6 = g6 self.__class__.g7 = g7
def test_10_rr_setup(self): # +------+ # | g3 | # +------| (RR) |------+ # | +------+ | # (iBGP) (iBGP) # | | # +-------------+ +-------------+ # | g4 | | g5 | # | (RR Client) | | (RR Client) | # +-------------+ +-------------+ gobgp_ctn_image_name = parser_option.gobgp_image g3 = GoBGPContainer(name='g3', asn=65000, router_id='192.168.0.3', ctn_image_name=gobgp_ctn_image_name, log_level=parser_option.gobgp_log_level) g4 = GoBGPContainer(name='g4', asn=65000, router_id='192.168.0.4', ctn_image_name=gobgp_ctn_image_name, log_level=parser_option.gobgp_log_level) g5 = GoBGPContainer(name='g5', asn=65000, router_id='192.168.0.5', ctn_image_name=gobgp_ctn_image_name, log_level=parser_option.gobgp_log_level) time.sleep(max(ctn.run() for ctn in [g3, g4, g5])) g3.add_peer(g4, vpn=True, is_rr_client=True) g4.add_peer(g3, vpn=True) g3.add_peer(g5, vpn=True, is_rr_client=True) g5.add_peer(g3, vpn=True) g3.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=g4) g3.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=g5) self.__class__.g3 = g3 self.__class__.g4 = g4 self.__class__.g5 = g5
def test_10_setup_rr_rtc_isolation_policy(self): # +-------+ # | rr | # +----------------+----| (RR) |---+----------------+ # | | +-------+ | | # | | | | # (iBGP) (iBGP) (iBGP) (iBGP) # | | | | # +-------------+ +-------------+ +-------------+ +-------------+ # | acme1 | | acme2 | | tyrell1 | | tyrell2 | # | (RR Client) | | (RR Client) | | (RR Client) | | (RR Client) | # +-------------+ +-------------+ +-------------+ +-------------+ gobgp_ctn_image_name = parser_option.gobgp_image rr = GoBGPContainer(name='rr', asn=65000, router_id='192.168.1.1', ctn_image_name=gobgp_ctn_image_name, log_level=parser_option.gobgp_log_level) acme1 = GoBGPContainer(name='acme1', asn=65000, router_id='192.168.1.101', ctn_image_name=gobgp_ctn_image_name, log_level=parser_option.gobgp_log_level) acme2 = GoBGPContainer(name='acme2', asn=65000, router_id='192.168.1.102', ctn_image_name=gobgp_ctn_image_name, log_level=parser_option.gobgp_log_level) tyrell1 = GoBGPContainer(name='tyrell1', asn=65000, router_id='192.168.1.201', ctn_image_name=gobgp_ctn_image_name, log_level=parser_option.gobgp_log_level) tyrell2 = GoBGPContainer(name='tyrell2', asn=65000, router_id='192.168.1.202', ctn_image_name=gobgp_ctn_image_name, log_level=parser_option.gobgp_log_level) time.sleep( max(ctn.run() for ctn in [rr, acme1, acme2, tyrell1, tyrell2])) rr.add_peer(acme1, vpn=True, addpath=True, graceful_restart=True, llgr=True, is_rr_client=True) acme1.add_peer(rr, vpn=True, addpath=True, graceful_restart=True, llgr=True) rr.add_peer(acme2, vpn=True, addpath=True, graceful_restart=True, llgr=True, is_rr_client=True) acme2.add_peer(rr, vpn=True, addpath=True, graceful_restart=True, llgr=True) rr.add_peer(tyrell1, vpn=True, addpath=True, graceful_restart=True, llgr=True, is_rr_client=True) tyrell1.add_peer(rr, vpn=True, addpath=True, graceful_restart=True, llgr=True) rr.add_peer(tyrell2, vpn=True, addpath=True, graceful_restart=True, llgr=True, is_rr_client=True) tyrell2.add_peer(rr, vpn=True, addpath=True, graceful_restart=True, llgr=True) self.__class__.rr = rr self.__class__.acme1 = acme1 self.__class__.acme2 = acme2 self.__class__.tyrell1 = tyrell1 self.__class__.tyrell2 = tyrell2 # add import/export policy to allow peers exchange routes within specific RTs # later tests should not break due to RTC Updates being filtered-out rr.local("gobgp policy neighbor add clients-acme {} {}".format( rr.peer_name(acme1), rr.peer_name(acme2))) rr.local("gobgp policy neighbor add clients-tyrell {} {}".format( rr.peer_name(tyrell1), rr.peer_name(tyrell2))) rr.local("gobgp policy ext-community add rts-acme rt:^100:.*$") rr.local("gobgp policy ext-community add rts-tyrell rt:^200:.*$") rr.local('gobgp policy statement add allow-rtc') rr.local( 'gobgp policy statement allow-rtc add condition afi-safi-in rtc') rr.local('gobgp policy statement allow-rtc add action accept') rr.local('gobgp policy statement add allow-acme') rr.local( 'gobgp policy statement allow-acme add condition neighbor clients-acme' ) rr.local( 'gobgp policy statement allow-acme add condition ext-community rts-acme' ) rr.local('gobgp policy statement allow-acme add action accept') rr.local('gobgp policy statement add allow-tyrell') rr.local( 'gobgp policy statement allow-tyrell add condition neighbor clients-tyrell' ) rr.local( 'gobgp policy statement allow-tyrell add condition ext-community rts-tyrell' ) rr.local('gobgp policy statement allow-tyrell add action accept') rr.local('gobgp policy add tenancy allow-rtc allow-acme allow-tyrell') rr.local('gobgp global policy import add tenancy default reject') rr.local('gobgp global policy export add tenancy default reject') acme1.local("gobgp vrf add a1 rd 100:100 rt both 100:100") acme2.local("gobgp vrf add a1 rd 100:100 rt both 100:100") tyrell1.local("gobgp vrf add t1 rd 200:100 rt both 200:100") tyrell2.local("gobgp vrf add t1 rd 200:100 rt both 200:100") rr.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=acme1) rr.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=acme2) rr.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=tyrell1) rr.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=tyrell2)
def test_10_rr_setup(self): # +------+ # | g3 | # +------| (RR) |------+ # | +------+ | # (iBGP) (iBGP) # | | # +-------------+ +-------------+ # | g4 | | g5 | # | (RR Client) | | (RR Client) | # +-------------+ +-------------+ gobgp_ctn_image_name = parser_option.gobgp_image g3 = GoBGPContainer(name='g3', asn=65000, router_id='192.168.0.3', ctn_image_name=gobgp_ctn_image_name, log_level=parser_option.gobgp_log_level) g4 = GoBGPContainer(name='g4', asn=65000, router_id='192.168.0.4', ctn_image_name=gobgp_ctn_image_name, log_level=parser_option.gobgp_log_level) g5 = GoBGPContainer(name='g5', asn=65000, router_id='192.168.0.5', ctn_image_name=gobgp_ctn_image_name, log_level=parser_option.gobgp_log_level) time.sleep(max(ctn.run() for ctn in [g3, g4, g5])) g3.add_peer(g4, vpn=True, is_rr_client=True) g4.add_peer(g3, vpn=True) g3.add_peer(g5, vpn=True, is_rr_client=True) g5.add_peer(g3, vpn=True) g3.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=g4) g3.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=g5) self.__class__.g3 = g3 self.__class__.g4 = g4 self.__class__.g5 = g5 # add import/export policy to allow peers exchange routes within specific RTs # later tests should not break due to RTC Updates being filtered-out self.g3.local("gobgp policy neighbor add rr-clients-acme {} {}".format( self.g3.peer_name(self.g4), self.g3.peer_name(self.g5))) self.g3.local( "gobgp policy ext-community add rts-acme rt:^100:.*$ rt:^200:200$ rt:^300:300$" ) self.g3.local('gobgp policy statement add allow-acme') self.g3.local( 'gobgp policy statement allow-acme add condition neighbor rr-clients-acme' ) self.g3.local( 'gobgp policy statement allow-acme add condition ext-community rts-acme' ) self.g3.local('gobgp policy statement allow-acme add action accept') self.g3.local('gobgp policy add allow-acme allow-acme') self.g3.local('gobgp policy statement add allow-rtc') self.g3.local( 'gobgp policy statement allow-rtc add condition afi-safi-in rtc') self.g3.local('gobgp policy statement allow-rtc add action accept') self.g3.local('gobgp policy add allow-rtc allow-rtc') self.g3.local( 'gobgp global policy import add allow-rtc allow-acme default reject' ) self.g3.local( 'gobgp global policy export add allow-rtc allow-acme default reject' )