summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--yardstick/orchestrator/heat.py9
-rw-r--r--yardstick/tests/unit/orchestrator/test_heat.py19
2 files changed, 27 insertions, 1 deletions
diff --git a/yardstick/orchestrator/heat.py b/yardstick/orchestrator/heat.py
index d69f86044..5afa4151e 100644
--- a/yardstick/orchestrator/heat.py
+++ b/yardstick/orchestrator/heat.py
@@ -15,6 +15,7 @@ import datetime
import getpass
import logging
import pkg_resources
+import pprint
import socket
import tempfile
import time
@@ -22,6 +23,7 @@ import time
from oslo_serialization import jsonutils
from oslo_utils import encodeutils
import shade
+from shade._heat import event_utils
import yardstick.common.openstack_utils as op_utils
from yardstick.common import exceptions
@@ -63,6 +65,10 @@ class HeatStack(object):
self._update_stack_tracking()
+ def get_failures(self):
+ return event_utils.get_events(self._cloud, self._stack.id,
+ event_args={'resource_status': 'FAILED'})
+
def get(self):
"""Retrieves an existing stack from the target cloud
@@ -625,6 +631,9 @@ name (i.e. %s).
return stack
if stack.status != self.HEAT_STATUS_COMPLETE:
+ for event in stack.get_failures():
+ log.error("%s", event.resource_status_reason)
+ log.error(pprint.pformat(self._template))
raise exceptions.HeatTemplateError(stack_name=self.name)
log.info("Creating stack '%s' DONE in %d secs",
diff --git a/yardstick/tests/unit/orchestrator/test_heat.py b/yardstick/tests/unit/orchestrator/test_heat.py
index aae2487aa..9598eeb04 100644
--- a/yardstick/tests/unit/orchestrator/test_heat.py
+++ b/yardstick/tests/unit/orchestrator/test_heat.py
@@ -354,13 +354,30 @@ class HeatTemplateTestCase(unittest.TestCase):
3600)
self.assertEqual(heat_stack, ret)
-
def test_create_block_status_no_complete(self):
heat_stack = mock.Mock()
heat_stack.status = 'other status'
+ heat_stack.get_failures.return_value = []
with mock.patch.object(heat, 'HeatStack', return_value=heat_stack):
self.assertRaises(exceptions.HeatTemplateError,
self.template.create, block=True)
heat_stack.create.assert_called_once_with(
self.template._template, self.template.heat_parameters, True,
3600)
+
+ def test_create_block_status_no_complete_with_reasons(self):
+ heat_stack = mock.Mock()
+ heat_stack.status = 'other status'
+ heat_stack.get_failures.return_value = [
+ mock.Mock(resource_status_reason="A reason"),
+ mock.Mock(resource_status_reason="Something else")
+ ]
+ with mock.patch.object(heat, 'HeatStack', return_value=heat_stack):
+ with mock.patch.object(heat, 'log') as mock_log:
+ self.assertRaises(exceptions.HeatTemplateError,
+ self.template.create, block=True)
+ mock_log.error.assert_any_call("%s", "A reason")
+ mock_log.error.assert_any_call("%s", "Something else")
+ heat_stack.create.assert_called_once_with(
+ self.template._template, self.template.heat_parameters, True,
+ 3600)