From 338539ec53b6f479df2cf88b87cedef3c6782576 Mon Sep 17 00:00:00 2001 From: Tin Lam Date: Fri, 26 Feb 2016 23:07:59 -0600 Subject: [PATCH] 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 --- watcher/api/controllers/v1/action_plan.py | 8 ++++---- watcher/objects/action_plan.py | 2 +- watcher/tests/api/v1/test_actions_plans.py | 18 +++++++++--------- .../tests/api/admin/test_action_plan.py | 6 +++--- .../tests/scenario/test_execute_basic_optim.py | 6 +++--- .../tests/scenario/test_execute_dummy_optim.py | 6 +++--- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/watcher/api/controllers/v1/action_plan.py b/watcher/api/controllers/v1/action_plan.py index a565dfec5..adcd74468 100644 --- a/watcher/api/controllers/v1/action_plan.py +++ b/watcher/api/controllers/v1/action_plan.py @@ -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() diff --git a/watcher/objects/action_plan.py b/watcher/objects/action_plan.py index 325d51785..4386eae2f 100644 --- a/watcher/objects/action_plan.py +++ b/watcher/objects/action_plan.py @@ -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' diff --git a/watcher/tests/api/v1/test_actions_plans.py b/watcher/tests/api/v1/test_actions_plans.py index ef0336ec3..d7663b5ee 100644 --- a/watcher/tests/api/v1/test_actions_plans.py +++ b/watcher/tests/api/v1/test_actions_plans.py @@ -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) diff --git a/watcher_tempest_plugin/tests/api/admin/test_action_plan.py b/watcher_tempest_plugin/tests/api/admin/test_action_plan.py index 0757ae203..7ff7adc8d 100644 --- a/watcher_tempest_plugin/tests/api/admin/test_action_plan.py +++ b/watcher_tempest_plugin/tests/api/admin/test_action_plan.py @@ -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') diff --git a/watcher_tempest_plugin/tests/scenario/test_execute_basic_optim.py b/watcher_tempest_plugin/tests/scenario/test_execute_basic_optim.py index ac6a6f1e6..92bc0e5ac 100644 --- a/watcher_tempest_plugin/tests/scenario/test_execute_basic_optim.py +++ b/watcher_tempest_plugin/tests/scenario/test_execute_basic_optim.py @@ -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']: diff --git a/watcher_tempest_plugin/tests/scenario/test_execute_dummy_optim.py b/watcher_tempest_plugin/tests/scenario/test_execute_dummy_optim.py index e9756d47f..df7d4eeee 100644 --- a/watcher_tempest_plugin/tests/scenario/test_execute_dummy_optim.py +++ b/watcher_tempest_plugin/tests/scenario/test_execute_dummy_optim.py @@ -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