Skip to content

Commit 9753ca9

Browse files
nhe-NVgshemesh2
authored andcommitted
Stabilize the copp test case (sonic-net#20595)
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. Signed-off-by: Guy Shemesh <[email protected]>
1 parent cbf0db8 commit 9753ca9

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

tests/copp/copp_utils.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,18 @@ def is_trap_installed(duthost, trap_id):
540540
return output[trap_id]["hw_status"] == "installed"
541541

542542

543+
def is_trap_uninstalled(duthost, trap_id):
544+
"""
545+
Checks if a specific trap is uninstalled by parsing the output of `show copp configuration`.
546+
Args:
547+
dut (SonicHost): The target device
548+
trap_id: The trap ID to check.
549+
Returns:
550+
bool: True if the trap is uninstalled, False otherwise.
551+
"""
552+
return not is_trap_installed(duthost, trap_id)
553+
554+
543555
def get_trap_hw_status(duthost):
544556
"""
545557
Retrieves the hw_status for traps from the STATE_DB.

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(30, 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)