Merge "Use helper functions stack_suspend and stack_resume"
This commit is contained in:
commit
d0ff1a80d1
@ -191,6 +191,15 @@ class HeatIntegrationTest(testscenarios.WithScenarios,
|
|||||||
return call_until_true(
|
return call_until_true(
|
||||||
self.conf.build_timeout, 1, ping)
|
self.conf.build_timeout, 1, ping)
|
||||||
|
|
||||||
|
def _wait_for_all_resource_status(self, stack_identifier,
|
||||||
|
status, failure_pattern='^.*_FAILED$',
|
||||||
|
success_on_not_found=False):
|
||||||
|
for res in self.client.resources.list(stack_identifier):
|
||||||
|
self._wait_for_resource_status(
|
||||||
|
stack_identifier, res.resource_name,
|
||||||
|
status, failure_pattern=failure_pattern,
|
||||||
|
success_on_not_found=success_on_not_found)
|
||||||
|
|
||||||
def _wait_for_resource_status(self, stack_identifier, resource_name,
|
def _wait_for_resource_status(self, stack_identifier, resource_name,
|
||||||
status, failure_pattern='^.*_FAILED$',
|
status, failure_pattern='^.*_FAILED$',
|
||||||
success_on_not_found=False):
|
success_on_not_found=False):
|
||||||
@ -406,11 +415,19 @@ class HeatIntegrationTest(testscenarios.WithScenarios,
|
|||||||
def stack_suspend(self, stack_identifier):
|
def stack_suspend(self, stack_identifier):
|
||||||
stack_name = stack_identifier.split('/')[0]
|
stack_name = stack_identifier.split('/')[0]
|
||||||
self.client.actions.suspend(stack_name)
|
self.client.actions.suspend(stack_name)
|
||||||
|
|
||||||
|
# improve debugging by first checking the resource's state.
|
||||||
|
self._wait_for_all_resource_status(stack_identifier,
|
||||||
|
'SUSPEND_COMPLETE')
|
||||||
self._wait_for_stack_status(stack_identifier, 'SUSPEND_COMPLETE')
|
self._wait_for_stack_status(stack_identifier, 'SUSPEND_COMPLETE')
|
||||||
|
|
||||||
def stack_resume(self, stack_identifier):
|
def stack_resume(self, stack_identifier):
|
||||||
stack_name = stack_identifier.split('/')[0]
|
stack_name = stack_identifier.split('/')[0]
|
||||||
self.client.actions.resume(stack_name)
|
self.client.actions.resume(stack_name)
|
||||||
|
|
||||||
|
# improve debugging by first checking the resource's state.
|
||||||
|
self._wait_for_all_resource_status(stack_identifier,
|
||||||
|
'RESUME_COMPLETE')
|
||||||
self._wait_for_stack_status(stack_identifier, 'RESUME_COMPLETE')
|
self._wait_for_stack_status(stack_identifier, 'RESUME_COMPLETE')
|
||||||
|
|
||||||
def wait_for_event_with_reason(self, stack_identifier, reason,
|
def wait_for_event_with_reason(self, stack_identifier, reason,
|
||||||
|
@ -318,21 +318,11 @@ class AutoscalingGroupBasicTest(AutoscalingGroupTest):
|
|||||||
nested_ident = self.assert_resource_is_a_stack(stack_identifier,
|
nested_ident = self.assert_resource_is_a_stack(stack_identifier,
|
||||||
'JobServerGroup')
|
'JobServerGroup')
|
||||||
|
|
||||||
self.client.actions.suspend(stack_id=stack_identifier)
|
self.stack_suspend(stack_identifier)
|
||||||
self._wait_for_resource_status(
|
self._wait_for_all_resource_status(nested_ident, 'SUSPEND_COMPLETE')
|
||||||
stack_identifier, 'JobServerGroup', 'SUSPEND_COMPLETE')
|
|
||||||
for res in self.client.resources.list(nested_ident):
|
|
||||||
self._wait_for_resource_status(nested_ident,
|
|
||||||
res.resource_name,
|
|
||||||
'SUSPEND_COMPLETE')
|
|
||||||
|
|
||||||
self.client.actions.resume(stack_id=stack_identifier)
|
self.stack_resume(stack_identifier)
|
||||||
self._wait_for_resource_status(
|
self._wait_for_all_resource_status(nested_ident, 'RESUME_COMPLETE')
|
||||||
stack_identifier, 'JobServerGroup', 'RESUME_COMPLETE')
|
|
||||||
for res in self.client.resources.list(nested_ident):
|
|
||||||
self._wait_for_resource_status(nested_ident,
|
|
||||||
res.resource_name,
|
|
||||||
'RESUME_COMPLETE')
|
|
||||||
|
|
||||||
|
|
||||||
class AutoscalingGroupUpdatePolicyTest(AutoscalingGroupTest):
|
class AutoscalingGroupUpdatePolicyTest(AutoscalingGroupTest):
|
||||||
|
@ -203,11 +203,5 @@ Outputs:
|
|||||||
url = self.publish_template(self.nested_name, self.nested_template)
|
url = self.publish_template(self.nested_name, self.nested_template)
|
||||||
self.template = self.test_template.replace('the.yaml', url)
|
self.template = self.test_template.replace('the.yaml', url)
|
||||||
stack_identifier = self.stack_create(template=self.template)
|
stack_identifier = self.stack_create(template=self.template)
|
||||||
|
self.stack_suspend(stack_identifier)
|
||||||
self.client.actions.suspend(stack_id=stack_identifier)
|
self.stack_resume(stack_identifier)
|
||||||
self._wait_for_resource_status(
|
|
||||||
stack_identifier, 'the_nested', 'SUSPEND_COMPLETE')
|
|
||||||
|
|
||||||
self.client.actions.resume(stack_id=stack_identifier)
|
|
||||||
self._wait_for_resource_status(
|
|
||||||
stack_identifier, 'the_nested', 'RESUME_COMPLETE')
|
|
||||||
|
@ -140,17 +140,5 @@ outputs:
|
|||||||
def test_stack_suspend_resume(self):
|
def test_stack_suspend_resume(self):
|
||||||
files = {'remote_stack.yaml': self.remote_template}
|
files = {'remote_stack.yaml': self.remote_template}
|
||||||
stack_id = self.stack_create(files=files)
|
stack_id = self.stack_create(files=files)
|
||||||
rsrc = self.client.resources.get(stack_id, 'my_stack')
|
self.stack_suspend(stack_id)
|
||||||
remote_id = rsrc.physical_resource_id
|
self.stack_resume(stack_id)
|
||||||
|
|
||||||
# suspend stack
|
|
||||||
self.client.actions.suspend(stack_id)
|
|
||||||
self._wait_for_stack_status(stack_id, 'SUSPEND_COMPLETE')
|
|
||||||
rsrc = self.client.stacks.get(remote_id)
|
|
||||||
self.assertEqual('SUSPEND_COMPLETE', rsrc.stack_status)
|
|
||||||
|
|
||||||
# resume stack
|
|
||||||
self.client.actions.resume(stack_id)
|
|
||||||
self._wait_for_stack_status(stack_id, 'RESUME_COMPLETE')
|
|
||||||
rsrc = self.client.stacks.get(remote_id)
|
|
||||||
self.assertEqual('RESUME_COMPLETE', rsrc.stack_status)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user