Merge "Get capacity when notification send if resize failed"
This commit is contained in:
commit
ff30fed06b
@ -341,6 +341,7 @@ class AutoScalingGroup(instgrp.InstanceGroup, cooldown.CooldownMixin):
|
||||
try:
|
||||
notif.update({'suffix': 'error',
|
||||
'message': six.text_type(resize_ex),
|
||||
'capacity': grouputils.get_size(self),
|
||||
})
|
||||
notification.send(**notif)
|
||||
except Exception:
|
||||
|
@ -266,7 +266,40 @@ class TestGroupAdjust(common.HeatTestCase):
|
||||
stack=self.group.stack)]
|
||||
|
||||
self.assertEqual(expected_notifies, notify.call_args_list)
|
||||
grouputils.get_size.assert_called_once_with(self.group)
|
||||
grouputils.get_size.assert_called_with(self.group)
|
||||
|
||||
def test_notification_send_if_resize_failed(self):
|
||||
"""If resize failed, the capacity of group might have been changed"""
|
||||
self.patchobject(grouputils, 'get_size', side_effect=[3, 4])
|
||||
self.patchobject(self.group, 'resize',
|
||||
side_effect=ValueError('test error'))
|
||||
notify = self.patch('heat.engine.notification.autoscaling.send')
|
||||
self.patchobject(self.group, '_cooldown_inprogress',
|
||||
return_value=False)
|
||||
|
||||
self.assertRaises(ValueError, self.group.adjust,
|
||||
5, adjustment_type='ExactCapacity')
|
||||
|
||||
expected_notifies = [
|
||||
mock.call(
|
||||
capacity=3, suffix='start',
|
||||
adjustment_type='ExactCapacity',
|
||||
groupname='my-group',
|
||||
message='Start resizing the group my-group',
|
||||
adjustment=5,
|
||||
stack=self.group.stack),
|
||||
mock.call(
|
||||
capacity=4, suffix='error',
|
||||
adjustment_type='ExactCapacity',
|
||||
groupname='my-group',
|
||||
message=u'test error',
|
||||
adjustment=5,
|
||||
stack=self.group.stack)]
|
||||
|
||||
self.assertEqual(expected_notifies, notify.call_args_list)
|
||||
self.group.resize.assert_called_once_with(5)
|
||||
grouputils.get_size.assert_has_calls([mock.call(self.group),
|
||||
mock.call(self.group)])
|
||||
|
||||
|
||||
class TestGroupCrud(common.HeatTestCase):
|
||||
|
@ -453,7 +453,40 @@ class TestGroupAdjust(common.HeatTestCase):
|
||||
stack=self.group.stack)]
|
||||
|
||||
self.assertEqual(expected_notifies, notify.call_args_list)
|
||||
grouputils.get_size.assert_called_once_with(self.group)
|
||||
grouputils.get_size.assert_called_with(self.group)
|
||||
|
||||
def test_notification_send_if_resize_failed(self):
|
||||
"""If resize failed, the capacity of group might have been changed"""
|
||||
self.patchobject(grouputils, 'get_size', side_effect=[3, 4])
|
||||
self.patchobject(self.group, 'resize',
|
||||
side_effect=ValueError('test error'))
|
||||
notify = self.patch('heat.engine.notification.autoscaling.send')
|
||||
self.patchobject(self.group, '_cooldown_inprogress',
|
||||
return_value=False)
|
||||
|
||||
self.assertRaises(ValueError, self.group.adjust,
|
||||
5, adjustment_type='ExactCapacity')
|
||||
|
||||
expected_notifies = [
|
||||
mock.call(
|
||||
capacity=3, suffix='start',
|
||||
adjustment_type='ExactCapacity',
|
||||
groupname=u'WebServerGroup',
|
||||
message=u'Start resizing the group WebServerGroup',
|
||||
adjustment=5,
|
||||
stack=self.group.stack),
|
||||
mock.call(
|
||||
capacity=4, suffix='error',
|
||||
adjustment_type='ExactCapacity',
|
||||
groupname=u'WebServerGroup',
|
||||
message=u'test error',
|
||||
adjustment=5,
|
||||
stack=self.group.stack)]
|
||||
|
||||
self.assertEqual(expected_notifies, notify.call_args_list)
|
||||
self.group.resize.assert_called_once_with(5)
|
||||
grouputils.get_size.assert_has_calls([mock.call(self.group),
|
||||
mock.call(self.group)])
|
||||
|
||||
|
||||
class TestGroupCrud(common.HeatTestCase):
|
||||
|
Loading…
Reference in New Issue
Block a user