Merge "Fix status reason in events for deployment signals"

This commit is contained in:
Jenkins 2014-05-05 06:25:33 +00:00 committed by Gerrit Code Review
commit 2d41233814
2 changed files with 23 additions and 2 deletions

View File

@ -882,6 +882,13 @@ class Resource(object):
elif 'state' in details:
# this is from watchrule
return 'alarm state changed to %(state)s' % details
elif 'deploy_status_code' in details:
# this is for SoftwareDeployment
if details['deploy_status_code'] == 0:
return 'deployment succeeded'
else:
return ('deployment failed '
'(%(deploy_status_code)s)' % details)
return 'Unknown'

View File

@ -284,6 +284,16 @@ class SignalTest(HeatTestCase):
none_details = None
none_expected = 'No signal details provided'
# signal from a successful deployment
sds_details = {'deploy_stdout': 'foo', 'deploy_stderr': 'bar',
'deploy_status_code': 0}
sds_expected = 'deployment succeeded'
# signal from a failed deployment
sdf_details = {'deploy_stdout': 'foo', 'deploy_stderr': 'bar',
'deploy_status_code': -1}
sdf_expected = 'deployment failed (-1)'
# to confirm we get a string reason
self.m.StubOutWithMock(generic_resource.SignalResource,
'_add_event')
@ -295,11 +305,15 @@ class SignalTest(HeatTestCase):
'signal', 'COMPLETE', str_expected).AndReturn(None)
generic_resource.SignalResource._add_event(
'signal', 'COMPLETE', none_expected).AndReturn(None)
generic_resource.SignalResource._add_event(
'signal', 'COMPLETE', sds_expected).AndReturn(None)
generic_resource.SignalResource._add_event(
'signal', 'COMPLETE', sdf_expected).AndReturn(None)
self.m.ReplayAll()
for test_d in (ceilo_details, watch_details,
str_details, none_details):
for test_d in (ceilo_details, watch_details, str_details,
none_details, sds_details, sdf_details):
rsrc.signal(details=test_d)
self.m.VerifyAll()