Skip to content

Commit

Permalink
feat: add one_dut fixture to only use one dut (sonic-net#16197)
Browse files Browse the repository at this point in the history
Description of PR
Summary:

Currently, test_pfc_pause_single_lossy_prio and test_pfc_pause_single_lossy_prio_reboot are using more parameters than its needed, resulting in a longer execution time

Fixes # (issue) 30562817

Approach
What is the motivation for this PR?
Reducing the number of DUT but still give enough priorities for coverage

How did you do it?
Modify the current fixture to add an option to pick 1 DUT for testing only

How did you verify/test it?
physical testbed

Signed-off-by: Austin Pham <austinpham@microsoft.com>
  • Loading branch information
auspham authored and mssonicbld committed Jan 2, 2025
1 parent e8a171a commit 850d6be
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
22 changes: 21 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1497,7 +1497,7 @@ def generate_dut_backend_asics(request, duts_selected):
return dut_asic_list


def generate_priority_lists(request, prio_scope, with_completeness_level=False):
def generate_priority_lists(request, prio_scope, with_completeness_level=False, one_dut_only=False):
empty = []

tbname = request.config.getoption("--testbed")
Expand All @@ -1523,6 +1523,9 @@ def generate_priority_lists(request, prio_scope, with_completeness_level=False):
for p in priorities:
ret.append('{}|{}'.format(dut, p))

if one_dut_only:
break

if with_completeness_level:
completeness_level = get_completeness_level_metadata(request)
# if completeness_level in ["debug", "basic", "confident"],
Expand All @@ -1539,6 +1542,9 @@ def generate_priority_lists(request, prio_scope, with_completeness_level=False):
p = random.choice(priorities)
ret.append('{}|{}'.format(dut, p))

if one_dut_only:
break

return ret if ret else empty


Expand Down Expand Up @@ -1732,14 +1738,28 @@ def format_portautoneg_test_id(param):
metafunc.parametrize("enum_dut_all_prio", generate_priority_lists(metafunc, 'all'))
if 'enum_dut_lossless_prio' in metafunc.fixturenames:
metafunc.parametrize("enum_dut_lossless_prio", generate_priority_lists(metafunc, 'lossless'))
if 'enum_one_dut_lossless_prio' in metafunc.fixturenames:
metafunc.parametrize("enum_one_dut_lossless_prio",
generate_priority_lists(metafunc, 'lossless', one_dut_only=True))
if 'enum_dut_lossless_prio_with_completeness_level' in metafunc.fixturenames:
metafunc.parametrize("enum_dut_lossless_prio_with_completeness_level",
generate_priority_lists(metafunc, 'lossless', with_completeness_level=True))
if 'enum_one_dut_lossless_prio_with_completeness_level' in metafunc.fixturenames:
metafunc.parametrize("enum_one_dut_lossless_prio_with_completeness_level",
generate_priority_lists(metafunc, 'lossless', with_completeness_level=True,
one_dut_only=True))
if 'enum_dut_lossy_prio' in metafunc.fixturenames:
metafunc.parametrize("enum_dut_lossy_prio", generate_priority_lists(metafunc, 'lossy'))
if 'enum_one_dut_lossy_prio' in metafunc.fixturenames:
metafunc.parametrize("enum_one_dut_lossy_prio", generate_priority_lists(metafunc, 'lossy',
one_dut_only=True))
if 'enum_dut_lossy_prio_with_completeness_level' in metafunc.fixturenames:
metafunc.parametrize("enum_dut_lossy_prio_with_completeness_level",
generate_priority_lists(metafunc, 'lossy', with_completeness_level=True))
if 'enum_one_dut_lossy_prio_with_completeness_level' in metafunc.fixturenames:
metafunc.parametrize("enum_one_dut_lossy_prio_with_completeness_level",
generate_priority_lists(metafunc, 'lossy', with_completeness_level=True,
one_dut_only=True))
if 'enum_pfc_pause_delay_test_params' in metafunc.fixturenames:
metafunc.parametrize("enum_pfc_pause_delay_test_params", pfc_pause_delay_test_params(metafunc))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_pfc_pause_single_lossless_prio(snappi_api, # noqa:
conn_graph_facts, # noqa: F811
fanout_graph_facts_multidut, # noqa: F811
duthosts,
enum_dut_lossless_prio,
enum_one_dut_lossless_prio,
prio_dscp_map, # noqa: F811
lossless_prio_list, # noqa: F811
all_prio_list, # noqa: F811
Expand Down Expand Up @@ -58,7 +58,7 @@ def test_pfc_pause_single_lossless_prio(snappi_api, # noqa:

testbed_config, port_config_list, snappi_ports = setup_ports_and_dut

_, lossless_prio = enum_dut_lossless_prio.split('|')
_, lossless_prio = enum_one_dut_lossless_prio.split('|')
lossless_prio = int(lossless_prio)
pause_prio_list = [lossless_prio]
test_prio_list = [lossless_prio]
Expand Down Expand Up @@ -142,7 +142,7 @@ def test_pfc_pause_single_lossless_prio_reboot(snappi_api, # n
fanout_graph_facts_multidut, # noqa: F811
duthosts,
localhost,
enum_dut_lossless_prio_with_completeness_level, # noqa: F811
enum_one_dut_lossless_prio_with_completeness_level, # noqa: F811
prio_dscp_map, # noqa: F811
lossless_prio_list, # noqa: F811
all_prio_list, # noqa: F811
Expand Down Expand Up @@ -171,7 +171,7 @@ def test_pfc_pause_single_lossless_prio_reboot(snappi_api, # n
"""
testbed_config, port_config_list, snappi_ports = setup_ports_and_dut

_, lossless_prio = enum_dut_lossless_prio_with_completeness_level.split('|')
_, lossless_prio = enum_one_dut_lossless_prio_with_completeness_level.split('|')
lossless_prio = int(lossless_prio)
pause_prio_list = [lossless_prio]
test_prio_list = [lossless_prio]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_pfc_pause_single_lossy_prio(snappi_api, # noqa: F811
conn_graph_facts, # noqa: F811
fanout_graph_facts_multidut, # noqa: F811
duthosts,
enum_dut_lossy_prio,
enum_one_dut_lossy_prio,
prio_dscp_map, # noqa: F811
lossy_prio_list, # noqa: F811
all_prio_list, # noqa: F811
Expand Down Expand Up @@ -57,7 +57,7 @@ def test_pfc_pause_single_lossy_prio(snappi_api, # noqa: F811
"""
testbed_config, port_config_list, snappi_ports = setup_ports_and_dut

_, lossy_prio = enum_dut_lossy_prio.split('|')
_, lossy_prio = enum_one_dut_lossy_prio.split('|')
lossy_prio = int(lossy_prio)
pause_prio_list = [lossy_prio]
test_prio_list = [lossy_prio]
Expand Down Expand Up @@ -150,7 +150,7 @@ def test_pfc_pause_single_lossy_prio_reboot(snappi_api, # noqa: F811
fanout_graph_facts_multidut, # noqa: F811
duthosts,
localhost,
enum_dut_lossy_prio_with_completeness_level,
enum_one_dut_lossy_prio_with_completeness_level,
prio_dscp_map, # noqa: F811
lossy_prio_list, # noqa: F811
all_prio_list, # noqa: F811
Expand Down Expand Up @@ -180,7 +180,7 @@ def test_pfc_pause_single_lossy_prio_reboot(snappi_api, # noqa: F811
"""
testbed_config, port_config_list, snappi_ports = setup_ports_and_dut

_, lossy_prio = enum_dut_lossy_prio_with_completeness_level.split('|')
_, lossy_prio = enum_one_dut_lossy_prio_with_completeness_level.split('|')
lossy_prio = int(lossy_prio)
pause_prio_list = [lossy_prio]
test_prio_list = [lossy_prio]
Expand Down

0 comments on commit 850d6be

Please sign in to comment.