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
diff --git a/functional/test_autoscaling.py b/functional/test_autoscaling.py
index 1b9fe99..9041405 100644
--- a/functional/test_autoscaling.py
+++ b/functional/test_autoscaling.py
@@ -13,7 +13,9 @@
import copy
import json
+from heatclient import exc
from oslo_log import log as logging
+import six
from testtools import matchers
from heat_integrationtests.common import test
@@ -728,8 +730,13 @@
self._wait_for_resource_status(
stack_identifier, 'JobServerGroup', 'SUSPEND_COMPLETE')
- # Send a signal and confirm nothing happened.
- self.client.resources.signal(stack_identifier, 'ScaleUpPolicy')
+ # Send a signal and a exception will raise
+ ex = self.assertRaises(exc.BadRequest,
+ self.client.resources.signal,
+ stack_identifier, 'ScaleUpPolicy')
+
+ error_msg = 'Signal resource during SUSPEND is not supported'
+ self.assertIn(error_msg, six.text_type(ex))
ev = self.wait_for_event_with_reason(
stack_identifier,
reason='Cannot signal resource during SUSPEND',