summaryrefslogtreecommitdiff
path: root/watcher_tempest_plugin/tests/scenario/test_execute_dummy_optim.py
diff options
context:
space:
mode:
Diffstat (limited to 'watcher_tempest_plugin/tests/scenario/test_execute_dummy_optim.py')
-rw-r--r--watcher_tempest_plugin/tests/scenario/test_execute_dummy_optim.py85
1 files changed, 0 insertions, 85 deletions
diff --git a/watcher_tempest_plugin/tests/scenario/test_execute_dummy_optim.py b/watcher_tempest_plugin/tests/scenario/test_execute_dummy_optim.py
deleted file mode 100644
index 33b108a..0000000
--- a/watcher_tempest_plugin/tests/scenario/test_execute_dummy_optim.py
+++ /dev/null
@@ -1,85 +0,0 @@
1# -*- encoding: utf-8 -*-
2# Copyright (c) 2016 b<>com
3#
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14# implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17
18from __future__ import unicode_literals
19
20import collections
21import functools
22
23from tempest.lib.common.utils import test_utils
24
25from watcher_tempest_plugin.tests.scenario import base
26
27
28class TestExecuteDummyStrategy(base.BaseInfraOptimScenarioTest):
29 """Tests for action plans"""
30
31 def test_execute_dummy_action_plan(self):
32 """Execute an action plan based on the 'dummy' strategy
33
34 - create an audit template with the 'dummy' strategy
35 - run the audit to create an action plan
36 - get the action plan
37 - run the action plan
38 - get results and make sure it succeeded
39 """
40 _, goal = self.client.show_goal("dummy")
41 _, audit_template = self.create_audit_template(goal['uuid'])
42 _, audit = self.create_audit(audit_template['uuid'])
43
44 self.assertTrue(test_utils.call_until_true(
45 func=functools.partial(self.has_audit_finished, audit['uuid']),
46 duration=30,
47 sleep_for=.5
48 ))
49
50 self.assertTrue(self.has_audit_succeeded(audit['uuid']))
51
52 _, action_plans = self.client.list_action_plans(
53 audit_uuid=audit['uuid'])
54 action_plan = action_plans['action_plans'][0]
55
56 _, action_plan = self.client.show_action_plan(action_plan['uuid'])
57
58 if action_plan['state'] in ['SUPERSEDED', 'SUCCEEDED']:
59 # This means the action plan is superseded so we cannot trigger it,
60 # or it is empty.
61 return
62
63 # Execute the action by changing its state to PENDING
64 _, updated_ap = self.client.start_action_plan(action_plan['uuid'])
65
66 self.assertTrue(test_utils.call_until_true(
67 func=functools.partial(
68 self.has_action_plan_finished, action_plan['uuid']),
69 duration=30,
70 sleep_for=.5
71 ))
72 _, finished_ap = self.client.show_action_plan(action_plan['uuid'])
73 _, action_list = self.client.list_actions(
74 action_plan_uuid=finished_ap["uuid"])
75
76 action_counter = collections.Counter(
77 act['action_type'] for act in action_list['actions'])
78
79 self.assertIn(updated_ap['state'], ('PENDING', 'ONGOING'))
80 self.assertIn(finished_ap['state'], ('SUCCEEDED', 'SUPERSEDED'))
81
82 # A dummy strategy generates 2 "nop" actions and 1 "sleep" action
83 self.assertEqual(3, len(action_list['actions']))
84 self.assertEqual(2, action_counter.get("nop"))
85 self.assertEqual(1, action_counter.get("sleep"))