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
This commit is contained in:
Angus Salkeld 2015-07-24 15:47:38 +10:00
parent 413c780bb2
commit 4b3b4ce14b
3 changed files with 18 additions and 7 deletions

View File

@ -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]

View File

@ -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)

View File

@ -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,