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
diff --git a/functional/test_autoscaling.py b/functional/test_autoscaling.py
index 489ae63..301981f 100644
--- a/functional/test_autoscaling.py
+++ b/functional/test_autoscaling.py
@@ -183,7 +183,6 @@
'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 @@
# 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
diff --git a/functional/test_default_parameters.py b/functional/test_default_parameters.py
index 138a13e..00000fd 100644
--- a/functional/test_default_parameters.py
+++ b/functional/test_default_parameters.py
@@ -68,8 +68,6 @@
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 @@
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']))
diff --git a/functional/test_heat_autoscaling.py b/functional/test_heat_autoscaling.py
index 0e6e0cb..dbe3e8f 100644
--- a/functional/test_heat_autoscaling.py
+++ b/functional/test_heat_autoscaling.py
@@ -132,4 +132,3 @@
'scaling_adjustment: 2')
self.update_stack(stack_identifier, template=new_template)
- self._wait_for_stack_status(stack_identifier, 'UPDATE_COMPLETE')
diff --git a/functional/test_instance_group.py b/functional/test_instance_group.py
index 5c88bed..1455d0b 100644
--- a/functional/test_instance_group.py
+++ b/functional/test_instance_group.py
@@ -174,7 +174,6 @@
'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 @@
# 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
diff --git a/functional/test_notifications.py b/functional/test_notifications.py
index a9b6cf1..a4c419c 100644
--- a/functional/test_notifications.py
+++ b/functional/test_notifications.py
@@ -141,17 +141,9 @@
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)
diff --git a/functional/test_template_resource.py b/functional/test_template_resource.py
index 392bddd..356fc2a 100644
--- a/functional/test_template_resource.py
+++ b/functional/test_template_resource.py
@@ -102,17 +102,12 @@
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 @@
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 @@
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')