mirror of
				https://git.proxmox.com/git/mirror_frr
				synced 2025-11-03 23:47:16 +00:00 
			
		
		
		
	bgp_l3vpn_to_bgp_direct: 2nd try at skipping tests when MPLS not available
Signed-off-by: Lou Berger <lberger@labn.net>
This commit is contained in:
		
							parent
							
								
									9ed0809e49
								
							
						
					
					
						commit
						99f5f0350b
					
				@ -74,6 +74,7 @@ r3-eth1 .3 |  | .3  r3-eth0      | .4 r4-eth0
 | 
			
		||||
"""
 | 
			
		||||
 | 
			
		||||
import os
 | 
			
		||||
import re
 | 
			
		||||
import sys
 | 
			
		||||
import pytest
 | 
			
		||||
 | 
			
		||||
@ -91,6 +92,8 @@ CWD = os.path.dirname(os.path.realpath(__file__))
 | 
			
		||||
# test name based on directory
 | 
			
		||||
TEST = os.path.basename(CWD)
 | 
			
		||||
 | 
			
		||||
MplsInit = False
 | 
			
		||||
 | 
			
		||||
class ThisTestTopo(Topo):
 | 
			
		||||
    "Test topology builder"
 | 
			
		||||
    def build(self, *_args, **_opts):
 | 
			
		||||
@ -101,7 +104,14 @@ class ThisTestTopo(Topo):
 | 
			
		||||
        # between routers, switches and hosts.
 | 
			
		||||
        #
 | 
			
		||||
        # Create P/PE routers
 | 
			
		||||
        for routern in range(1, 5):
 | 
			
		||||
        tgen.add_router('r1')
 | 
			
		||||
        #check for mpls - there may be a better way to check...
 | 
			
		||||
        if os.path.exists('/proc/sys/net/mpls/conf') != True:
 | 
			
		||||
            logger.info('MPLS not available, tests will be skipped')
 | 
			
		||||
            return
 | 
			
		||||
        global MplsInit
 | 
			
		||||
        MplsInit = True
 | 
			
		||||
        for routern in range(2, 5):
 | 
			
		||||
            tgen.add_router('r{}'.format(routern))
 | 
			
		||||
        # Create CE routers
 | 
			
		||||
        for routern in range(1, 4):
 | 
			
		||||
@ -128,20 +138,20 @@ class ThisTestTopo(Topo):
 | 
			
		||||
        switch[1].add_link(tgen.gears['r2'], nodeif='r2-eth2')
 | 
			
		||||
        switch[1].add_link(tgen.gears['r3'], nodeif='r3-eth1')
 | 
			
		||||
 | 
			
		||||
def doCmd(tgen, rtr, cmd, checkstr=None):
 | 
			
		||||
def doCmd(tgen, rtr, cmd, checkstr = None):
 | 
			
		||||
    output = tgen.net[rtr].cmd(cmd).strip()
 | 
			
		||||
    if len(output):
 | 
			
		||||
        logger.info('command output: ' + output)
 | 
			
		||||
        if checkstr != None:
 | 
			
		||||
            return re.search(checkstr, output)
 | 
			
		||||
        logger.info('command output: ' + output)
 | 
			
		||||
    return None
 | 
			
		||||
 | 
			
		||||
def ltemplatePreRouterStartHook():
 | 
			
		||||
    tgen = get_topogen()
 | 
			
		||||
    logger.info('pre router-start hook')
 | 
			
		||||
    #check for mpls - there may be a better way to check...
 | 
			
		||||
    if doCmd(tgen, 'r2', 'ls /proc/sys/net/mpls/conf', 'No such'):
 | 
			
		||||
        logger.info('MPLS not supported, tests will be skipped')
 | 
			
		||||
    #check for mpls
 | 
			
		||||
    if MplsInit == False:
 | 
			
		||||
        logger.info('MPLS not available, skipping setup')
 | 
			
		||||
        return
 | 
			
		||||
    #configure r2 mpls interfaces
 | 
			
		||||
    intfs = ['lo', 'r2-eth0', 'r2-eth1', 'r2-eth2']
 | 
			
		||||
@ -169,8 +179,8 @@ def versionCheck(vstr, rname='r1', compstr='<',cli=False):
 | 
			
		||||
 | 
			
		||||
    router = tgen.gears[rname]
 | 
			
		||||
 | 
			
		||||
    if router.has_mpls() == False:
 | 
			
		||||
        ret = 'MPLS not supported'
 | 
			
		||||
    if MplsInit == False:
 | 
			
		||||
        ret = 'MPLS not initialized'
 | 
			
		||||
        return ret
 | 
			
		||||
 | 
			
		||||
    ret = True
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user