Merge "ResourceGroup fix issue with batch create and zero count"

This commit is contained in:
Jenkins 2017-02-02 09:30:12 +00:00 committed by Gerrit Code Review
commit 067fcea0c3
2 changed files with 14 additions and 1 deletions

View File

@ -358,7 +358,8 @@ class ResourceGroup(stack_resource.StackResource):
max_batch_size = batch_create[self.MAX_BATCH_SIZE]
pause_sec = batch_create[self.PAUSE_TIME]
checkers = self._replace(0, max_batch_size, pause_sec)
checkers[0].start()
if checkers:
checkers[0].start()
return checkers
else:
names = self._resource_names()

View File

@ -531,6 +531,18 @@ class ResourceGroupTest(common.HeatTestCase):
checkers = resgrp.handle_create()
self.assertEqual(4, len(checkers))
def test_handle_create_with_batching_zero_count(self):
stack = utils.parse_stack(tmpl_with_default_updt_policy())
defn = stack.t.resource_definitions(stack)['group1']
props = stack.t.t['resources']['group1']['properties'].copy()
props['count'] = 0
update_policy = {'batch_create': {'max_batch_size': 1}}
snip = defn.freeze(properties=props, update_policy=update_policy)
resgrp = resource_group.ResourceGroup('test', snip, stack)
self.patchobject(scheduler.TaskRunner, 'start')
checkers = resgrp.handle_create()
self.assertEqual(0, len(checkers))
def test_run_to_completion(self):
stack = utils.parse_stack(template2)
snip = stack.t.resource_definitions(stack)['group1']