Fix wrongly printed count of received handled conditions.
The WaitConditionTimeout message was using size of the reason string as input instead of the actual number of status reasons. Change-Id: I9ad1813755eda6924ffeff116eaeda9f36b601d1 Closes-Bug: #1297230
This commit is contained in:
parent
0114afcf56
commit
a4ed4a1921
|
@ -95,13 +95,11 @@ class WaitConditionHandle(signal_responder.SignalResponder):
|
|||
|
||||
def get_status_reason(self, status):
|
||||
'''
|
||||
Return the reason associated with a particular status
|
||||
If there is more than one handle signal matching the specified status
|
||||
then return a semicolon delimited string containing all reasons
|
||||
Return a list of reasons associated with a particular status
|
||||
'''
|
||||
return ';'.join([v['Reason']
|
||||
for v in self.metadata.values()
|
||||
if v['Status'] == status])
|
||||
return [v['Reason']
|
||||
for v in self.metadata.values()
|
||||
if v['Status'] == status]
|
||||
|
||||
|
||||
WAIT_STATUSES = (
|
||||
|
@ -129,7 +127,7 @@ class UpdateWaitConditionHandle(WaitConditionHandle):
|
|||
class WaitConditionFailure(exception.Error):
|
||||
def __init__(self, wait_condition, handle):
|
||||
reasons = handle.get_status_reason(STATUS_FAILURE)
|
||||
super(WaitConditionFailure, self).__init__(reasons)
|
||||
super(WaitConditionFailure, self).__init__(';'.join(reasons))
|
||||
|
||||
|
||||
class WaitConditionTimeout(exception.Error):
|
||||
|
@ -138,7 +136,7 @@ class WaitConditionTimeout(exception.Error):
|
|||
vals = {'len': len(reasons),
|
||||
'count': wait_condition.properties[wait_condition.COUNT]}
|
||||
if reasons:
|
||||
vals['reasons'] = reasons
|
||||
vals['reasons'] = ';'.join(reasons)
|
||||
message = (_('%(len)d of %(count)d received - %(reasons)s') % vals)
|
||||
else:
|
||||
message = (_('%(len)d of %(count)d received') % vals)
|
||||
|
|
|
@ -561,17 +561,17 @@ class WaitConditionHandleTest(HeatTestCase):
|
|||
test_metadata = {'Data': 'foo', 'Reason': 'bar',
|
||||
'Status': 'SUCCESS', 'UniqueId': '123'}
|
||||
rsrc.metadata_update(new_metadata=test_metadata)
|
||||
self.assertEqual('bar', rsrc.get_status_reason('SUCCESS'))
|
||||
self.assertEqual(['bar'], rsrc.get_status_reason('SUCCESS'))
|
||||
|
||||
test_metadata = {'Data': 'dog', 'Reason': 'cat',
|
||||
'Status': 'SUCCESS', 'UniqueId': '456'}
|
||||
rsrc.metadata_update(new_metadata=test_metadata)
|
||||
self.assertEqual('bar;cat', rsrc.get_status_reason('SUCCESS'))
|
||||
self.assertEqual(['bar', 'cat'], rsrc.get_status_reason('SUCCESS'))
|
||||
|
||||
test_metadata = {'Data': 'boo', 'Reason': 'hoo',
|
||||
'Status': 'FAILURE', 'UniqueId': '789'}
|
||||
rsrc.metadata_update(new_metadata=test_metadata)
|
||||
self.assertEqual('hoo', rsrc.get_status_reason('FAILURE'))
|
||||
self.assertEqual(['hoo'], rsrc.get_status_reason('FAILURE'))
|
||||
self.m.VerifyAll()
|
||||
|
||||
|
||||
|
@ -758,8 +758,9 @@ class WaitConditionUpdateTest(HeatTestCase):
|
|||
parsed_snippet = self.stack.resolve_static_data(update_snippet)
|
||||
updater = rsrc.handle_update(parsed_snippet, {}, prop_diff)
|
||||
self.assertEqual(5, rsrc.properties['Count'])
|
||||
self.assertRaises(wc.WaitConditionTimeout, updater.run_to_completion)
|
||||
|
||||
ex = self.assertRaises(wc.WaitConditionTimeout,
|
||||
updater.run_to_completion)
|
||||
self.assertEqual("0 of 5 received", str(ex))
|
||||
self.m.VerifyAll()
|
||||
self.m.UnsetStubs()
|
||||
|
||||
|
|
Loading…
Reference in New Issue