From 4b3b4ce14be27c13cccd379192991e2bf200a89b Mon Sep 17 00:00:00 2001 From: Angus Salkeld Date: Fri, 24 Jul 2015 15:47:38 +1000 Subject: [PATCH] Scan for output errors in functional tests In _stack_output() look for unexpected "output_error" messages. Fix a missing output in the template resource tests. Change-Id: I71d5d7e5800d7503d9e6015f637fe7fef5d867fe --- heat_integrationtests/common/test.py | 14 +++++++++++--- .../functional/test_resource_group.py | 8 ++++---- .../functional/test_template_resource.py | 3 +++ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/heat_integrationtests/common/test.py b/heat_integrationtests/common/test.py index acfe1ad742..584af6de38 100644 --- a/heat_integrationtests/common/test.py +++ b/heat_integrationtests/common/test.py @@ -175,10 +175,18 @@ class HeatIntegrationTest(testscenarios.WithScenarios, return net @staticmethod - def _stack_output(stack, output_key): + def _stack_output(stack, output_key, validate_errors=True): """Return a stack output value for a given key.""" - return next((o['output_value'] for o in stack.outputs - if o['output_key'] == output_key), None) + value = None + for o in stack.outputs: + if validate_errors and 'output_error' in o: + # scan for errors in the stack output. + raise ValueError( + 'Unexpected output errors in %s : %s' % ( + output_key, o['output_error'])) + if o['output_key'] == output_key: + value = o['output_value'] + return value def _ping_ip_address(self, ip_address, should_succeed=True): cmd = ['ping', '-c1', '-w1', ip_address] diff --git a/heat_integrationtests/functional/test_resource_group.py b/heat_integrationtests/functional/test_resource_group.py index ab3b355b3c..8bc99502c8 100644 --- a/heat_integrationtests/functional/test_resource_group.py +++ b/heat_integrationtests/functional/test_resource_group.py @@ -244,14 +244,14 @@ resources: env = {'resource_registry': {'My::RandomString': 'OS::Heat::RandomString'}} - template_one = self.template.replace("count: 0", "count: 1") + template_one = self.template.replace("count: 0", "count: 2") stack_identifier = self.stack_create(template=template_one, environment=env) self.assertEqual({u'random_group': u'OS::Heat::ResourceGroup'}, self.list_resources(stack_identifier)) initial_nested_ident = self._group_nested_identifier(stack_identifier) - self.assertEqual({'0': 'My::RandomString'}, + self.assertEqual({'0': 'My::RandomString', '1': 'My::RandomString'}, self.list_resources(initial_nested_ident)) # get the output stack0 = self.client.stacks.get(stack_identifier) @@ -301,7 +301,7 @@ outputs: env = {'resource_registry': {'My::RandomString': 'my_random.yaml'}} - template_one = self.template.replace("count: 0", "count: 1") + template_one = self.template.replace("count: 0", "count: 2") stack_identifier = self.stack_create(template=template_one, environment=env, files=files1) @@ -309,7 +309,7 @@ outputs: self.list_resources(stack_identifier)) initial_nested_ident = self._group_nested_identifier(stack_identifier) - self.assertEqual({'0': 'My::RandomString'}, + self.assertEqual({'0': 'My::RandomString', '1': 'My::RandomString'}, self.list_resources(initial_nested_ident)) # get the output stack0 = self.client.stacks.get(stack_identifier) diff --git a/heat_integrationtests/functional/test_template_resource.py b/heat_integrationtests/functional/test_template_resource.py index 0d5734b3ee..00e08b0e57 100644 --- a/heat_integrationtests/functional/test_template_resource.py +++ b/heat_integrationtests/functional/test_template_resource.py @@ -180,6 +180,9 @@ heat_template_version: 2014-10-16 resources: secret1: type: OS::Heat::RandomString +outputs: + nested_str: + value: {get_attr: [secret1, value]} ''' stack_identifier = self.stack_create( template=self.main_templ,