mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Do not limit event assert to first event
This commit is contained in:
parent
304229240e
commit
6c8c4182dd
1 changed files with 7 additions and 9 deletions
|
@ -706,20 +706,18 @@ class SaltMinionEventAssertsMixin(object):
|
|||
raise salt.exceptions.NotImplemented('assertMinionEventFired() not implemented')
|
||||
|
||||
def assertMinionEventReceived(self, desired_event, timeout=5, sleep_time=0.5):
|
||||
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()
|
||||
start = time.time()
|
||||
while True:
|
||||
try:
|
||||
event = self.q.get(False)
|
||||
except Emtpy:
|
||||
time.sleep(sleep_time)
|
||||
if isinstance(event, dict):
|
||||
event.pop('_stamp')
|
||||
if desired_event == event:
|
||||
self.fetch_proc.terminate()
|
||||
return True
|
||||
if time.time() - start >= timeout:
|
||||
if start - time.time() >= timeout:
|
||||
break
|
||||
self.fetch_proc.terminate()
|
||||
raise AssertionError('Event {0} was not received by minion'.format(desired_event))
|
||||
|
|
Loading…
Add table
Reference in a new issue