summaryrefslogtreecommitdiff
path: root/heat/tests/test_signal.py
diff options
context:
space:
mode:
authorhuangtianhua <huangtianhua@huawei.com>2015-07-09 09:15:10 +0800
committerhuangtianhua <huangtianhua@huawei.com>2015-09-09 14:52:37 +0800
commit18ded430d0e256ce5f9eec3ef61b5337596f914a (patch)
tree764364609a80d62b7fe79fb905a953b7ef2d63e7 /heat/tests/test_signal.py
parentf1cfb9ed39a6316f4da2148e7830874b59b56863 (diff)
downloadheat-18ded430d0e256ce5f9eec3ef61b5337596f914a.tar.gz
Return error message if validate fail when clearing hook
There are some situations: 1. User can run the command "heat hook-clear" on any resource in the stack, even if there is no hook defined on it, and no error or warning message is returned. 2. User run the command "heat hook-clear" on resource to clear the hook which resource unset, and no error or warning message is returned. 3. User run the command "heat hook-clear" on resource even if the resource's action is not support to signal, and no error or warning message is returned. 4. User run the command "heat hook-clear" to clear invalid hooks, and no error or warnning message is returned. This patch will check the situations above before call resource.signal, and will return error messages to user. Change-Id: Ifb9befad864ebe1bb5f8b419b95d1b3a95530573 Closes-Bug: #1472515
Diffstat (limited to 'heat/tests/test_signal.py')
-rw-r--r--heat/tests/test_signal.py23
1 files changed, 16 insertions, 7 deletions
diff --git a/heat/tests/test_signal.py b/heat/tests/test_signal.py
index c955001de..9c6a5d8a6 100644
--- a/heat/tests/test_signal.py
+++ b/heat/tests/test_signal.py
@@ -618,9 +618,7 @@ class SignalTest(common.HeatTestCase):
self.m.VerifyAll()
- def test_signal_reception_wrong_state(self):
- # assert that we get the correct exception when calling a
- # resource.signal() that is in having a destructive action.
+ def _test_signal_not_supported_action(self, action='DELETE'):
self.stack = self.create_stack()
self.m.ReplayAll()
@@ -629,14 +627,25 @@ class SignalTest(common.HeatTestCase):
rsrc = self.stack['signal_handler']
self.assertEqual((rsrc.CREATE, rsrc.COMPLETE), rsrc.state)
# manually override the action to DELETE
- rsrc.action = rsrc.DELETE
+ rsrc.action = action
err_metadata = {'Data': 'foo', 'Status': 'SUCCESS', 'UniqueId': '123'}
- self.assertRaises(exception.ResourceFailure, rsrc.signal,
- details=err_metadata)
-
+ msg = 'Signal resource during %s is not supported.' % action
+ exc = self.assertRaises(exception.NotSupported, rsrc.signal,
+ details=err_metadata)
+ self.assertEqual(msg, six.text_type(exc))
self.m.VerifyAll()
+ def test_signal_in_delete_state(self):
+ # assert that we get the correct exception when calling a
+ # resource.signal() that is in delete action.
+ self._test_signal_not_supported_action()
+
+ def test_signal_in_suspend_state(self):
+ # assert that we get the correct exception when calling a
+ # resource.signal() that is in suspend action.
+ self._test_signal_not_supported_action(action='SUSPEND')
+
def test_signal_reception_failed_call(self):
# assert that we get the correct exception from resource.signal()
# when resource.handle_signal() raises an exception.