diff --git a/heat_integrationtests/common/test.py b/heat_integrationtests/common/test.py index 6c70d830ac..38748aac16 100644 --- a/heat_integrationtests/common/test.py +++ b/heat_integrationtests/common/test.py @@ -321,7 +321,7 @@ class HeatIntegrationTest(testscenarios.WithScenarios, success_on_not_found=True) def update_stack(self, stack_identifier, template, environment=None, - files=None, parameters=None, + files=None, parameters=None, tags=None, expected_status='UPDATE_COMPLETE', disable_rollback=True): env = environment or {} @@ -342,7 +342,8 @@ class HeatIntegrationTest(testscenarios.WithScenarios, files=env_files, disable_rollback=disable_rollback, parameters=parameters, - environment=env + environment=env, + tags=tags ) except heat_exceptions.HTTPConflict as ex: # FIXME(sirushtim): Wait a little for the stack lock to be @@ -405,9 +406,9 @@ class HeatIntegrationTest(testscenarios.WithScenarios, return dict((r.resource_name, r.resource_type) for r in resources) def stack_create(self, stack_name=None, template=None, files=None, - parameters=None, environment=None, - expected_status='CREATE_COMPLETE', disable_rollback=True, - enable_cleanup=True): + parameters=None, environment=None, tags=None, + 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 {} @@ -419,7 +420,8 @@ class HeatIntegrationTest(testscenarios.WithScenarios, files=templ_files, disable_rollback=disable_rollback, parameters=params, - environment=env + environment=env, + tags=tags ) if expected_status not in ['ROLLBACK_COMPLETE'] and enable_cleanup: self.addCleanup(self.client.stacks.delete, name) diff --git a/heat_integrationtests/functional/test_stack_tags.py b/heat_integrationtests/functional/test_stack_tags.py new file mode 100644 index 0000000000..a183d25006 --- /dev/null +++ b/heat_integrationtests/functional/test_stack_tags.py @@ -0,0 +1,69 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from heat_integrationtests.common import test + + +class StackTagTest(test.HeatIntegrationTest): + + template = ''' +heat_template_version: 2014-10-16 +description: + foo +''' + + def setUp(self): + super(StackTagTest, self).setUp() + self.client = self.orchestration_client + + def test_stack_tag(self): + # Stack create with stack tags + tags = ['foo', 'bar'] + stack_identifier = self.stack_create( + template=self.template, + tags=tags + ) + + # Ensure property tag is populated and matches given tags + stack = self.client.stacks.get(stack_identifier) + self.assertEqual(tags, stack.tags) + + # Update tags + updated_tags = ['tag1', 'tag2'] + self.update_stack( + stack_identifier, + template=self.template, + tags=updated_tags) + + # Ensure property tag is populated and matches updated tags + updated_stack = self.client.stacks.get(stack_identifier) + self.assertEqual(updated_tags, updated_stack.tags) + + # Delete tags + self.update_stack( + stack_identifier, + template=self.template + ) + + # Ensure property tag is not populated + empty_tags_stack = self.client.stacks.get(stack_identifier) + self.assertIsNone(empty_tags_stack.tags) + + def test_hidden_stack(self): + # Stack create with hidden stack tag + tags = ['foo', 'hidden'] + self.stack_create( + template=self.template, + tags=tags) + # Ensure stack does not exist when we do a stack list + for stack in self.client.stacks.list(): + self.assertNotIn('hidden', stack.tags, "Hidden stack can be seen") diff --git a/heat_integrationtests/pre_test_hook.sh b/heat_integrationtests/pre_test_hook.sh index fa4db09d22..3a9b6fb48b 100755 --- a/heat_integrationtests/pre_test_hook.sh +++ b/heat_integrationtests/pre_test_hook.sh @@ -21,3 +21,4 @@ echo -e '[[post-config|$HEAT_CONF]]\n[DEFAULT]\n' >> $localconf echo -e 'notification_driver=messagingv2\n' >> $localconf echo -e 'num_engine_workers=2\n' >> $localconf echo -e 'plugin_dirs=$HEAT_DIR/heat_integrationtests/common/test_resources\n' >> $localconf +echo -e 'hidden_stack_tags=hidden\n' >> $localconf