From 527423a5fa6f2229e9f47cb8546cf939a823a2d4 Mon Sep 17 00:00:00 2001 From: licanwei Date: Tue, 28 Mar 2017 12:36:34 +0800 Subject: [PATCH] exception when running 'watcher actionplan start XXX' In DefaultApplier.execute(), Action.list should set eager=True. Otherwise it will trigger an exception when the notification is sent. This also causes the FAILURE of gate-watcher-dsvm-multinode-ubuntu-xenial-nv. Change-Id: I27db9691727671abb582d4f22283ebda5bd51b07 Closes-Bug: #1676308 --- watcher/applier/default.py | 3 ++- .../action_plan/test_default_action_handler.py | 13 ++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) mode change 100644 => 100755 watcher/applier/default.py mode change 100644 => 100755 watcher/tests/applier/action_plan/test_default_action_handler.py diff --git a/watcher/applier/default.py b/watcher/applier/default.py old mode 100644 new mode 100755 index 62b5dce36..aac85d689 --- a/watcher/applier/default.py +++ b/watcher/applier/default.py @@ -58,5 +58,6 @@ class DefaultApplier(base.BaseApplier): LOG.debug("Executing action plan %s ", action_plan_uuid) filters = {'action_plan_uuid': action_plan_uuid} - actions = objects.Action.list(self.context, filters=filters) + actions = objects.Action.list(self.context, filters=filters, + eager=True) return self.engine.execute(actions) diff --git a/watcher/tests/applier/action_plan/test_default_action_handler.py b/watcher/tests/applier/action_plan/test_default_action_handler.py old mode 100644 new mode 100755 index 94827d738..6949416d9 --- a/watcher/tests/applier/action_plan/test_default_action_handler.py +++ b/watcher/tests/applier/action_plan/test_default_action_handler.py @@ -40,9 +40,16 @@ class TestDefaultActionPlanHandler(base.DbTestCase): self.addCleanup(p_action_plan_notifications.stop) obj_utils.create_test_goal(self.context) - obj_utils.create_test_strategy(self.context) - obj_utils.create_test_audit(self.context) - self.action_plan = obj_utils.create_test_action_plan(self.context) + self.strategy = obj_utils.create_test_strategy(self.context) + self.audit = obj_utils.create_test_audit( + self.context, strategy_id=self.strategy.id) + self.action_plan = obj_utils.create_test_action_plan( + self.context, audit_id=self.audit.id, + strategy_id=self.strategy.id) + self.action = obj_utils.create_test_action( + self.context, action_plan_id=self.action_plan.id, + action_type='nop', + input_parameters={'message': 'hello World'}) @mock.patch.object(objects.ActionPlan, "get_by_uuid") def test_launch_action_plan(self, m_get_action_plan):