Skip to content

Commit 6bf4c63

Browse files
stephenxsdaall
authored andcommitted
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 <[email protected]>
1 parent 25f4944 commit 6bf4c63

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

tests/test_buffer_dynamic.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,17 @@ def setup_asic_db(self, dvs):
102102
self.ingress_lossless_pool_oid = key
103103

104104
def check_new_profile_in_asic_db(self, dvs, profile):
105-
diff = set(self.asic_db.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_BUFFER_PROFILE")) - self.initProfileSet
106-
if len(diff) == 1:
107-
self.newProfileInAsicDb = diff.pop()
108-
assert self.newProfileInAsicDb, "Can't get SAI OID for newly created profile {}".format(profile)
105+
retry_count = 0
106+
self.newProfileInAsicDb = None
107+
while retry_count < 5:
108+
retry_count += 1
109+
diff = set(self.asic_db.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_BUFFER_PROFILE")) - self.initProfileSet
110+
if len(diff) == 1:
111+
self.newProfileInAsicDb = diff.pop()
112+
break
113+
else:
114+
time.sleep(1)
115+
assert self.newProfileInAsicDb, "Can't get SAI OID for newly created profile {} after retry {} times".format(profile, retry_count)
109116

110117
# in case diff is empty, we just treat the newProfileInAsicDb cached the latest one
111118
fvs = self.app_db.get_entry("BUFFER_PROFILE_TABLE", profile)

0 commit comments

Comments
 (0)