4444# Voq asics will have 16 fabric ports created (defined in Azure/sonic-buildimage#7629).
4545FABRIC_NUM_PORTS = 16
4646
47+ SINGLE_ASIC_VOQ_FS = "single_asic_voq_fs"
48+
4749def ensure_system (cmd ):
4850 rc , output = subprocess .getstatusoutput (cmd )
4951 if rc :
@@ -112,6 +114,12 @@ def pytest_addoption(parser):
112114 default = False ,
113115 help = "Collect the test coverage information" )
114116
117+ parser .addoption ("--switch-mode" ,
118+ action = "store" ,
119+ default = None ,
120+ type = str ,
121+ help = "Set switch mode information" )
122+
115123
116124def random_string (size = 4 , chars = string .ascii_uppercase + string .digits ):
117125 return "" .join (random .choice (chars ) for x in range (size ))
@@ -294,7 +302,8 @@ def __init__(
294302 newctnname : str = None ,
295303 ctnmounts : Dict [str , str ] = None ,
296304 buffer_model : str = None ,
297- enable_coverage : bool = False
305+ enable_coverage : bool = False ,
306+ switch_mode : str = None
298307 ):
299308 self .basicd = ["redis-server" , "rsyslogd" ]
300309 self .swssd = [
@@ -317,6 +326,7 @@ def __init__(
317326 self .vct = vct
318327 self .ctn = None
319328 self .enable_coverage = enable_coverage
329+ self .switch_mode = switch_mode
320330
321331 self .cleanup = not keeptb
322332
@@ -583,7 +593,10 @@ def check_swss_ready(self, timeout: int = 300) -> None:
583593 self .get_config_db ()
584594 metadata = self .config_db .get_entry ('DEVICE_METADATA|localhost' , '' )
585595 if metadata .get ('switch_type' , 'npu' ) in ['voq' , 'fabric' ]:
586- num_ports = NUM_PORTS + FABRIC_NUM_PORTS
596+ if self .switch_mode and self .switch_mode == SINGLE_ASIC_VOQ_FS :
597+ num_ports = NUM_PORTS
598+ else :
599+ num_ports = NUM_PORTS + FABRIC_NUM_PORTS
587600
588601 # Verify that all ports have been initialized and configured
589602 app_db = self .get_app_db ()
@@ -603,8 +616,9 @@ def _polling_function():
603616
604617 # Verify that fabric ports are monitored in STATE_DB
605618 if metadata .get ('switch_type' , 'npu' ) in ['voq' , 'fabric' ]:
606- self .get_state_db ()
607- self .state_db .wait_for_n_keys ("FABRIC_PORT_TABLE" , FABRIC_NUM_PORTS )
619+ if not self .switch_mode or (self .switch_mode and self .switch_mode != SINGLE_ASIC_VOQ_FS ):
620+ self .get_state_db ()
621+ self .state_db .wait_for_n_keys ("FABRIC_PORT_TABLE" , FABRIC_NUM_PORTS )
608622
609623 def net_cleanup (self ) -> None :
610624 """Clean up network, remove extra links."""
@@ -1690,6 +1704,11 @@ def create_vct_ctn(self, ctndir):
16901704 vol = {}
16911705 vol [chassis_config_dir ] = {"bind" : "/usr/share/sonic/virtual_chassis" , "mode" : "ro" }
16921706
1707+ # Mount database_config.json when connect_to_chassis_db is set to 1
1708+ if defcfg .get ("connect_to_chassis_db" ) == 1 :
1709+ database_config_file = cwd + "/virtual_chassis/database_config.json"
1710+ vol [database_config_file ] = {"bind" : "/etc/sonic/database_config.json" , "mode" : "ro" }
1711+
16931712 # pass self.ns into the vs to be use for vs restarts by swss conftest.
16941713 # connection to chassbr is setup by chassis_connect.py within the vs
16951714 data = {}
@@ -1880,6 +1899,7 @@ def manage_dvs(request) -> str:
18801899 force_recreate = request .config .getoption ("--force-recreate-dvs" )
18811900 graceful_stop = request .config .getoption ("--graceful-stop" )
18821901 enable_coverage = request .config .getoption ("--enable-coverage" )
1902+ switch_mode = request .config .getoption ("--switch-mode" )
18831903
18841904 dvs = None
18851905 curr_dvs_env = [] # lgtm[py/unused-local-variable]
@@ -1911,7 +1931,13 @@ def update_dvs(log_path, new_dvs_env=[]):
19111931 dvs .get_logs ()
19121932 dvs .destroy ()
19131933
1914- dvs = DockerVirtualSwitch (name , imgname , keeptb , new_dvs_env , log_path , max_cpu , forcedvs , buffer_model = buffer_model , enable_coverage = enable_coverage )
1934+ vol = {}
1935+ if switch_mode and switch_mode == SINGLE_ASIC_VOQ_FS :
1936+ cwd = os .getcwd ()
1937+ voq_configs = cwd + "/single_asic_voq_fs"
1938+ vol [voq_configs ] = {"bind" : "/usr/share/sonic/single_asic_voq_fs" , "mode" : "ro" }
1939+
1940+ dvs = DockerVirtualSwitch (name , imgname , keeptb , new_dvs_env , log_path , max_cpu , forcedvs , buffer_model = buffer_model , enable_coverage = enable_coverage , ctnmounts = vol , switch_mode = switch_mode )
19151941
19161942 curr_dvs_env = new_dvs_env
19171943
0 commit comments