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
diff --git a/common/test.py b/common/test.py
index acfe1ad..584af6d 100644
--- a/common/test.py
+++ b/common/test.py
@@ -175,10 +175,18 @@
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/functional/test_resource_group.py b/functional/test_resource_group.py
index ab3b355..8bc9950 100644
--- a/functional/test_resource_group.py
+++ b/functional/test_resource_group.py
@@ -244,14 +244,14 @@
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 @@
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 @@
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/functional/test_template_resource.py b/functional/test_template_resource.py
index 0d5734b..00e08b0 100644
--- a/functional/test_template_resource.py
+++ b/functional/test_template_resource.py
@@ -180,6 +180,9 @@
resources:
secret1:
type: OS::Heat::RandomString
+outputs:
+ nested_str:
+ value: {get_attr: [secret1, value]}
'''
stack_identifier = self.stack_create(
template=self.main_templ,