Merge "Fix race in ZaqarEventSinkTest.test_events"

This commit is contained in:
Jenkins 2017-08-13 18:46:56 +00:00 committed by Gerrit Code Review
commit d59a550f62

View File

@ -14,6 +14,7 @@ import uuid
from zaqarclient.queues.v1 import client as zaqarclient from zaqarclient.queues.v1 import client as zaqarclient
from heat_integrationtests.common import test
from heat_integrationtests.functional import functional_base from heat_integrationtests.functional import functional_base
@ -54,17 +55,25 @@ resources:
zaqar = zaqarclient.Client(conf=conf, version=1.1) zaqar = zaqarclient.Client(conf=conf, version=1.1)
queue = zaqar.queue(queue_id) queue = zaqar.queue(queue_id)
def validate_messages():
messages = list(queue.messages()) messages = list(queue.messages())
self.assertEqual(4, len(messages)) if len(messages) < 4:
return False
types = [m.body['type'] for m in messages] types = [m.body['type'] for m in messages]
self.assertEqual(['os.heat.event'] * 4, types) self.assertEqual(['os.heat.event'] * 4, types)
resources = set([m.body['payload']['resource_name'] for m in messages]) resources = set([m.body['payload'][
'resource_name'] for m in messages])
self.assertEqual(set([stack_name, 'test_resource']), resources) self.assertEqual(set([stack_name, 'test_resource']), resources)
stack_ids = [m.body['payload']['stack_id'] for m in messages] stack_ids = [m.body['payload']['stack_id'] for m in messages]
self.assertEqual([stack_id] * 4, stack_ids) self.assertEqual([stack_id] * 4, stack_ids)
statuses = [m.body['payload']['resource_status'] for m in messages] statuses = [m.body['payload']['resource_status'] for m in messages]
statuses.sort() statuses.sort()
self.assertEqual( self.assertEqual(['COMPLETE', 'COMPLETE',
['COMPLETE', 'COMPLETE', 'IN_PROGRESS', 'IN_PROGRESS'], statuses) 'IN_PROGRESS', 'IN_PROGRESS'], statuses)
actions = [m.body['payload']['resource_action'] for m in messages] actions = [m.body['payload']['resource_action'] for m in messages]
self.assertEqual(['CREATE'] * 4, actions) self.assertEqual(['CREATE'] * 4, actions)
return True
self.assertTrue(test.call_until_true(20, 0, validate_messages))