Remove redundant checks of stack status
The main methods create/update/delete in HeatIntegrationTest class already contains _wait_for_stack_status, so we can remove duplicate checks in tests. Also was added paramter enable_cleanup for stack_create method, which allows to disable CleanUp method in tests, where we delete stack manually. Change-Id: I41b546d648656676ec9bc3b38940eac68f9a848d
This commit is contained in:
parent
f50f4ddcfa
commit
1fb557bf05
@ -352,7 +352,8 @@ class HeatIntegrationTest(testscenarios.WithScenarios,
|
||||
|
||||
def stack_create(self, stack_name=None, template=None, files=None,
|
||||
parameters=None, environment=None,
|
||||
expected_status='CREATE_COMPLETE', disable_rollback=True):
|
||||
expected_status='CREATE_COMPLETE', disable_rollback=True,
|
||||
enable_cleanup=True):
|
||||
name = stack_name or self._stack_rand_name()
|
||||
templ = template or self.template
|
||||
templ_files = files or {}
|
||||
@ -366,7 +367,7 @@ class HeatIntegrationTest(testscenarios.WithScenarios,
|
||||
parameters=params,
|
||||
environment=env
|
||||
)
|
||||
if expected_status not in ['ROLLBACK_COMPLETE']:
|
||||
if expected_status not in ['ROLLBACK_COMPLETE'] and enable_cleanup:
|
||||
self.addCleanup(self.client.stacks.delete, name)
|
||||
|
||||
stack = self.client.stacks.get(name)
|
||||
|
@ -183,7 +183,6 @@ class AutoscalingGroupBasicTest(AutoscalingGroupTest):
|
||||
'flavor': self.conf.instance_type}}
|
||||
self.update_stack(stack_identifier, self.template,
|
||||
environment=env2, files=files)
|
||||
self._wait_for_stack_status(stack_identifier, 'UPDATE_COMPLETE')
|
||||
stack = self.client.stacks.get(stack_identifier)
|
||||
self.assert_instance_count(stack, 5)
|
||||
|
||||
@ -374,7 +373,6 @@ class AutoscalingGroupUpdatePolicyTest(AutoscalingGroupTest):
|
||||
# test stack update
|
||||
self.update_stack(stack_identifier, updt_template,
|
||||
environment=env, files=files)
|
||||
self._wait_for_stack_status(stack_identifier, 'UPDATE_COMPLETE')
|
||||
updt_stack = self.client.stacks.get(stack_identifier)
|
||||
|
||||
# test that the launch configuration is replaced
|
||||
|
@ -68,8 +68,6 @@ outputs:
|
||||
self.client = self.orchestration_client
|
||||
|
||||
def test_defaults(self):
|
||||
stack_name = self._stack_rand_name()
|
||||
|
||||
env = {'parameters': {}, 'parameter_defaults': {}}
|
||||
if self.param:
|
||||
env['parameters'] = {'length': self.param}
|
||||
@ -84,22 +82,13 @@ outputs:
|
||||
else:
|
||||
nested_template = self.nested_template
|
||||
|
||||
self.client.stacks.create(
|
||||
stack_name=stack_name,
|
||||
stack_identifier = self.stack_create(
|
||||
template=self.template,
|
||||
files={'nested_random.yaml': nested_template},
|
||||
disable_rollback=True,
|
||||
parameters={},
|
||||
environment=env
|
||||
)
|
||||
self.addCleanup(self.client.stacks.delete, stack_name)
|
||||
|
||||
stack = self.client.stacks.get(stack_name)
|
||||
stack_identifier = '%s/%s' % (stack_name, stack.id)
|
||||
|
||||
self._wait_for_stack_status(stack_identifier, 'CREATE_COMPLETE')
|
||||
|
||||
stack = self.client.stacks.get(stack_name)
|
||||
stack = self.client.stacks.get(stack_identifier)
|
||||
for out in stack.outputs:
|
||||
if out['output_key'] == 'random1':
|
||||
self.assertEqual(self.expect1, len(out['output_value']))
|
||||
|
@ -132,4 +132,3 @@ resources:
|
||||
'scaling_adjustment: 2')
|
||||
|
||||
self.update_stack(stack_identifier, template=new_template)
|
||||
self._wait_for_stack_status(stack_identifier, 'UPDATE_COMPLETE')
|
||||
|
@ -174,7 +174,6 @@ class InstanceGroupBasicTest(InstanceGroupTest):
|
||||
'flavor': self.conf.instance_type}}
|
||||
self.update_stack(stack_identifier, self.template,
|
||||
environment=env2, files=files)
|
||||
self._wait_for_stack_status(stack_identifier, 'UPDATE_COMPLETE')
|
||||
stack = self.client.stacks.get(stack_identifier)
|
||||
self.assert_instance_count(stack, 5)
|
||||
|
||||
@ -345,7 +344,6 @@ class InstanceGroupUpdatePolicyTest(InstanceGroupTest):
|
||||
# test stack update
|
||||
self.update_stack(stack_identifier, updt_template,
|
||||
environment=env, files=files)
|
||||
self._wait_for_stack_status(stack_identifier, 'UPDATE_COMPLETE')
|
||||
updt_stack = self.client.stacks.get(stack_identifier)
|
||||
|
||||
# test that the launch configuration is replaced
|
||||
|
@ -141,17 +141,9 @@ outputs:
|
||||
return len(handler.notifications) == count
|
||||
|
||||
def test_basic_notifications(self):
|
||||
stack_identifier = self._stack_rand_name()
|
||||
# do this manually so we can call _stack_delete() directly.
|
||||
self.client.stacks.create(
|
||||
stack_name=stack_identifier,
|
||||
template=self.basic_template,
|
||||
files={},
|
||||
disable_rollback=True,
|
||||
parameters={},
|
||||
environment={}
|
||||
)
|
||||
self._wait_for_stack_status(stack_identifier, 'CREATE_COMPLETE')
|
||||
# disable cleanup so we can call _stack_delete() directly.
|
||||
stack_identifier = self.stack_create(template=self.basic_template,
|
||||
enable_cleanup=False)
|
||||
self.update_stack(stack_identifier,
|
||||
template=self.update_basic_template)
|
||||
self.stack_suspend(stack_identifier)
|
||||
|
@ -102,17 +102,12 @@ resource_registry:
|
||||
This tests that if you manually delete a nested
|
||||
stack, the parent stack is still deletable.
|
||||
"""
|
||||
name = self._stack_rand_name()
|
||||
# do this manually so we can call _stack_delete() directly.
|
||||
self.client.stacks.create(
|
||||
stack_name=name,
|
||||
# disable cleanup so we can call _stack_delete() directly.
|
||||
stack_identifier = self.stack_create(
|
||||
template=self.template,
|
||||
files={'nested.yaml': self.nested_templ},
|
||||
environment=self.env_templ,
|
||||
disable_rollback=True)
|
||||
stack = self.client.stacks.get(name)
|
||||
stack_identifier = '%s/%s' % (name, stack.id)
|
||||
self._wait_for_stack_status(stack_identifier, 'CREATE_COMPLETE')
|
||||
enable_cleanup=False)
|
||||
|
||||
nested_ident = self.assert_resource_is_a_stack(stack_identifier,
|
||||
'secret1')
|
||||
@ -445,16 +440,11 @@ Outputs:
|
||||
return yaml.load(yaml_templ)
|
||||
|
||||
def test_abandon(self):
|
||||
stack_name = self._stack_rand_name()
|
||||
self.client.stacks.create(
|
||||
stack_name=stack_name,
|
||||
stack_identifier = self.stack_create(
|
||||
template=self.main_template,
|
||||
files={'the.yaml': self.nested_templ},
|
||||
disable_rollback=True,
|
||||
enable_cleanup=False
|
||||
)
|
||||
stack = self.client.stacks.get(stack_name)
|
||||
stack_identifier = '%s/%s' % (stack_name, stack.id)
|
||||
self._wait_for_stack_status(stack_identifier, 'CREATE_COMPLETE')
|
||||
|
||||
info = self.stack_abandon(stack_id=stack_identifier)
|
||||
self.assertEqual(self._yaml_to_json(self.main_template),
|
||||
@ -527,16 +517,10 @@ Outputs:
|
||||
self.client = self.orchestration_client
|
||||
|
||||
def test_check(self):
|
||||
stack_name = self._stack_rand_name()
|
||||
self.client.stacks.create(
|
||||
stack_name=stack_name,
|
||||
stack_identifier = self.stack_create(
|
||||
template=self.main_template,
|
||||
files={'the.yaml': self.nested_templ},
|
||||
disable_rollback=True,
|
||||
files={'the.yaml': self.nested_templ}
|
||||
)
|
||||
stack = self.client.stacks.get(stack_name)
|
||||
stack_identifier = '%s/%s' % (stack_name, stack.id)
|
||||
self._wait_for_stack_status(stack_identifier, 'CREATE_COMPLETE')
|
||||
|
||||
self.client.actions.check(stack_id=stack_identifier)
|
||||
self._wait_for_stack_status(stack_identifier, 'CHECK_COMPLETE')
|
||||
|
@ -47,9 +47,6 @@ class CfnInitIntegrationTest(scenario_base.ScenarioTestsBase):
|
||||
# logs to be compared
|
||||
self._log_console_output(servers=[server])
|
||||
|
||||
# Check stack status
|
||||
self._wait_for_stack_status(sid, 'CREATE_COMPLETE')
|
||||
|
||||
stack = self.client.stacks.get(sid)
|
||||
|
||||
# This is an assert of great significance, as it means the following
|
||||
|
@ -84,9 +84,6 @@ class SoftwareConfigIntegrationTest(scenario_base.ScenarioTestsBase):
|
||||
# logs to be compared
|
||||
self._log_console_output(servers=[server])
|
||||
|
||||
# Check that stack was fully created
|
||||
self._wait_for_stack_status(sid, 'CREATE_COMPLETE')
|
||||
|
||||
complete_server_metadata = self.client.resources.metadata(
|
||||
sid, 'server')
|
||||
|
||||
|
@ -61,8 +61,7 @@ class VolumeBackupRestoreIntegrationTest(scenario_base.ScenarioTestsBase):
|
||||
|
||||
# Delete the stack and ensure a backup is created for volume_id
|
||||
# but the volume itself is gone
|
||||
self.client.stacks.delete(stack_id)
|
||||
self._wait_for_stack_status(stack_id, 'DELETE_COMPLETE')
|
||||
self._stack_delete(stack_id)
|
||||
self.assertRaises(cinder_exceptions.NotFound,
|
||||
self.volume_client.volumes.get,
|
||||
volume_id)
|
||||
@ -97,8 +96,7 @@ class VolumeBackupRestoreIntegrationTest(scenario_base.ScenarioTestsBase):
|
||||
testfile_data)
|
||||
|
||||
# Delete the stack and ensure the volume is gone
|
||||
self.client.stacks.delete(stack_identifier2)
|
||||
self._wait_for_stack_status(stack_identifier2, 'DELETE_COMPLETE')
|
||||
self._stack_delete(stack_identifier2)
|
||||
self.assertRaises(cinder_exceptions.NotFound,
|
||||
self.volume_client.volumes.get,
|
||||
volume_id2)
|
||||
|
Loading…
Reference in New Issue
Block a user