Skip to content

Commit a1c6563

Browse files
stephenxsmssonicbld
authored andcommitted
Enhance PFC watchdog log analyzer to check debug information on a per-vendor basis (sonic-net#10305)
* Enhance PFC watchdog debug information checking 1. Check diagnosis information in PFC watchdog detection message on a per-vendor basis 2. Move expected log message to a common file
1 parent b4bbe77 commit a1c6563

4 files changed

Lines changed: 31 additions & 9 deletions

File tree

tests/pfcwd/files/pfcwd_helper.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@
88
if sys.version_info[0] >= 3:
99
unicode = str
1010

11+
EXPECT_PFC_WD_DETECT_RE = ".* detected PFC storm .*"
12+
VENDOR_SPEC_ADDITIONAL_INFO_RE = {
13+
"mellanox":
14+
r"additional info: occupancy:[0-9]+\|packets:[0-9]+\|packets_last:[0-9]+\|pfc_rx_packets:[0-9]+\|"
15+
r"pfc_rx_packets_last:[0-9]+\|pfc_duration:[0-9]+\|pfc_duration_last:[0-9]+\|timestamp:[0-9]+\.[0-9]+\|"
16+
r"timestamp_last:[0-9]+\.[0-9]+\|real_poll_time:[0-9]+"
17+
}
18+
EXPECT_PFC_WD_RESTORE_RE = ".*storm restored.*"
19+
1120

1221
class TrafficPorts(object):
1322
""" Generate a list of ports needed for the PFC Watchdog test"""
@@ -342,3 +351,16 @@ def start_wd_on_ports(duthost, port, restore_time, detect_time, action="drop"):
342351
"""
343352
duthost.command("pfcwd start --action {} --restoration-time {} {} {}"
344353
.format(action, restore_time, port, detect_time))
354+
355+
356+
def fetch_vendor_specific_diagnosis_re(duthost):
357+
"""
358+
Fetch regular expression of vendor specific diagnosis information
359+
Args:
360+
duthost: The duthost object
361+
"""
362+
unsupported_branches = ['202012', '202205', '202211']
363+
if duthost.os_version in unsupported_branches or duthost.sonic_release in unsupported_branches:
364+
return ""
365+
366+
return VENDOR_SPEC_ADDITIONAL_INFO_RE.get(duthost.facts["asic_type"], "")

tests/pfcwd/test_pfcwd_all_port_storm.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
from tests.common.helpers.pfc_storm import PFCMultiStorm
88
from tests.common.plugins.loganalyzer.loganalyzer import LogAnalyzer
99
from .files.pfcwd_helper import start_wd_on_ports
10+
from .files.pfcwd_helper import EXPECT_PFC_WD_DETECT_RE, EXPECT_PFC_WD_RESTORE_RE, fetch_vendor_specific_diagnosis_re
1011

1112
TEMPLATES_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "templates")
12-
EXPECT_PFC_WD_DETECT_RE = ".* detected PFC storm .*"
13-
EXPECT_PFC_WD_RESTORE_RE = ".*storm restored.*"
1413

1514
pytestmark = [
1615
pytest.mark.disable_loganalyzer,
@@ -157,7 +156,10 @@ def test_all_port_storm_restore(self, duthosts, enum_rand_one_per_hwsku_frontend
157156
duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname]
158157
storm_hndle = storm_test_setup_restore
159158
logger.info("--- Testing if PFC storm is detected on all ports ---")
160-
self.run_test(duthost, storm_hndle, expect_regex=[EXPECT_PFC_WD_DETECT_RE], syslog_marker="all_port_storm",
159+
self.run_test(duthost,
160+
storm_hndle,
161+
expect_regex=[EXPECT_PFC_WD_DETECT_RE + fetch_vendor_specific_diagnosis_re(duthost)],
162+
syslog_marker="all_port_storm",
161163
action="storm")
162164

163165
logger.info("--- Testing if PFC storm is restored on all ports ---")

tests/pfcwd/test_pfcwd_function.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from tests.common.helpers.pfc_storm import PFCStorm
1111
from tests.common.plugins.loganalyzer.loganalyzer import LogAnalyzer
1212
from .files.pfcwd_helper import start_wd_on_ports
13+
from .files.pfcwd_helper import EXPECT_PFC_WD_DETECT_RE, EXPECT_PFC_WD_RESTORE_RE, fetch_vendor_specific_diagnosis_re
1314
from tests.ptf_runner import ptf_runner
1415
from tests.common import port_toggle
1516
from tests.common import constants
@@ -20,8 +21,6 @@
2021
PTF_PORT_MAPPING_MODE = 'use_orig_interface'
2122

2223
TEMPLATES_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "templates")
23-
EXPECT_PFC_WD_DETECT_RE = ".* detected PFC storm .*"
24-
EXPECT_PFC_WD_RESTORE_RE = ".*storm restored.*"
2524
WD_ACTION_MSG_PFX = {"dontcare": "Verify PFCWD detection when queue buffer is not empty "
2625
"and proper function of pfcwd drop action",
2726
"drop": "Verify proper function of pfcwd drop action",
@@ -671,7 +670,7 @@ def storm_detect_path(self, dut, port, action):
671670
reg_exp = loganalyzer.parse_regexp_file(src=ignore_file)
672671
loganalyzer.ignore_regex.extend(reg_exp)
673672
loganalyzer.expect_regex = []
674-
loganalyzer.expect_regex.extend([EXPECT_PFC_WD_DETECT_RE])
673+
loganalyzer.expect_regex.extend([EXPECT_PFC_WD_DETECT_RE + fetch_vendor_specific_diagnosis_re(dut)])
675674
loganalyzer.match_regex = []
676675

677676
if action != "dontcare":
@@ -1067,7 +1066,7 @@ def test_pfcwd_port_toggle(self, request, fake_storm, setup_pfc_test, setup_dut_
10671066
reg_exp = loganalyzer.parse_regexp_file(src=ignore_file)
10681067
loganalyzer.ignore_regex.extend(reg_exp)
10691068
loganalyzer.expect_regex = []
1070-
loganalyzer.expect_regex.extend([EXPECT_PFC_WD_DETECT_RE])
1069+
loganalyzer.expect_regex.extend([EXPECT_PFC_WD_DETECT_RE + fetch_vendor_specific_diagnosis_re(duthost)])
10711070
loganalyzer.match_regex = []
10721071

10731072
port_toggle(self.dut, tbinfo, ports=[port])

tests/pfcwd/test_pfcwd_warm_reboot.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@
1616
from tests.common.utilities import InterruptableThread
1717
from tests.common.utilities import join_all
1818
from tests.ptf_runner import ptf_runner
19+
from .files.pfcwd_helper import EXPECT_PFC_WD_DETECT_RE, EXPECT_PFC_WD_RESTORE_RE
1920

2021
TEMPLATES_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "templates")
21-
EXPECT_PFC_WD_DETECT_RE = ".* detected PFC storm .*"
22-
EXPECT_PFC_WD_RESTORE_RE = ".*storm restored.*"
2322
TESTCASE_INFO = {'no_storm': {'test_sequence': ["detect", "restore", "warm-reboot", "detect", "restore"],
2423
'desc': "Test PFC storm detect/restore before and after warm boot"},
2524
'storm': {'test_sequence': ["detect", "warm-reboot", "detect", "restore"],

0 commit comments

Comments
 (0)