Skip to content
7 changes: 7 additions & 0 deletions ansible/library/dut_basic_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ def main():
else:
results['asic_index_list'] = [ns.replace('asic', '') for ns in multi_asic.get_namespace_list()]

results['is_smartswitch'] = False
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it support light mode and dark mode?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JibinBao, Variable is defined for all topo, it will be only true for smartswitch (in both darkmode and litmode)

if hasattr(device_info, 'is_smartswitch'):
results['is_smartswitch'] = device_info.is_smartswitch()
results['is_dpu'] = False
if hasattr(device_info, 'is_dpu'):
results['is_dpu'] = device_info.is_dpu()

# In case a image does not have /etc/sonic/sonic_release, guess release from 'build_version'
if 'release' not in results or not results['release'] or results['release'] == 'none':
if 'build_version' in results:
Expand Down
36 changes: 0 additions & 36 deletions tests/common/devices/sonic.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,42 +424,6 @@ def is_supervisor_node(self):
inv_files = im._sources
return is_supervisor_node(inv_files, self.hostname)

def is_smartswitch(self):
"""Check if the current node is a SmartSwitch

Returns:
True if the current node is a SmartSwitch, else False
"""
config_facts = self.config_facts(host=self.hostname, source="running")['ansible_facts']
if (
"DEVICE_METADATA" in config_facts and
"localhost" in config_facts["DEVICE_METADATA"] and
"subtype" in config_facts["DEVICE_METADATA"]["localhost"] and
config_facts["DEVICE_METADATA"]["localhost"]["subtype"] == "SmartSwitch" and
"type" in config_facts["DEVICE_METADATA"]["localhost"] and
config_facts["DEVICE_METADATA"]["localhost"]["type"] != "SmartSwitchDPU"
):
return True

return False

def is_dpu(self):
"""Check if the current node is a DPU

Returns:
True if the current node is a DPU, else False
"""
config_facts = self.config_facts(host=self.hostname, source="running")['ansible_facts']
if (
"DEVICE_METADATA" in config_facts and
"localhost" in config_facts["DEVICE_METADATA"] and
"type" in config_facts["DEVICE_METADATA"]["localhost"] and
config_facts["DEVICE_METADATA"]["localhost"]["type"] == "SmartSwitchDPU"
):
return True

return False

def is_frontend_node(self):
"""Check if the current node is a frontend node in case of multi-DUT.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1060,11 +1060,12 @@ platform_tests/test_advanced_reboot.py::test_fast_reboot_from_other_vendor:

platform_tests/test_advanced_reboot.py::test_warm_reboot:
skip:
reason: "Skip in PR testing as taking too much time. / Warm reboot is not required for 202412"
reason: "Skip in PR testing as taking too much time. / Warm reboot is not required for 202412 / Skip for smartswitch topology."
conditions_logical_operator: or
conditions:
- "asic_type in ['vs'] and 't0' not in topo_name"
- "release in ['202412']"
- "is_smartswitch==True"

platform_tests/test_advanced_reboot.py::test_warm_reboot_mac_jump:
skip:
Expand Down Expand Up @@ -1206,12 +1207,13 @@ platform_tests/test_reboot.py::test_cold_reboot:

platform_tests/test_reboot.py::test_fast_reboot:
skip:
reason: "Skip test_fast_reboot for M*/t1/t2 / Fast reboot is broken on dualtor topology. Skipping for now."
reason: "Skip test_fast_reboot for M*/t1/t2 / Fast reboot is broken on dualtor topology. Skipping for now. / Skip for smartswitch topology."
conditions_logical_operator: or
conditions:
- "topo_type in ['m0', 'mx', 'm1', 't1', 't2']"
- "'dualtor' in topo_name and https://github.com/sonic-net/sonic-buildimage/issues/16502"
- "release in ['202412']"
- "is_smartswitch==True"
xfail:
reason: "case failed and waiting for fix"
conditions:
Expand Down
2 changes: 1 addition & 1 deletion tests/common/reboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def reboot(duthost, localhost, reboot_type='cold', delay=10,
collect_console_log, args=(duthost, localhost, timeout + wait_conlsole_connection))
time.sleep(wait_conlsole_connection)
# Perform reboot
if duthost.is_smartswitch():
if duthost.get_facts().get("is_smartswitch"):
reboot_res, dut_datetime = reboot_smartswitch(duthost, reboot_type)
else:
reboot_res, dut_datetime = perform_reboot(duthost, pool, reboot_command, reboot_helper,
Expand Down
6 changes: 0 additions & 6 deletions tests/platform_tests/test_reboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,6 @@ def test_fast_reboot(duthosts, enum_rand_one_per_hwsku_hostname,
if duthost.is_multi_asic:
pytest.skip("Multi-ASIC devices not supporting fast reboot")

if duthost.is_smartswitch():
pytest.skip("Smart Switch devices does not support fast reboot")

reboot_and_check(localhost, duthost, conn_graph_facts.get("device_conn", {}).get(duthost.hostname, {}),
xcvr_skip_list, reboot_type=REBOOT_TYPE_FAST, duthosts=duthosts)

Expand All @@ -239,9 +236,6 @@ def test_warm_reboot(duthosts, enum_rand_one_per_hwsku_hostname,
if duthost.is_multi_asic:
pytest.skip("Multi-ASIC devices not supporting warm reboot")

if duthost.is_smartswitch():
pytest.skip("Smart Switch devices does not support warm reboot")

asic_type = duthost.facts["asic_type"]

if asic_type in ["mellanox"]:
Expand Down
14 changes: 3 additions & 11 deletions tests/show_techsupport/test_techsupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,13 @@ def setup_acl_rules(duthost, acl_setup):
duthost.command('config acl update full {}'.format(dut_conf_file_path))


def check_dut_is_dpu(duthosts, enum_rand_one_per_hwsku_frontend_hostname):
"""
Check dut is dpu or not. True when dut is dpu, else False
"""
duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname]
config_facts = duthost.config_facts(host=duthost.hostname, source="running")['ansible_facts']
return config_facts['DEVICE_METADATA']['localhost'].get('switch_type', '') == 'dpu'


@pytest.fixture(scope='module')
def skip_on_dpu(duthosts, enum_rand_one_per_hwsku_frontend_hostname):
"""
When dut is dpu, skip the case
"""
if check_dut_is_dpu(duthosts, enum_rand_one_per_hwsku_frontend_hostname):
duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname]
if duthost.get_facts().get('is_dpu'):
pytest.skip("Skip the test, as it is not supported on DPU.")


Expand Down Expand Up @@ -628,7 +620,7 @@ def test_techsupport_on_dpu(duthosts, enum_rand_one_per_hwsku_frontend_hostname)
:param duthosts: DUT host
"""
duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname]
if not check_dut_is_dpu(duthosts, enum_rand_one_per_hwsku_frontend_hostname):
if not duthost.get_facts().get('is_dpu'):
pytest.skip("Skip the test, as it is supported only on DPU.")

