Skip to content

Commit

Permalink
Stablize the test case (#1679)
Browse files Browse the repository at this point in the history
- 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 <stephens@nvidia.com>
  • Loading branch information
stephenxs authored and daall committed Apr 1, 2021
1 parent 25f4944 commit 6bf4c63
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions tests/test_buffer_dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6bf4c63

Please sign in to comment.