Rename 'TRIGGERED' state as 'PENDING'
"TRIGGERED" is not the correct word to use to describe the action state, we should use "PENDING" instead. Change-Id: If24979cdb916523861324f7bcc024e2f1fc28b05 Closes-Bug: #1548377
This commit is contained in:
@@ -406,12 +406,12 @@ class ActionPlansController(rest.RestController):
|
|||||||
# transitions that are allowed via PATCH
|
# transitions that are allowed via PATCH
|
||||||
allowed_patch_transitions = [
|
allowed_patch_transitions = [
|
||||||
(ap_objects.State.RECOMMENDED,
|
(ap_objects.State.RECOMMENDED,
|
||||||
ap_objects.State.TRIGGERED),
|
ap_objects.State.PENDING),
|
||||||
(ap_objects.State.RECOMMENDED,
|
(ap_objects.State.RECOMMENDED,
|
||||||
ap_objects.State.CANCELLED),
|
ap_objects.State.CANCELLED),
|
||||||
(ap_objects.State.ONGOING,
|
(ap_objects.State.ONGOING,
|
||||||
ap_objects.State.CANCELLED),
|
ap_objects.State.CANCELLED),
|
||||||
(ap_objects.State.TRIGGERED,
|
(ap_objects.State.PENDING,
|
||||||
ap_objects.State.CANCELLED),
|
ap_objects.State.CANCELLED),
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -427,7 +427,7 @@ class ActionPlansController(rest.RestController):
|
|||||||
initial_state=action_plan_to_update.state,
|
initial_state=action_plan_to_update.state,
|
||||||
new_state=action_plan.state))
|
new_state=action_plan.state))
|
||||||
|
|
||||||
if action_plan.state == ap_objects.State.TRIGGERED:
|
if action_plan.state == ap_objects.State.PENDING:
|
||||||
launch_action_plan = True
|
launch_action_plan = True
|
||||||
|
|
||||||
# Update only the fields that have changed
|
# Update only the fields that have changed
|
||||||
@@ -443,7 +443,7 @@ class ActionPlansController(rest.RestController):
|
|||||||
action_plan_to_update[field] = patch_val
|
action_plan_to_update[field] = patch_val
|
||||||
|
|
||||||
if (field == 'state'
|
if (field == 'state'
|
||||||
and patch_val == objects.action_plan.State.TRIGGERED):
|
and patch_val == objects.action_plan.State.PENDING):
|
||||||
launch_action_plan = True
|
launch_action_plan = True
|
||||||
|
|
||||||
action_plan_to_update.save()
|
action_plan_to_update.save()
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ from watcher.objects import utils as obj_utils
|
|||||||
|
|
||||||
class State(object):
|
class State(object):
|
||||||
RECOMMENDED = 'RECOMMENDED'
|
RECOMMENDED = 'RECOMMENDED'
|
||||||
TRIGGERED = 'TRIGGERED'
|
PENDING = 'PENDING'
|
||||||
ONGOING = 'ONGOING'
|
ONGOING = 'ONGOING'
|
||||||
FAILED = 'FAILED'
|
FAILED = 'FAILED'
|
||||||
SUCCEEDED = 'SUCCEEDED'
|
SUCCEEDED = 'SUCCEEDED'
|
||||||
|
|||||||
@@ -386,7 +386,7 @@ class TestPatch(api_base.FunctionalTest):
|
|||||||
response = self.patch_json(
|
response = self.patch_json(
|
||||||
'/action_plans/%s' % utils.generate_uuid(),
|
'/action_plans/%s' % utils.generate_uuid(),
|
||||||
[{'path': '/state',
|
[{'path': '/state',
|
||||||
'value': objects.action_plan.State.TRIGGERED,
|
'value': objects.action_plan.State.PENDING,
|
||||||
'op': 'replace'}],
|
'op': 'replace'}],
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
self.assertEqual(404, response.status_int)
|
self.assertEqual(404, response.status_int)
|
||||||
@@ -436,8 +436,8 @@ class TestPatch(api_base.FunctionalTest):
|
|||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['error_message'])
|
||||||
|
|
||||||
@mock.patch.object(aapi.ApplierAPI, 'launch_action_plan')
|
@mock.patch.object(aapi.ApplierAPI, 'launch_action_plan')
|
||||||
def test_replace_state_triggered_ok(self, applier_mock):
|
def test_replace_state_pending_ok(self, applier_mock):
|
||||||
new_state = objects.action_plan.State.TRIGGERED
|
new_state = objects.action_plan.State.PENDING
|
||||||
response = self.get_json(
|
response = self.get_json(
|
||||||
'/action_plans/%s' % self.action_plan.uuid)
|
'/action_plans/%s' % self.action_plan.uuid)
|
||||||
self.assertNotEqual(new_state, response['state'])
|
self.assertNotEqual(new_state, response['state'])
|
||||||
@@ -453,12 +453,12 @@ class TestPatch(api_base.FunctionalTest):
|
|||||||
|
|
||||||
ALLOWED_TRANSITIONS = [
|
ALLOWED_TRANSITIONS = [
|
||||||
{"original_state": objects.action_plan.State.RECOMMENDED,
|
{"original_state": objects.action_plan.State.RECOMMENDED,
|
||||||
"new_state": objects.action_plan.State.TRIGGERED},
|
"new_state": objects.action_plan.State.PENDING},
|
||||||
{"original_state": objects.action_plan.State.RECOMMENDED,
|
{"original_state": objects.action_plan.State.RECOMMENDED,
|
||||||
"new_state": objects.action_plan.State.CANCELLED},
|
"new_state": objects.action_plan.State.CANCELLED},
|
||||||
{"original_state": objects.action_plan.State.ONGOING,
|
{"original_state": objects.action_plan.State.ONGOING,
|
||||||
"new_state": objects.action_plan.State.CANCELLED},
|
"new_state": objects.action_plan.State.CANCELLED},
|
||||||
{"original_state": objects.action_plan.State.TRIGGERED,
|
{"original_state": objects.action_plan.State.PENDING,
|
||||||
"new_state": objects.action_plan.State.CANCELLED},
|
"new_state": objects.action_plan.State.CANCELLED},
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -479,7 +479,7 @@ class TestPatchStateTransitionDenied(api_base.FunctionalTest):
|
|||||||
for original_state, new_state
|
for original_state, new_state
|
||||||
in list(itertools.product(STATES, STATES))
|
in list(itertools.product(STATES, STATES))
|
||||||
# from DELETED to ...
|
# from DELETED to ...
|
||||||
# NOTE: Any state transition from DELETED (To RECOMMENDED, TRIGGERED,
|
# NOTE: Any state transition from DELETED (To RECOMMENDED, PENDING,
|
||||||
# ONGOING, CANCELLED, SUCCEEDED and FAILED) will cause a 404 Not Found
|
# ONGOING, CANCELLED, SUCCEEDED and FAILED) will cause a 404 Not Found
|
||||||
# because we cannot retrieve them with a GET (soft_deleted state).
|
# because we cannot retrieve them with a GET (soft_deleted state).
|
||||||
# This is the reason why they are not listed here but they have a
|
# This is the reason why they are not listed here but they have a
|
||||||
@@ -493,7 +493,7 @@ class TestPatchStateTransitionDenied(api_base.FunctionalTest):
|
|||||||
@mock.patch.object(
|
@mock.patch.object(
|
||||||
db_api.BaseConnection, 'update_action_plan',
|
db_api.BaseConnection, 'update_action_plan',
|
||||||
mock.Mock(side_effect=lambda ap: ap.save() or ap))
|
mock.Mock(side_effect=lambda ap: ap.save() or ap))
|
||||||
def test_replace_state_triggered_denied(self):
|
def test_replace_state_pending_denied(self):
|
||||||
action_plan = obj_utils.create_action_plan_without_audit(
|
action_plan = obj_utils.create_action_plan_without_audit(
|
||||||
self.context, state=self.original_state)
|
self.context, state=self.original_state)
|
||||||
|
|
||||||
@@ -517,7 +517,7 @@ class TestPatchStateDeletedNotFound(api_base.FunctionalTest):
|
|||||||
@mock.patch.object(
|
@mock.patch.object(
|
||||||
db_api.BaseConnection, 'update_action_plan',
|
db_api.BaseConnection, 'update_action_plan',
|
||||||
mock.Mock(side_effect=lambda ap: ap.save() or ap))
|
mock.Mock(side_effect=lambda ap: ap.save() or ap))
|
||||||
def test_replace_state_triggered_not_found(self):
|
def test_replace_state_pending_not_found(self):
|
||||||
action_plan = obj_utils.create_action_plan_without_audit(
|
action_plan = obj_utils.create_action_plan_without_audit(
|
||||||
self.context, state=objects.action_plan.State.DELETED)
|
self.context, state=objects.action_plan.State.DELETED)
|
||||||
|
|
||||||
@@ -545,7 +545,7 @@ class TestPatchStateTransitionOk(api_base.FunctionalTest):
|
|||||||
db_api.BaseConnection, 'update_action_plan',
|
db_api.BaseConnection, 'update_action_plan',
|
||||||
mock.Mock(side_effect=lambda ap: ap.save() or ap))
|
mock.Mock(side_effect=lambda ap: ap.save() or ap))
|
||||||
@mock.patch.object(aapi.ApplierAPI, 'launch_action_plan', mock.Mock())
|
@mock.patch.object(aapi.ApplierAPI, 'launch_action_plan', mock.Mock())
|
||||||
def test_replace_state_triggered_ok(self):
|
def test_replace_state_pending_ok(self):
|
||||||
action_plan = obj_utils.create_action_plan_without_audit(
|
action_plan = obj_utils.create_action_plan_without_audit(
|
||||||
self.context, state=self.original_state)
|
self.context, state=self.original_state)
|
||||||
|
|
||||||
|
|||||||
@@ -83,10 +83,10 @@ class TestCreateDeleteExecuteActionPlan(base.BaseInfraOptimTest):
|
|||||||
|
|
||||||
_, action_plan = self.client.show_action_plan(action_plan['uuid'])
|
_, action_plan = self.client.show_action_plan(action_plan['uuid'])
|
||||||
|
|
||||||
# Execute the action by changing its state to TRIGGERED
|
# Execute the action by changing its state to PENDING
|
||||||
_, updated_ap = self.client.update_action_plan(
|
_, updated_ap = self.client.update_action_plan(
|
||||||
action_plan['uuid'],
|
action_plan['uuid'],
|
||||||
patch=[{'path': '/state', 'op': 'replace', 'value': 'TRIGGERED'}]
|
patch=[{'path': '/state', 'op': 'replace', 'value': 'PENDING'}]
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertTrue(test.call_until_true(
|
self.assertTrue(test.call_until_true(
|
||||||
@@ -97,7 +97,7 @@ class TestCreateDeleteExecuteActionPlan(base.BaseInfraOptimTest):
|
|||||||
))
|
))
|
||||||
_, finished_ap = self.client.show_action_plan(action_plan['uuid'])
|
_, finished_ap = self.client.show_action_plan(action_plan['uuid'])
|
||||||
|
|
||||||
self.assertIn(updated_ap['state'], ('TRIGGERED', 'ONGOING'))
|
self.assertIn(updated_ap['state'], ('PENDING', 'ONGOING'))
|
||||||
self.assertEqual(finished_ap['state'], 'SUCCEEDED')
|
self.assertEqual(finished_ap['state'], 'SUCCEEDED')
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -123,10 +123,10 @@ class TestExecuteBasicStrategy(base.BaseInfraOptimScenarioTest):
|
|||||||
|
|
||||||
_, action_plan = self.client.show_action_plan(action_plan['uuid'])
|
_, action_plan = self.client.show_action_plan(action_plan['uuid'])
|
||||||
|
|
||||||
# Execute the action by changing its state to TRIGGERED
|
# Execute the action by changing its state to PENDING
|
||||||
_, updated_ap = self.client.update_action_plan(
|
_, updated_ap = self.client.update_action_plan(
|
||||||
action_plan['uuid'],
|
action_plan['uuid'],
|
||||||
patch=[{'path': '/state', 'op': 'replace', 'value': 'TRIGGERED'}]
|
patch=[{'path': '/state', 'op': 'replace', 'value': 'PENDING'}]
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertTrue(test.call_until_true(
|
self.assertTrue(test.call_until_true(
|
||||||
@@ -139,7 +139,7 @@ class TestExecuteBasicStrategy(base.BaseInfraOptimScenarioTest):
|
|||||||
_, action_list = self.client.list_actions(
|
_, action_list = self.client.list_actions(
|
||||||
action_plan_uuid=finished_ap["uuid"])
|
action_plan_uuid=finished_ap["uuid"])
|
||||||
|
|
||||||
self.assertIn(updated_ap['state'], ('TRIGGERED', 'ONGOING'))
|
self.assertIn(updated_ap['state'], ('PENDING', 'ONGOING'))
|
||||||
self.assertEqual(finished_ap['state'], 'SUCCEEDED')
|
self.assertEqual(finished_ap['state'], 'SUCCEEDED')
|
||||||
|
|
||||||
for action in action_list['actions']:
|
for action in action_list['actions']:
|
||||||
|
|||||||
@@ -51,10 +51,10 @@ class TestExecuteDummyStrategy(base.BaseInfraOptimScenarioTest):
|
|||||||
|
|
||||||
_, action_plan = self.client.show_action_plan(action_plan['uuid'])
|
_, action_plan = self.client.show_action_plan(action_plan['uuid'])
|
||||||
|
|
||||||
# Execute the action by changing its state to TRIGGERED
|
# Execute the action by changing its state to PENDING
|
||||||
_, updated_ap = self.client.update_action_plan(
|
_, updated_ap = self.client.update_action_plan(
|
||||||
action_plan['uuid'],
|
action_plan['uuid'],
|
||||||
patch=[{'path': '/state', 'op': 'replace', 'value': 'TRIGGERED'}]
|
patch=[{'path': '/state', 'op': 'replace', 'value': 'PENDING'}]
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertTrue(test.call_until_true(
|
self.assertTrue(test.call_until_true(
|
||||||
@@ -70,7 +70,7 @@ class TestExecuteDummyStrategy(base.BaseInfraOptimScenarioTest):
|
|||||||
action_counter = collections.Counter(
|
action_counter = collections.Counter(
|
||||||
act['action_type'] for act in action_list['actions'])
|
act['action_type'] for act in action_list['actions'])
|
||||||
|
|
||||||
self.assertIn(updated_ap['state'], ('TRIGGERED', 'ONGOING'))
|
self.assertIn(updated_ap['state'], ('PENDING', 'ONGOING'))
|
||||||
self.assertEqual(finished_ap['state'], 'SUCCEEDED')
|
self.assertEqual(finished_ap['state'], 'SUCCEEDED')
|
||||||
|
|
||||||
# A dummy strategy generates 2 "nop" actions and 1 "sleep" action
|
# A dummy strategy generates 2 "nop" actions and 1 "sleep" action
|
||||||
|
|||||||
Reference in New Issue
Block a user