From 6bf4c63c8d5b93f78b62e549ba27bd4e148ddfb4 Mon Sep 17 00:00:00 2001 From: Stephen Sun <5379172+stephenxs@users.noreply.github.com> Date: Mon, 29 Mar 2021 18:27:09 +0800 Subject: [PATCH] Stablize the test case (#1679) - What I did Stabilize the vs test. - Why I did it Stabilize the vs test. - How I verified it Run the vs test. - Details if related One logic in the vs test is to check consistency between APPL_DB and ASIC_DB for buffer profiles. However, the mapping between are stored in the orchagent and can't be accessed from outside. The way we fetch that mapping is: Get the SAI OID of all the buffer profiles in ASIC_DB at the beginning of the test, and store it to set P1 Get the SAI OID of all the buffer profiles in ASIC_DB after a new buffer profile has been created, and stored it to P2 The newly created buffer profile in ASIC_DB should be P2 - P1. However, sometimes there can be more than one OIDs in P2 - P1. This is because the old profile hasn't been removed from the ASIC, which typically caused by timing issues, which fails the test. To make the test case stable, we will retry for 5 seconds to make sure the old profile is removed and the OID of the new profile can be fetched. Signed-off-by: Stephen Sun --- tests/test_buffer_dynamic.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/test_buffer_dynamic.py b/tests/test_buffer_dynamic.py index 8733657abf..61e6cbd612 100644 --- a/tests/test_buffer_dynamic.py +++ b/tests/test_buffer_dynamic.py @@ -102,10 +102,17 @@ def setup_asic_db(self, dvs): self.ingress_lossless_pool_oid = key def check_new_profile_in_asic_db(self, dvs, profile): - diff = set(self.asic_db.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_BUFFER_PROFILE")) - self.initProfileSet - if len(diff) == 1: - self.newProfileInAsicDb = diff.pop() - assert self.newProfileInAsicDb, "Can't get SAI OID for newly created profile {}".format(profile) + retry_count = 0 + self.newProfileInAsicDb = None + while retry_count < 5: + retry_count += 1 + diff = set(self.asic_db.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_BUFFER_PROFILE")) - self.initProfileSet + if len(diff) == 1: + self.newProfileInAsicDb = diff.pop() + break + else: + time.sleep(1) + assert self.newProfileInAsicDb, "Can't get SAI OID for newly created profile {} after retry {} times".format(profile, retry_count) # in case diff is empty, we just treat the newProfileInAsicDb cached the latest one fvs = self.app_db.get_entry("BUFFER_PROFILE_TABLE", profile)