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 ))
@@ -293,7 +301,8 @@ def __init__(
293301 newctnname : str = None ,
294302 ctnmounts : Dict [str , str ] = None ,
295303 buffer_model : str = None ,
296- enable_coverage : bool = False
304+ enable_coverage : bool = False ,
305+ switch_mode : str = None
297306 ):
298307 self .basicd = ["redis-server" , "rsyslogd" ]
299308 self .swssd = [
@@ -316,6 +325,7 @@ def __init__(
316325 self .vct = vct
317326 self .ctn = None
318327 self .enable_coverage = enable_coverage
328+ self .switch_mode = switch_mode
319329
320330 self .cleanup = not keeptb
321331
@@ -577,7 +587,10 @@ def check_swss_ready(self, timeout: int = 300) -> None:
577587 self .get_config_db ()
578588 metadata = self .config_db .get_entry ('DEVICE_METADATA|localhost' , '' )
579589 if metadata .get ('switch_type' , 'npu' ) in ['voq' , 'fabric' ]:
580- num_ports = NUM_PORTS + FABRIC_NUM_PORTS
590+ if self .switch_mode and self .switch_mode == SINGLE_ASIC_VOQ_FS :
591+ num_ports = NUM_PORTS
592+ else :
593+ num_ports = NUM_PORTS + FABRIC_NUM_PORTS
581594
582595 # Verify that all ports have been initialized and configured
583596 app_db = self .get_app_db ()
@@ -597,8 +610,9 @@ def _polling_function():
597610
598611 # Verify that fabric ports are monitored in STATE_DB
599612 if metadata .get ('switch_type' , 'npu' ) in ['voq' , 'fabric' ]:
600- self .get_state_db ()
601- self .state_db .wait_for_n_keys ("FABRIC_PORT_TABLE" , FABRIC_NUM_PORTS )
613+ if not self .switch_mode or (self .switch_mode and self .switch_mode != SINGLE_ASIC_VOQ_FS ):
614+ self .get_state_db ()
615+ self .state_db .wait_for_n_keys ("FABRIC_PORT_TABLE" , FABRIC_NUM_PORTS )
602616
603617 def net_cleanup (self ) -> None :
604618 """Clean up network, remove extra links."""
@@ -1669,6 +1683,11 @@ def create_vct_ctn(self, ctndir):
16691683 vol = {}
16701684 vol [chassis_config_dir ] = {"bind" : "/usr/share/sonic/virtual_chassis" , "mode" : "ro" }
16711685
1686+ # Mount database_config.json when connect_to_chassis_db is set to 1
1687+ if defcfg .get ("connect_to_chassis_db" ) == 1 :
1688+ database_config_file = cwd + "/virtual_chassis/database_config.json"
1689+ vol [database_config_file ] = {"bind" : "/etc/sonic/database_config.json" , "mode" : "ro" }
1690+
16721691 # pass self.ns into the vs to be use for vs restarts by swss conftest.
16731692 # connection to chassbr is setup by chassis_connect.py within the vs
16741693 data = {}
@@ -1859,6 +1878,7 @@ def manage_dvs(request) -> str:
18591878 force_recreate = request .config .getoption ("--force-recreate-dvs" )
18601879 graceful_stop = request .config .getoption ("--graceful-stop" )
18611880 enable_coverage = request .config .getoption ("--enable-coverage" )
1881+ switch_mode = request .config .getoption ("--switch-mode" )
18621882
18631883 dvs = None
18641884 curr_dvs_env = [] # lgtm[py/unused-local-variable]
@@ -1890,7 +1910,13 @@ def update_dvs(log_path, new_dvs_env=[]):
18901910 dvs .get_logs ()
18911911 dvs .destroy ()
18921912
1893- dvs = DockerVirtualSwitch (name , imgname , keeptb , new_dvs_env , log_path , max_cpu , forcedvs , buffer_model = buffer_model , enable_coverage = enable_coverage )
1913+ vol = {}
1914+ if switch_mode and switch_mode == SINGLE_ASIC_VOQ_FS :
1915+ cwd = os .getcwd ()
1916+ voq_configs = cwd + "/single_asic_voq_fs"
1917+ vol [voq_configs ] = {"bind" : "/usr/share/sonic/single_asic_voq_fs" , "mode" : "ro" }
1918+
1919+ 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 )
18941920
18951921 curr_dvs_env = new_dvs_env
18961922
0 commit comments