@@ -244,7 +244,7 @@ def __init__(
244244 name : str = None ,
245245 imgname : str = None ,
246246 keeptb : bool = False ,
247- env : list = [] ,
247+ fakeplatform : str = None ,
248248 log_path : str = None ,
249249 max_cpu : int = 2 ,
250250 forcedvs : bool = None ,
@@ -356,6 +356,8 @@ def __init__(
356356 self .mount = f"/var/run/redis-vs/{ self .ctn_sw .name } "
357357 ensure_system (f"mkdir -p { self .mount } " )
358358
359+ self .environment = [f"fake_platform={ fakeplatform } " ] if fakeplatform else []
360+
359361 kwargs = {}
360362 if newctnname :
361363 kwargs ["name" ] = newctnname
@@ -370,7 +372,7 @@ def __init__(
370372 self .ctn = self .client .containers .run (imgname ,
371373 privileged = True ,
372374 detach = True ,
373- environment = env ,
375+ environment = self . environment ,
374376 network_mode = f"container:{ self .ctn_sw .name } " ,
375377 cpu_count = max_cpu ,
376378 ** kwargs )
@@ -1233,7 +1235,7 @@ def __init__(
12331235 namespace = None ,
12341236 imgname = None ,
12351237 keeptb = False ,
1236- env = [] ,
1238+ fakeplatform = None ,
12371239 log_path = None ,
12381240 max_cpu = 2 ,
12391241 forcedvs = None ,
@@ -1242,7 +1244,7 @@ def __init__(
12421244 self .ns = namespace
12431245 self .chassbr = "br4chs"
12441246 self .keeptb = keeptb
1245- self .env = env
1247+ self .fakeplatform = fakeplatform
12461248 self .topoFile = topoFile
12471249 self .imgname = imgname
12481250 self .ctninfo = {}
@@ -1301,7 +1303,7 @@ def find_all_ctns(self):
13011303 for ctn in docker .from_env ().containers .list ():
13021304 if ctn .name .endswith (suffix ):
13031305 self .dvss [ctn .name ] = DockerVirtualSwitch (ctn .name , self .imgname , self .keeptb ,
1304- self .env , log_path = ctn .name ,
1306+ self .fakeplatform , log_path = ctn .name ,
13051307 max_cpu = self .max_cpu , forcedvs = self .forcedvs ,
13061308 vct = self )
13071309 if self .chassbr is None and len (self .dvss ) > 0 :
@@ -1419,7 +1421,7 @@ def create_vct_ctn(self, ctndir):
14191421 if ctnname not in self .dvss :
14201422 self .dvss [ctnname ] = DockerVirtualSwitch (name = None , imgname = self .imgname ,
14211423 keeptb = self .keeptb ,
1422- env = self .env ,
1424+ fakeplatform = self .fakeplatform ,
14231425 log_path = self .log_path ,
14241426 max_cpu = self .max_cpu ,
14251427 forcedvs = self .forcedvs ,
@@ -1596,18 +1598,18 @@ def manage_dvs(request) -> str:
15961598 buffer_model = request .config .getoption ("--buffer_model" )
15971599 force_recreate = request .config .getoption ("--force-recreate-dvs" )
15981600 dvs = None
1599- curr_dvs_env = [] # lgtm[py/unused-local-variable]
1601+ curr_fake_platform = None # lgtm[py/unused-local-variable]
16001602
16011603 if using_persistent_dvs and force_recreate :
16021604 pytest .fail ("Options --dvsname and --force-recreate-dvs are mutually exclusive" )
16031605
1604- def update_dvs (log_path , new_dvs_env = [] ):
1606+ def update_dvs (log_path , new_fake_platform = None ):
16051607 """
16061608 Decides whether or not to create a new DVS
16071609
16081610 Create a new the DVS in the following cases:
16091611 1. CLI option `--force-recreate-dvs` was specified (recreate for every module)
1610- 2. The dvs_env has changed (this can only be set at container creation,
1612+ 2. The fake_platform has changed (this can only be set at container creation,
16111613 so it is necessary to spin up a new DVS)
16121614 3. No DVS currently exists (i.e. first time startup)
16131615
@@ -1616,18 +1618,18 @@ def update_dvs(log_path, new_dvs_env=[]):
16161618 Returns:
16171619 (DockerVirtualSwitch) a DVS object
16181620 """
1619- nonlocal curr_dvs_env , dvs
1621+ nonlocal curr_fake_platform , dvs
16201622 if force_recreate or \
1621- new_dvs_env != curr_dvs_env or \
1623+ new_fake_platform != curr_fake_platform or \
16221624 dvs is None :
16231625
16241626 if dvs is not None :
16251627 dvs .get_logs ()
16261628 dvs .destroy ()
16271629
1628- dvs = DockerVirtualSwitch (name , imgname , keeptb , new_dvs_env , log_path , max_cpu , forcedvs , buffer_model = buffer_model )
1630+ dvs = DockerVirtualSwitch (name , imgname , keeptb , new_fake_platform , log_path , max_cpu , forcedvs , buffer_model = buffer_model )
16291631
1630- curr_dvs_env = new_dvs_env
1632+ curr_fake_platform = new_fake_platform
16311633
16321634 else :
16331635 # First generate GCDA files for GCov
@@ -1652,11 +1654,11 @@ def update_dvs(log_path, new_dvs_env=[]):
16521654
16531655@pytest .yield_fixture (scope = "module" )
16541656def dvs (request , manage_dvs ) -> DockerVirtualSwitch :
1655- dvs_env = getattr (request .module , "DVS_ENV " , [] )
1657+ fakeplatform = getattr (request .module , "DVS_FAKE_PLATFORM " , None )
16561658 name = request .config .getoption ("--dvsname" )
16571659 log_path = name if name else request .module .__name__
16581660
1659- return manage_dvs (log_path , dvs_env )
1661+ return manage_dvs (log_path , fakeplatform )
16601662
16611663@pytest .yield_fixture (scope = "module" )
16621664def vct (request ):
@@ -1667,11 +1669,11 @@ def vct(request):
16671669 imgname = request .config .getoption ("--imgname" )
16681670 max_cpu = request .config .getoption ("--max_cpu" )
16691671 log_path = vctns if vctns else request .module .__name__
1670- dvs_env = getattr (request .module , "DVS_ENV " , [] )
1672+ fakeplatform = getattr (request .module , "DVS_FAKE_PLATFORM " , None )
16711673 if not topo :
16721674 # use ecmp topology as default
16731675 topo = "virtual_chassis/chassis_with_ecmp_neighbors.json"
1674- vct = DockerVirtualChassisTopology (vctns , imgname , keeptb , dvs_env , log_path , max_cpu ,
1676+ vct = DockerVirtualChassisTopology (vctns , imgname , keeptb , fakeplatform , log_path , max_cpu ,
16751677 forcedvs , topo )
16761678 yield vct
16771679 vct .get_logs (request .module .__name__ )
0 commit comments