Skip to content

Commit 8a9ffe5

Browse files
committed
Stabilize the copp test case
The new check point in the test_remove_trap was added by the community recently, but it failed on the SN2700 A0 from time to time, check few more time to make sure the test stable.
1 parent d61736c commit 8a9ffe5

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

tests/copp/copp_utils.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,16 @@ def is_trap_installed(duthost, trap_id):
539539

540540
return output[trap_id]["hw_status"] == "installed"
541541

542+
def is_trap_uninstalled(duthost, trap_id):
543+
"""
544+
Checks if a specific trap is uninstalled by parsing the output of `show copp configuration`.
545+
Args:
546+
dut (SonicHost): The target device
547+
trap_id: The trap ID to check.
548+
Returns:
549+
bool: True if the trap is uninstalled, False otherwise.
550+
"""
551+
return not is_trap_installed(duthost, trap_id)
542552

543553
def get_trap_hw_status(duthost):
544554
"""

tests/copp/test_copp.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,8 @@ def test_remove_trap(self, duthosts, enum_rand_one_per_hwsku_frontend_hostname,
240240
copp_utils.disable_feature_entry(duthost, self.feature_name)
241241

242242
logging.info("Verify {} trap is uninstalled through CLI".format(self.trap_id))
243-
pytest_assert(not copp_utils.is_trap_installed(duthost, self.trap_id),
243+
pytest_assert(wait_until(20, 2, 0, copp_utils.is_trap_uninstalled, duthost, self.trap_id),
244244
"Trap {} is not uninstalled".format(self.trap_id))
245-
246245
logger.info("Verify {} trap status is uninstalled by sending traffic".format(self.trap_id))
247246
pytest_assert(
248247
wait_until(100, 20, 0, _copp_runner, duthost, ptfhost, self.trap_id.upper(),

0 commit comments

Comments
 (0)