mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Wait longer for ping reaction
Wait longer for the ping reaction in case there are multiple events on the bus and/or high load on the system running tests
This commit is contained in:
parent
8c10f5ffa1
commit
304229240e
1 changed files with 8 additions and 9 deletions
|
@ -706,15 +706,14 @@ class SaltMinionEventAssertsMixin(object):
|
|||
raise salt.exceptions.NotImplemented('assertMinionEventFired() not implemented')
|
||||
|
||||
def assertMinionEventReceived(self, desired_event, timeout=5, sleep_time=0.5):
|
||||
start = time.time()
|
||||
while True:
|
||||
try:
|
||||
event = self.q.get(False)
|
||||
except Empty:
|
||||
time.sleep(sleep_time)
|
||||
if time.time() - start >= timeout:
|
||||
break
|
||||
continue
|
||||
queue_wait = timeout / sleep_time
|
||||
while self.q.empty():
|
||||
time.sleep(sleep_time) # Wait for events to be pushed into the queue
|
||||
queue_wait -= 1
|
||||
if queue_wait <= 0:
|
||||
raise AssertionError('Queue wait timer expired')
|
||||
while not self.q.empty(): # This is not thread-safe and may be inaccurate
|
||||
event = self.q.get()
|
||||
if isinstance(event, dict):
|
||||
event.pop('_stamp')
|
||||
if desired_event == event:
|
||||
|
|
Loading…
Add table
Reference in a new issue