Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions tests/snappi_tests/files/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
from tests.common.platform.interface_utils import check_interface_status_of_up_ports
from tests.common.snappi_tests.snappi_fixtures import get_snappi_ports_for_rdma, \
snappi_dut_base_config, is_snappi_multidut
from tests.common.snappi_tests.qos_fixtures import reapply_pfcwd, get_pfcwd_config
from tests.common.snappi_tests.common_helpers import \
stop_pfcwd, disable_packet_aging, enable_packet_aging


logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -383,3 +387,50 @@ def get_npu_voq_queue_counters(duthost, interface, priority, clear=False):
dict_output[entry] = value

return dict_output


@pytest.fixture(params=['warm', 'cold', 'fast'])
def reboot_duts_and_disable_wd(setup_ports_and_dut, localhost, request):
'''
Purpose of the function is to have reboot_duts and disable watchdogs.
'''
reboot_type = request.param
_, _, snappi_ports = setup_ports_and_dut
skip_warm_reboot(snappi_ports[0]['duthost'], reboot_type)
skip_warm_reboot(snappi_ports[1]['duthost'], reboot_type)
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.

isn't this repetitive ?


def save_config_and_reboot(node, results=None):
up_bgp_neighbors = node.get_bgp_neighbors_per_asic("established")
logger.info("Issuing a {} reboot on the dut {}".format(reboot_type, node.hostname))
node.shell("mkdir /etc/sonic/orig_configs; mv /etc/sonic/config_db* /etc/sonic/orig_configs/")
node.shell("sudo config save -y")
reboot(node, localhost, reboot_type=reboot_type, safe_reboot=True)
logger.info("Wait until the system is stable")
wait_until(180, 20, 0, node.critical_services_fully_started)
wait_until(180, 20, 0, check_interface_status_of_up_ports, node)
wait_until(300, 10, 0, node.check_bgp_session_state_all_asics, up_bgp_neighbors, "established")

# Convert the list of duthosts into a list of tuples as required for parallel func.
args = set((snappi_ports[0]['duthost'], snappi_ports[1]['duthost']))
parallel_run(save_config_and_reboot, {}, {}, list(args), timeout=900)
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.

If src and dest dut is same then will this reboot twice ?


pfcwd_value = {}

for duthost in list(args):
pfcwd_value[duthost.hostname] = get_pfcwd_config(duthost)
stop_pfcwd(duthost)
disable_packet_aging(duthost)

yield

for duthost in list(args):
reapply_pfcwd(duthost, pfcwd_value[duthost.hostname])
enable_packet_aging(duthost)

def revert_config_and_reload(node, results=None):
node.shell("mv /etc/sonic/orig_configs/* /etc/sonic/ ; rmdir /etc/sonic/orig_configs; ")
config_reload(node, safe_reload=True)

# parallel_run(revert_config_and_reload, {}, {}, list(args), timeout=900)
for duthost in args:
revert_config_and_reload(node=duthost)
29 changes: 15 additions & 14 deletions tests/snappi_tests/pfc/test_pfc_pause_lossless_with_snappi.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
snappi_api, snappi_dut_base_config, get_snappi_ports_for_rdma, cleanup_config, get_snappi_ports_multi_dut, \
snappi_testbed_config, get_snappi_ports_single_dut, \
get_snappi_ports, is_snappi_multidut # noqa: F401
from tests.snappi_tests.files.helper import multidut_port_info, setup_ports_and_dut, reboot_duts # noqa: F401
from tests.snappi_tests.files.helper import multidut_port_info, setup_ports_and_dut, reboot_duts, \
reboot_duts_and_disable_wd # noqa: F401
from tests.common.snappi_tests.qos_fixtures import prio_dscp_map, all_prio_list, lossless_prio_list,\
lossy_prio_list, disable_pfcwd # noqa F401
from tests.snappi_tests.pfc.files.helper import run_pfc_test
Expand Down Expand Up @@ -204,14 +205,13 @@ def test_pfc_pause_single_lossless_prio_reboot(snappi_api, # n
duthosts,
localhost,
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
get_snappi_ports, # noqa: F811
tbinfo, # noqa: F811
setup_ports_and_dut, # noqa: F811
disable_pfcwd, # noqa: F811
reboot_duts): # noqa: F811
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.

@amitpawar12, as discussed, the order is not guaranteed here. we can either define a new fixture to explicit define the dependency, or add one function level fixture.

prio_dscp_map, # noqa: F811
lossless_prio_list, # noqa: F811
all_prio_list, # noqa: F811
get_snappi_ports, # noqa: F811
tbinfo, # noqa: F811
reboot_duts_and_disable_wd, # noqa: F811
setup_ports_and_dut): # noqa: F811
"""
Test if PFC can pause a single lossless priority even after various types of reboot in multidut setup

Expand All @@ -226,7 +226,8 @@ def test_pfc_pause_single_lossless_prio_reboot(snappi_api, # n
prio_dscp_map (pytest fixture): priority vs. DSCP map (key = priority).
lossless_prio_list (pytest fixture): list of all the lossless priorities
tbinfo (pytest fixture): fixture provides information about testbed
get_snappi_ports (pytest fixture): gets snappi ports and connected DUT port info and returns as a list
reboot_duts_and_disable_wd (pytest fixture): fixture reboots associated DUTs and disables Credit and PFC WD
setup_ports_and_dut (pytest fixture): gets snappi ports and connected DUT port info and returns as a list
Returns:
N/A
"""
Expand Down Expand Up @@ -268,9 +269,8 @@ def test_pfc_pause_multi_lossless_prio_reboot(snappi_api, # no
lossless_prio_list, # noqa: F811
get_snappi_ports, # noqa: F811
tbinfo, # noqa: F811
setup_ports_and_dut, # noqa: F811
disable_pfcwd, # noqa: F811
reboot_duts): # noqa: F811
reboot_duts_and_disable_wd, # noqa: F811
setup_ports_and_dut): # noqa: F811
"""
Test if PFC can pause multiple lossless priorities even after various types of reboot in multidut setup

Expand All @@ -284,7 +284,8 @@ def test_pfc_pause_multi_lossless_prio_reboot(snappi_api, # no
lossless_prio_list (pytest fixture): list of all the lossless priorities
lossy_prio_list (pytest fixture): list of all the lossy priorities
tbinfo (pytest fixture): fixture provides information about testbed
get_snappi_ports (pytest fixture): gets snappi ports and connected DUT port info and returns as a list
reboot_duts_and_disable_wd (pytest fixture): fixture reboots associated DUTs and disables Credit and PFC WD
setup_ports_and_dut (pytest fixture): gets snappi ports and connected DUT port info and returns as a list
Returns:
N/A
"""
Expand Down
Loading