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:
Daniel A. Wozniak 2019-04-13 22:43:10 +00:00 committed by Pedro Algarvio
parent 8c10f5ffa1
commit 304229240e
No known key found for this signature in database
GPG key ID: BB36BF6584A298FF

View file

@ -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: