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:
Tin Lam 2016-02-26 23:07:59 -06:00
parent 02f0f8e70a
commit 338539ec53
6 changed files with 23 additions and 23 deletions

View File

@ -406,12 +406,12 @@ class ActionPlansController(rest.RestController):
# transitions that are allowed via PATCH
allowed_patch_transitions = [
(ap_objects.State.RECOMMENDED,
ap_objects.State.TRIGGERED),
ap_objects.State.PENDING),
(ap_objects.State.RECOMMENDED,
ap_objects.State.CANCELLED),
(ap_objects.State.ONGOING,
ap_objects.State.CANCELLED),
(ap_objects.State.TRIGGERED,
(ap_objects.State.PENDING,
ap_objects.State.CANCELLED),
]
@ -427,7 +427,7 @@ class ActionPlansController(rest.RestController):
initial_state=action_plan_to_update.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
# Update only the fields that have changed
@ -443,7 +443,7 @@ class ActionPlansController(rest.RestController):
action_plan_to_update[field] = patch_val
if (field == 'state'
and patch_val == objects.action_plan.State.TRIGGERED):
and patch_val == objects.action_plan.State.PENDING):
launch_action_plan = True
action_plan_to_update.save()

View File

@ -78,7 +78,7 @@ from watcher.objects import utils as obj_utils
class State(object):
RECOMMENDED = 'RECOMMENDED'
TRIGGERED = 'TRIGGERED'
PENDING = 'PENDING'
ONGOING = 'ONGOING'
FAILED = 'FAILED'
SUCCEEDED = 'SUCCEEDED'

View File

@ -386,7 +386,7 @@ class TestPatch(api_base.FunctionalTest):
response = self.patch_json(
'/action_plans/%s' % utils.generate_uuid(),
[{'path': '/state',
'value': objects.action_plan.State.TRIGGERED,
'value': objects.action_plan.State.PENDING,
'op': 'replace'}],
expect_errors=True)
self.assertEqual(404, response.status_int)
@ -436,8 +436,8 @@ class TestPatch(api_base.FunctionalTest):
self.assertTrue(response.json['error_message'])
@mock.patch.object(aapi.ApplierAPI, 'launch_action_plan')
def test_replace_state_triggered_ok(self, applier_mock):
new_state = objects.action_plan.State.TRIGGERED
def test_replace_state_pending_ok(self, applier_mock):
new_state = objects.action_plan.State.PENDING
response = self.get_json(
'/action_plans/%s' % self.action_plan.uuid)
self.assertNotEqual(new_state, response['state'])
@ -453,12 +453,12 @@ class TestPatch(api_base.FunctionalTest):
ALLOWED_TRANSITIONS = [
{"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,
"new_state": objects.action_plan.State.CANCELLED},
{"original_state": objects.action_plan.State.ONGOING,
"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},
]
@ -479,7 +479,7 @@ class TestPatchStateTransitionDenied(api_base.FunctionalTest):
for original_state, new_state
in list(itertools.product(STATES, STATES))
# 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
# 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
@ -493,7 +493,7 @@ class TestPatchStateTransitionDenied(api_base.FunctionalTest):
@mock.patch.object(
db_api.BaseConnection, 'update_action_plan',
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(
self.context, state=self.original_state)
@ -517,7 +517,7 @@ class TestPatchStateDeletedNotFound(api_base.FunctionalTest):
@mock.patch.object(
db_api.BaseConnection, 'update_action_plan',
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(
self.context, state=objects.action_plan.State.DELETED)
@ -545,7 +545,7 @@ class TestPatchStateTransitionOk(api_base.FunctionalTest):
db_api.BaseConnection, 'update_action_plan',
mock.Mock(side_effect=lambda ap: ap.save() or ap))
@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(
self.context, state=self.original_state)

View File

@ -83,10 +83,10 @@ class TestCreateDeleteExecuteActionPlan(base.BaseInfraOptimTest):
_, 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(
action_plan['uuid'],
patch=[{'path': '/state', 'op': 'replace', 'value': 'TRIGGERED'}]
patch=[{'path': '/state', 'op': 'replace', 'value': 'PENDING'}]
)
self.assertTrue(test.call_until_true(
@ -97,7 +97,7 @@ class TestCreateDeleteExecuteActionPlan(base.BaseInfraOptimTest):
))
_, 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')

View File

@ -123,10 +123,10 @@ class TestExecuteBasicStrategy(base.BaseInfraOptimScenarioTest):
_, 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(
action_plan['uuid'],
patch=[{'path': '/state', 'op': 'replace', 'value': 'TRIGGERED'}]
patch=[{'path': '/state', 'op': 'replace', 'value': 'PENDING'}]
)
self.assertTrue(test.call_until_true(
@ -139,7 +139,7 @@ class TestExecuteBasicStrategy(base.BaseInfraOptimScenarioTest):
_, action_list = self.client.list_actions(
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')
for action in action_list['actions']:

View File

@ -51,10 +51,10 @@ class TestExecuteDummyStrategy(base.BaseInfraOptimScenarioTest):
_, 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(
action_plan['uuid'],
patch=[{'path': '/state', 'op': 'replace', 'value': 'TRIGGERED'}]
patch=[{'path': '/state', 'op': 'replace', 'value': 'PENDING'}]
)
self.assertTrue(test.call_until_true(
@ -70,7 +70,7 @@ class TestExecuteDummyStrategy(base.BaseInfraOptimScenarioTest):
action_counter = collections.Counter(
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')
# A dummy strategy generates 2 "nop" actions and 1 "sleep" action