since = str(randint(1, 5)) + " minute ago"
Expand Down
17 changes: 13 additions & 4 deletions tests/smartswitch/common/device_utils_dpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,21 @@ def num_dpu_modules(platform_api_conn): # noqa F811
return num_modules


@pytest.fixture(scope='function', autouse=True)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest make this scope "session", so that we can make sure the skip is before any other fixtures for test setup.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@congh-nvidia Not sure defining this scope to session works, as this depends on enum_rand_one_per_hwsku_hostname which is a scope of function.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@congh-nvidia By modifying the fixture, I changed the scope to session. Thanks!

def skip_for_non_smartswitch(duthosts, enum_rand_one_per_hwsku_hostname):
"""
Skip test if not running on a smartswitch testbed
"""
duthost = duthosts[enum_rand_one_per_hwsku_hostname]
if not duthost.facts.get('is_smartswitch'):
pytest.skip("Test is supported only on smartswitch testbeds. "
"is_smartswitch: {}".format(duthost.facts.get('is_smartswitch')))


@pytest.fixture(scope='function', autouse=True)
def check_smartswitch_and_dark_mode(duthosts, enum_rand_one_per_hwsku_hostname,
platform_api_conn, num_dpu_modules): # noqa F811
platform_api_conn, num_dpu_modules, # noqa F811
skip_for_non_smartswitch):
"""
Checks whether given testbed is running
202405 image or below versions
Expand All @@ -57,9 +69,6 @@ def check_smartswitch_and_dark_mode(duthosts, enum_rand_one_per_hwsku_hostname,

duthost = duthosts[enum_rand_one_per_hwsku_hostname]

if "DPUS" not in duthost.facts:
pytest.skip("Test is not supported for this testbed")

darkmode = is_dark_mode_enabled(duthost, platform_api_conn, num_dpu_modules) # noqa F811

if darkmode:
Expand Down
4 changes: 2 additions & 2 deletions tests/smartswitch/common/reboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def log_and_perform_reboot(duthost, reboot_type, dpu_name):
hostname = duthost.hostname

if reboot_type == REBOOT_TYPE_COLD:
if duthost.is_smartswitch():
if duthost.facts['is_smartswitch']:
if dpu_name is None:
logger.info("Sync reboot cause history queue with DUT reboot cause history queue")
sync_reboot_history_queue_with_dut(duthost)
Expand All @@ -33,7 +33,7 @@ def log_and_perform_reboot(duthost, reboot_type, dpu_name):
else:
logger.info("Rebooting the DPU {} with type {}".format(dpu_name, reboot_type))
return duthost.command("sudo reboot -d {}".format(dpu_name))
elif duthost.is_dpu():
elif duthost.facts['is_dpu']:
pytest.skip("Skipping the reboot test as the DUT is a DPU")
else:
pytest.skip("Skipping the reboot test as the reboot type {} is not supported".format(reboot_type))
Expand Down
Loading