Merge "Fix suspend/resume error in RemoteStack"
This commit is contained in:
commit
398b77042c
@ -180,13 +180,13 @@ class RemoteStack(resource.Resource):
|
|||||||
if self.resource_id is None:
|
if self.resource_id is None:
|
||||||
raise exception.Error(_('Cannot resume %s, resource not found')
|
raise exception.Error(_('Cannot resume %s, resource not found')
|
||||||
% self.name)
|
% self.name)
|
||||||
self.heat().stacks.resume(stack_id=self.resource_id)
|
self.heat().actions.resume(stack_id=self.resource_id)
|
||||||
|
|
||||||
def handle_suspend(self):
|
def handle_suspend(self):
|
||||||
if self.resource_id is None:
|
if self.resource_id is None:
|
||||||
raise exception.Error(_('Cannot suspend %s, resource not found')
|
raise exception.Error(_('Cannot suspend %s, resource not found')
|
||||||
% self.name)
|
% self.name)
|
||||||
self.heat().stacks.suspend(stack_id=self.resource_id)
|
self.heat().actions.suspend(stack_id=self.resource_id)
|
||||||
|
|
||||||
def handle_update(self, json_snippet, tmpl_diff, prop_diff):
|
def handle_update(self, json_snippet, tmpl_diff, prop_diff):
|
||||||
if self.resource_id and prop_diff:
|
if self.resource_id and prop_diff:
|
||||||
|
@ -417,11 +417,11 @@ class RemoteStackTest(tests_common.HeatTestCase):
|
|||||||
rsrc.action = rsrc.SUSPEND
|
rsrc.action = rsrc.SUSPEND
|
||||||
|
|
||||||
self.heat.stacks.get = mock.MagicMock(side_effect=side_effect)
|
self.heat.stacks.get = mock.MagicMock(side_effect=side_effect)
|
||||||
self.heat.stacks.resume = mock.MagicMock()
|
self.heat.actions.resume = mock.MagicMock()
|
||||||
scheduler.TaskRunner(rsrc.resume)()
|
scheduler.TaskRunner(rsrc.resume)()
|
||||||
|
|
||||||
self.assertEqual((rsrc.RESUME, rsrc.COMPLETE), rsrc.state)
|
self.assertEqual((rsrc.RESUME, rsrc.COMPLETE), rsrc.state)
|
||||||
self.heat.stacks.resume.assert_called_with(stack_id=rsrc.resource_id)
|
self.heat.actions.resume.assert_called_with(stack_id=rsrc.resource_id)
|
||||||
|
|
||||||
def test_resume_failed(self):
|
def test_resume_failed(self):
|
||||||
returns = [get_stack(stack_status='RESUME_IN_PROGRESS'),
|
returns = [get_stack(stack_status='RESUME_IN_PROGRESS'),
|
||||||
@ -435,14 +435,14 @@ class RemoteStackTest(tests_common.HeatTestCase):
|
|||||||
rsrc.action = rsrc.SUSPEND
|
rsrc.action = rsrc.SUSPEND
|
||||||
|
|
||||||
self.heat.stacks.get = mock.MagicMock(side_effect=side_effect)
|
self.heat.stacks.get = mock.MagicMock(side_effect=side_effect)
|
||||||
self.heat.stacks.resume = mock.MagicMock()
|
self.heat.actions.resume = mock.MagicMock()
|
||||||
error = self.assertRaises(exception.ResourceFailure,
|
error = self.assertRaises(exception.ResourceFailure,
|
||||||
scheduler.TaskRunner(rsrc.resume))
|
scheduler.TaskRunner(rsrc.resume))
|
||||||
error_msg = ('ResourceInError: Went to status RESUME_FAILED due to '
|
error_msg = ('ResourceInError: Went to status RESUME_FAILED due to '
|
||||||
'"Remote stack resume failed"')
|
'"Remote stack resume failed"')
|
||||||
self.assertEqual(error_msg, six.text_type(error))
|
self.assertEqual(error_msg, six.text_type(error))
|
||||||
self.assertEqual((rsrc.RESUME, rsrc.FAILED), rsrc.state)
|
self.assertEqual((rsrc.RESUME, rsrc.FAILED), rsrc.state)
|
||||||
self.heat.stacks.resume.assert_called_with(stack_id=rsrc.resource_id)
|
self.heat.actions.resume.assert_called_with(stack_id=rsrc.resource_id)
|
||||||
|
|
||||||
def test_resume_failed_not_created(self):
|
def test_resume_failed_not_created(self):
|
||||||
self.initialize()
|
self.initialize()
|
||||||
@ -464,11 +464,11 @@ class RemoteStackTest(tests_common.HeatTestCase):
|
|||||||
rsrc = self.create_remote_stack()
|
rsrc = self.create_remote_stack()
|
||||||
|
|
||||||
self.heat.stacks.get = mock.MagicMock(side_effect=side_effect)
|
self.heat.stacks.get = mock.MagicMock(side_effect=side_effect)
|
||||||
self.heat.stacks.suspend = mock.MagicMock()
|
self.heat.actions.suspend = mock.MagicMock()
|
||||||
scheduler.TaskRunner(rsrc.suspend)()
|
scheduler.TaskRunner(rsrc.suspend)()
|
||||||
|
|
||||||
self.assertEqual((rsrc.SUSPEND, rsrc.COMPLETE), rsrc.state)
|
self.assertEqual((rsrc.SUSPEND, rsrc.COMPLETE), rsrc.state)
|
||||||
self.heat.stacks.suspend.assert_called_with(stack_id=rsrc.resource_id)
|
self.heat.actions.suspend.assert_called_with(stack_id=rsrc.resource_id)
|
||||||
|
|
||||||
def test_suspend_failed(self):
|
def test_suspend_failed(self):
|
||||||
stacks = [get_stack(stack_status='SUSPEND_IN_PROGRESS'),
|
stacks = [get_stack(stack_status='SUSPEND_IN_PROGRESS'),
|
||||||
@ -481,24 +481,28 @@ class RemoteStackTest(tests_common.HeatTestCase):
|
|||||||
rsrc = self.create_remote_stack()
|
rsrc = self.create_remote_stack()
|
||||||
|
|
||||||
self.heat.stacks.get = mock.MagicMock(side_effect=side_effect)
|
self.heat.stacks.get = mock.MagicMock(side_effect=side_effect)
|
||||||
self.heat.stacks.suspend = mock.MagicMock()
|
self.heat.actions.suspend = mock.MagicMock()
|
||||||
error = self.assertRaises(exception.ResourceFailure,
|
error = self.assertRaises(exception.ResourceFailure,
|
||||||
scheduler.TaskRunner(rsrc.suspend))
|
scheduler.TaskRunner(rsrc.suspend))
|
||||||
error_msg = ('ResourceInError: Went to status SUSPEND_FAILED due to '
|
error_msg = ('ResourceInError: Went to status SUSPEND_FAILED due to '
|
||||||
'"Remote stack suspend failed"')
|
'"Remote stack suspend failed"')
|
||||||
self.assertEqual(error_msg, six.text_type(error))
|
self.assertEqual(error_msg, six.text_type(error))
|
||||||
self.assertEqual((rsrc.SUSPEND, rsrc.FAILED), rsrc.state)
|
self.assertEqual((rsrc.SUSPEND, rsrc.FAILED), rsrc.state)
|
||||||
self.heat.stacks.suspend.assert_called_with(stack_id=rsrc.resource_id)
|
# assert suspend was not called
|
||||||
|
self.heat.actions.suspend.assert_has_calls([])
|
||||||
|
|
||||||
def test_suspend_failed_not_created(self):
|
def test_suspend_failed_not_created(self):
|
||||||
self.initialize()
|
self.initialize()
|
||||||
rsrc = self.parent['remote_stack']
|
rsrc = self.parent['remote_stack']
|
||||||
# Note: the resource is not created so far
|
# Note: the resource is not created so far
|
||||||
|
self.heat.actions.suspend = mock.MagicMock()
|
||||||
error = self.assertRaises(exception.ResourceFailure,
|
error = self.assertRaises(exception.ResourceFailure,
|
||||||
scheduler.TaskRunner(rsrc.suspend))
|
scheduler.TaskRunner(rsrc.suspend))
|
||||||
error_msg = 'Error: Cannot suspend remote_stack, resource not found'
|
error_msg = 'Error: Cannot suspend remote_stack, resource not found'
|
||||||
self.assertEqual(error_msg, six.text_type(error))
|
self.assertEqual(error_msg, six.text_type(error))
|
||||||
self.assertEqual((rsrc.SUSPEND, rsrc.FAILED), rsrc.state)
|
self.assertEqual((rsrc.SUSPEND, rsrc.FAILED), rsrc.state)
|
||||||
|
# assert suspend was not called
|
||||||
|
self.heat.actions.suspend.assert_has_calls([])
|
||||||
|
|
||||||
def test_update(self):
|
def test_update(self):
|
||||||
stacks = [get_stack(stack_status='UPDATE_IN_PROGRESS'),
|
stacks = [get_stack(stack_status='UPDATE_IN_PROGRESS'),
|
||||||
|
Loading…
Reference in New Issue
Block a user