Skip to content

Commit

Permalink
Fix the issue where the test case randomly fails due to not waiting a…
Browse files Browse the repository at this point in the history
…fter updating the config DB. (sonic-net#3323)
  • Loading branch information
liuh-80 authored Oct 14, 2024
1 parent 5cf6220 commit 7ac0d4f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions tests/dvslib/dvs_hash.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Utilities for interacting with HASH objects when writing VS tests."""
from typing import Dict, List
import time


class DVSHash:
Expand All @@ -21,6 +22,7 @@ def update_switch_hash(
) -> None:
"""Update switch hash global in Config DB."""
self.config_db.update_entry(self.CDB_SWITCH_HASH, self.KEY_SWITCH_HASH_GLOBAL, qualifiers)
time.sleep(1)

def get_hash_ids(
self,
Expand Down
2 changes: 2 additions & 0 deletions tests/test_dash_acl.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,12 @@ def __setitem__(self, key: str, pairs: Union[dict, list, tuple]):
pairs_str.append((to_string(k), to_string(v)))
self.table.set(key, pairs_str)
self.keys.add(key)
time.sleep(1)

def __delitem__(self, key: str):
self.table.delete(str(key))
self.keys.discard(key)
time.sleep(1)

def get_keys(self):
return self.keys
Expand Down
2 changes: 2 additions & 0 deletions tests/test_dash_vnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ def __setitem__(self, key: str, pairs: typing.Union[dict, list, tuple]):
for k, v in pairs:
pairs_str.append((to_string(k), to_string(v)))
self.table.set(key, pairs_str)
time.sleep(1)

def __delitem__(self, key: str):
self.table.delete(str(key))
time.sleep(1)


class Table(object):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_ipv6_link_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ def test_NeighborAddRemoveIpv6LinkLocal(self, dvs, testlog):
time.sleep(2)

# Neigh entries should contain Ipv6-link-local neighbors, should be 4
neigh_entries = self.pdb.get_keys("NEIGH_TABLE")
assert (len(neigh_entries) == 4)
self.pdb.wait_for_n_keys("NEIGH_TABLE", 4)

found_entry = False
neigh_entries = self.pdb.get_keys("NEIGH_TABLE")
for key in neigh_entries:
if (key.find("Ethernet4:2001::2") or key.find("Ethernet0:2000::2")):
found_entry = True
Expand Down

0 comments on commit 7ac0d4f

Please sign in to comment.