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. (#3305)

* Fix the issue where the test case randomly fails due to not waiting after updating the config DB.
Why I did it
Some test case randomly fails due to not waiting after updating the config DB.
  • Loading branch information
liuh-80 authored Oct 8, 2024
1 parent c553d8d commit 09fc6b5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions tests/dash/dash_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from dvslib.dvs_common import wait_for_result
import typing
import pytest
import time

from dash_api.appliance_pb2 import *
from dash_api.vnet_pb2 import *
Expand Down Expand Up @@ -58,9 +59,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.set(key, pairs_str)
time.sleep(1)

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


class Table(swsscommon.Table):
Expand Down
2 changes: 2 additions & 0 deletions tests/dash/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/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
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 09fc6b5

Please sign in to comment.