stale the action plan
Check the creation time of the actionplan, and set the state to SUPERSEDED if it has expired. Change-Id: I900e8dc5011dec4cffd58913b9c5083a6131d70d Implements: blueprint stale-action-plan
This commit is contained in:
@@ -48,7 +48,7 @@ class TestDecisionEngineSchedulingService(base.TestCase):
|
||||
|
||||
m_start.assert_called_once_with(scheduler)
|
||||
jobs = scheduler.get_jobs()
|
||||
self.assertEqual(1, len(jobs))
|
||||
self.assertEqual(2, len(jobs))
|
||||
|
||||
job = jobs[0]
|
||||
self.assertTrue(bool(fake_collector.cluster_data_model))
|
||||
@@ -77,7 +77,7 @@ class TestDecisionEngineSchedulingService(base.TestCase):
|
||||
|
||||
m_start.assert_called_once_with(scheduler)
|
||||
jobs = scheduler.get_jobs()
|
||||
self.assertEqual(1, len(jobs))
|
||||
self.assertEqual(2, len(jobs))
|
||||
|
||||
job = jobs[0]
|
||||
job.func()
|
||||
|
||||
@@ -19,12 +19,16 @@ import iso8601
|
||||
import mock
|
||||
|
||||
from watcher.common import exception
|
||||
from watcher.common import utils as common_utils
|
||||
from watcher import conf
|
||||
from watcher.db.sqlalchemy import api as db_api
|
||||
from watcher import notifications
|
||||
from watcher import objects
|
||||
from watcher.tests.db import base
|
||||
from watcher.tests.db import utils
|
||||
|
||||
CONF = conf.CONF
|
||||
|
||||
|
||||
class TestActionPlanObject(base.DbTestCase):
|
||||
|
||||
@@ -290,3 +294,31 @@ class TestCreateDeleteActionPlanObject(base.DbTestCase):
|
||||
m_destroy_efficacy_indicator.assert_called_once_with(
|
||||
efficacy_indicator['uuid'])
|
||||
self.assertEqual(self.context, action_plan._context)
|
||||
|
||||
|
||||
@mock.patch.object(notifications.action_plan, 'send_update', mock.Mock())
|
||||
class TestStateManager(base.DbTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestStateManager, self).setUp()
|
||||
self.state_manager = objects.action_plan.StateManager()
|
||||
|
||||
def test_check_expired(self):
|
||||
CONF.set_default('action_plan_expiry', 0,
|
||||
group='watcher_decision_engine')
|
||||
strategy_1 = utils.create_test_strategy(
|
||||
uuid=common_utils.generate_uuid())
|
||||
audit_1 = utils.create_test_audit(
|
||||
uuid=common_utils.generate_uuid())
|
||||
action_plan_1 = utils.create_test_action_plan(
|
||||
state=objects.action_plan.State.RECOMMENDED,
|
||||
uuid=common_utils.generate_uuid(),
|
||||
audit_id=audit_1.id,
|
||||
strategy_id=strategy_1.id)
|
||||
|
||||
self.state_manager.check_expired(self.context)
|
||||
|
||||
action_plan = objects.action_plan.ActionPlan.get_by_uuid(
|
||||
self.context, action_plan_1.uuid)
|
||||
self.assertEqual(objects.action_plan.State.SUPERSEDED,
|
||||
action_plan.state)
|
||||
|
||||
Reference in New Issue
Block a user