Skip to content

Commit

Permalink
Loose PFCWD timer accuracy test on Mellanox testbed with Non-Onyx or …
Browse files Browse the repository at this point in the history
…Non-Mellanox leaf fanout (#14562) (#14571)

Co-authored-by: bingwang-ms <66248323+bingwang-ms@users.noreply.github.com>
  • Loading branch information
mssonicbld and bingwang-ms authored Sep 13, 2024
1 parent c8e4f47 commit a59c80e
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions tests/pfcwd/test_pfcwd_timer_accuracy.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
pytest.mark.topology('any')
]

ITERATION_NUM = 20

logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -223,32 +225,46 @@ def verify_pfcwd_timers(self):
logger.info("Verify that real detection time is not greater than configured")
logger.info("all detect time {}".format(self.all_detect_time))
logger.info("all restore time {}".format(self.all_restore_time))

check_point = ITERATION_NUM // 2 - 1
# Loose the check if two conditions are met
# 1. Device is Mellanox plaform
# 2. Leaf-fanout is Non-Onyx or non-Mellanox SONiC devices
# It's because the pfc_gen.py running on leaf-fanout can't guarantee the PFCWD is triggered consistently
if self.dut.facts['asic_type'] == "mellanox":
for fanouthost in list(self.fanout.values()):
if fanouthost.get_fanout_os() != "onyx" or \
fanouthost.get_fanout_os() == "sonic" and fanouthost.facts['asic_type'] != "mellanox":
logger.info("Loose the check for non-Onyx or non-Mellanox leaf-fanout testbed")
check_point = ITERATION_NUM // 3 - 1
break

config_detect_time = self.timers['pfc_wd_detect_time'] + self.timers['pfc_wd_poll_time']
err_msg = ("Real detection time is greater than configured: Real detect time: {} "
"Expected: {} (wd_detect_time + wd_poll_time)".format(self.all_detect_time[9],
"Expected: {} (wd_detect_time + wd_poll_time)".format(self.all_detect_time[check_point],
config_detect_time))
pytest_assert(self.all_detect_time[9] < config_detect_time, err_msg)
pytest_assert(self.all_detect_time[check_point] < config_detect_time, err_msg)

if self.timers['pfc_wd_poll_time'] < self.timers['pfc_wd_detect_time']:
logger.info("Verify that real detection time is not less than configured")
err_msg = ("Real detection time is less than configured: Real detect time: {} "
"Expected: {} (wd_detect_time)".format(self.all_detect_time[9],
"Expected: {} (wd_detect_time)".format(self.all_detect_time[check_point],
self.timers['pfc_wd_detect_time']))
pytest_assert(self.all_detect_time[9] > self.timers['pfc_wd_detect_time'], err_msg)
pytest_assert(self.all_detect_time[check_point] > self.timers['pfc_wd_detect_time'], err_msg)

if self.timers['pfc_wd_poll_time'] < self.timers['pfc_wd_restore_time']:
logger.info("Verify that real restoration time is not less than configured")
err_msg = ("Real restoration time is less than configured: Real restore time: {} "
"Expected: {} (wd_restore_time)".format(self.all_restore_time[9],
"Expected: {} (wd_restore_time)".format(self.all_restore_time[check_point],
self.timers['pfc_wd_restore_time']))
pytest_assert(self.all_restore_time[9] > self.timers['pfc_wd_restore_time'], err_msg)
pytest_assert(self.all_restore_time[check_point] > self.timers['pfc_wd_restore_time'], err_msg)

logger.info("Verify that real restoration time is less than configured")
config_restore_time = self.timers['pfc_wd_restore_time'] + self.timers['pfc_wd_poll_time']
err_msg = ("Real restoration time is greater than configured: Real restore time: {} "
"Expected: {} (wd_restore_time + wd_poll_time)".format(self.all_restore_time[9],
"Expected: {} (wd_restore_time + wd_poll_time)".format(self.all_restore_time[check_point],
config_restore_time))
pytest_assert(self.all_restore_time[9] < config_restore_time, err_msg)
pytest_assert(self.all_restore_time[check_point] < config_restore_time, err_msg)

def verify_pfcwd_timers_t2(self):
"""
Expand Down Expand Up @@ -291,7 +307,7 @@ def retrieve_timestamp(self, pattern):
return int(timestamp_ms)

def test_pfcwd_timer_accuracy(self, duthosts, ptfhost, enum_rand_one_per_hwsku_frontend_hostname,
pfcwd_timer_setup_restore):
pfcwd_timer_setup_restore, fanouthosts):
"""
Tests PFCwd timer accuracy
Expand All @@ -305,6 +321,7 @@ def test_pfcwd_timer_accuracy(self, duthosts, ptfhost, enum_rand_one_per_hwsku_f
self.timers = setup_info['timers']
self.dut = duthost
self.ptf = ptfhost
self.fanout = fanouthosts
self.all_detect_time = list()
self.all_restore_time = list()
self.all_dut_detect_restore_time = list()
Expand All @@ -315,7 +332,7 @@ def test_pfcwd_timer_accuracy(self, duthosts, ptfhost, enum_rand_one_per_hwsku_f
self.run_test(setup_info)
self.verify_pfcwd_timers_t2()
else:
for i in range(1, 20):
for i in range(1, ITERATION_NUM):
logger.info("--- Pfcwd Timer Test iteration #{}".format(i))

cmd = "show pfc counters"
Expand Down

0 comments on commit a59c80e

Please sign in to comment.