|
| 1 | +"""SAI thrift-based tests for the OQ watchdog feature in SONiC. |
| 2 | +This set of test cases verifies OQ watchdog behavior. These are dataplane |
| 3 | +tests that depend on the SAI thrift library in order to pause ports and read |
| 4 | +drop counters. |
| 5 | +Parameters: |
| 6 | + --ptf_portmap <filename> (str): file name of port index to DUT interface alias map. Default is None. |
| 7 | + In case a filename is not provided, a file containing a port indices to aliases map will be generated. |
| 8 | + --qos_swap_syncd (bool): Used to install the RPC syncd image before running the tests. Default is True. |
| 9 | + --qos_dst_ports (list) Indices of available DUT test ports to serve as destination ports. Note: This is not port |
| 10 | + index on DUT, rather an index into filtered (excludes lag member ports) DUT ports. Plan is to randomize port |
| 11 | + selection. Default is [0, 1, 3]. |
| 12 | + --qos_src_ports (list) Indices of available DUT test ports to serve as source port. Similar note as in |
| 13 | + qos_dst_ports applies. Default is [2]. |
| 14 | +""" |
| 15 | + |
| 16 | +import logging |
| 17 | +import pytest |
| 18 | + |
| 19 | +from tests.common.fixtures.duthost_utils import dut_qos_maps, \ |
| 20 | + separated_dscp_to_tc_map_on_uplink # noqa F401 |
| 21 | +from tests.common.fixtures.ptfhost_utils import copy_ptftests_directory # noqa F401 |
| 22 | +from tests.common.fixtures.ptfhost_utils import copy_saitests_directory # noqa F401 |
| 23 | +from tests.common.fixtures.ptfhost_utils import change_mac_addresses # noqa F401 |
| 24 | +from .qos_sai_base import QosSaiBase |
| 25 | + |
| 26 | +logger = logging.getLogger(__name__) |
| 27 | + |
| 28 | +pytestmark = [ |
| 29 | + pytest.mark.topology('any') |
| 30 | +] |
| 31 | + |
| 32 | +PKTS_NUM = 100 |
| 33 | + |
| 34 | + |
| 35 | +@pytest.fixture(scope="function") |
| 36 | +def ignore_log_oq_watchdog(duthosts, loganalyzer): |
| 37 | + if not loganalyzer: |
| 38 | + yield |
| 39 | + return |
| 40 | + ignore_list = [r".*HARDWARE_WATCHDOG.*", r".*soft_reset*"] |
| 41 | + for dut in duthosts: |
| 42 | + for line in ignore_list: |
| 43 | + loganalyzer[dut.hostname].ignore_regex.append(line) |
| 44 | + yield |
| 45 | + return |
| 46 | + |
| 47 | + |
| 48 | +class TestOqWatchdog(QosSaiBase): |
| 49 | + """TestVoqWatchdog derives from QosSaiBase and contains collection of OQ watchdog test cases. |
| 50 | + """ |
| 51 | + @pytest.fixture(scope="class", autouse=True) |
| 52 | + def check_skip_oq_watchdog_test(self, get_src_dst_asic_and_duts): |
| 53 | + if not self.oq_watchdog_enabled(get_src_dst_asic_and_duts): |
| 54 | + pytest.skip("OQ watchdog test is skipped since OQ watchdog is not enabled.") |
| 55 | + |
| 56 | + def testOqWatchdog( |
| 57 | + self, ptfhost, dutTestParams, dutConfig, dutQosConfig, |
| 58 | + get_src_dst_asic_and_duts, ignore_log_oq_watchdog, |
| 59 | + disable_voq_watchdog_function_scope |
| 60 | + ): |
| 61 | + """ |
| 62 | + Test OQ watchdog functionality. |
| 63 | + Test steps: |
| 64 | + 1. block voq7, sys_port scheduler set Q7 credit_pir to 0 |
| 65 | + 2. fill leakout of Q7 by ping, make sure no packet dequeue/enqueue in OQ7 afterwards |
| 66 | + 3. block oq0, sys_port scheduler set Q0 transmit_pir to 0 |
| 67 | + 4. send traffic on Q0, oq watchdog should be triggered in about 5 seconds |
| 68 | + 5. Unblock voq7 and oq0 to restore the system state |
| 69 | + 6. Run TrafficSanityTest to verify the system state is restored |
| 70 | + Args: |
| 71 | + ptfhost (AnsibleHost): Packet Test Framework (PTF) |
| 72 | + dutTestParams (Fixture, dict): DUT host test params |
| 73 | + dutConfig (Fixture, dict): Map of DUT config containing dut interfaces, test port IDs, test port IPs, |
| 74 | + and test ports |
| 75 | + dutQosConfig (Fixture, dict): Map containing DUT host QoS configuration |
| 76 | + Returns: |
| 77 | + None |
| 78 | + Raises: |
| 79 | + RunAnsibleModuleFail if ptf test fails |
| 80 | + """ |
| 81 | + |
| 82 | + # Block voq7 |
| 83 | + dst_dut = get_src_dst_asic_and_duts['dst_dut'] |
| 84 | + dst_asic_index = get_src_dst_asic_and_duts['dst_asic_index'] |
| 85 | + dst_port = dutConfig['dutInterfaces'][dutConfig["testPorts"]["dst_port_id"]] |
| 86 | + original_pir_voq7 = self.block_queue(dst_dut, dst_port, 7, "voq", dst_asic_index) |
| 87 | + # Fill leakout of Q7 by ping |
| 88 | + cmd_opt = "sudo ip netns exec asic{}".format(dst_asic_index) |
| 89 | + if not dst_dut.sonichost.is_multi_asic: |
| 90 | + cmd_opt = "" |
| 91 | + dst_dut.shell("{} ping -I {} -c 50 1.1.1.1 -i 0 -w 0 || true".format(cmd_opt, dst_port)) |
| 92 | + |
| 93 | + # Block oq0 |
| 94 | + original_pir_oq0 = self.block_queue(dst_dut, dst_port, 0, "oq", dst_asic_index) |
| 95 | + |
| 96 | + testParams = dict() |
| 97 | + testParams.update(dutTestParams["basicParams"]) |
| 98 | + testParams.update({ |
| 99 | + "dscp": 8, |
| 100 | + "dst_port_id": dutConfig["testPorts"]["dst_port_id"], |
| 101 | + "dst_port_ip": dutConfig["testPorts"]["dst_port_ip"], |
| 102 | + "src_port_id": dutConfig["testPorts"]["src_port_id"], |
| 103 | + "src_port_ip": dutConfig["testPorts"]["src_port_ip"], |
| 104 | + "src_port_vlan": dutConfig["testPorts"]["src_port_vlan"], |
| 105 | + "packet_size": 1350, |
| 106 | + "pkts_num": PKTS_NUM, |
| 107 | + "oq_watchdog_enabled": True, |
| 108 | + }) |
| 109 | + |
| 110 | + self.runPtfTest( |
| 111 | + ptfhost, testCase="sai_qos_tests.OqWatchdogTest", |
| 112 | + testParams=testParams) |
| 113 | + |
| 114 | + # Unblock voq7 and oq0 to restore the system state |
| 115 | + self.unblock_queue(dst_dut, dst_port, 7, "voq", original_pir_voq7, dst_asic_index) |
| 116 | + self.unblock_queue(dst_dut, dst_port, 0, "oq", original_pir_oq0, dst_asic_index) |
| 117 | + |
| 118 | + self.runPtfTest( |
| 119 | + ptfhost, testCase="sai_qos_tests.TrafficSanityTest", |
| 120 | + testParams=testParams) |
0 commit comments