diff options
Diffstat (limited to 'watcher_tempest_plugin/tests/api/admin/test_action_plan.py')
-rw-r--r-- | watcher_tempest_plugin/tests/api/admin/test_action_plan.py | 140 |
1 files changed, 0 insertions, 140 deletions
diff --git a/watcher_tempest_plugin/tests/api/admin/test_action_plan.py b/watcher_tempest_plugin/tests/api/admin/test_action_plan.py deleted file mode 100644 index 442ac42..0000000 --- a/watcher_tempest_plugin/tests/api/admin/test_action_plan.py +++ /dev/null | |||
@@ -1,140 +0,0 @@ | |||
1 | # -*- encoding: utf-8 -*- | ||
2 | # Copyright (c) 2016 b<>com | ||
3 | # | ||
4 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | # you may not use this file except in compliance with the License. | ||
6 | # You may obtain a copy of the License at | ||
7 | # | ||
8 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | # | ||
10 | # Unless required by applicable law or agreed to in writing, software | ||
11 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
13 | # implied. | ||
14 | # See the License for the specific language governing permissions and | ||
15 | # limitations under the License. | ||
16 | |||
17 | from __future__ import unicode_literals | ||
18 | |||
19 | import functools | ||
20 | |||
21 | from tempest.lib.common.utils import test_utils | ||
22 | from tempest.lib import decorators | ||
23 | from tempest.lib import exceptions | ||
24 | |||
25 | from watcher_tempest_plugin.tests.api.admin import base | ||
26 | |||
27 | |||
28 | class TestCreateDeleteExecuteActionPlan(base.BaseInfraOptimTest): | ||
29 | """Tests for action plans""" | ||
30 | |||
31 | @decorators.attr(type='smoke') | ||
32 | def test_create_action_plan(self): | ||
33 | _, goal = self.client.show_goal("dummy") | ||
34 | _, audit_template = self.create_audit_template(goal['uuid']) | ||
35 | _, audit = self.create_audit(audit_template['uuid']) | ||
36 | |||
37 | self.assertTrue(test_utils.call_until_true( | ||
38 | func=functools.partial(self.has_audit_finished, audit['uuid']), | ||
39 | duration=30, | ||
40 | sleep_for=.5 | ||
41 | )) | ||
42 | _, action_plans = self.client.list_action_plans( | ||
43 | audit_uuid=audit['uuid']) | ||
44 | action_plan = action_plans['action_plans'][0] | ||
45 | |||
46 | _, action_plan = self.client.show_action_plan(action_plan['uuid']) | ||
47 | |||
48 | self.assertEqual(audit['uuid'], action_plan['audit_uuid']) | ||
49 | self.assertEqual('RECOMMENDED', action_plan['state']) | ||
50 | |||
51 | @decorators.attr(type='smoke') | ||
52 | def test_delete_action_plan(self): | ||
53 | _, goal = self.client.show_goal("dummy") | ||
54 | _, audit_template = self.create_audit_template(goal['uuid']) | ||
55 | _, audit = self.create_audit(audit_template['uuid']) | ||
56 | |||
57 | self.assertTrue(test_utils.call_until_true( | ||
58 | func=functools.partial(self.has_audit_finished, audit['uuid']), | ||
59 | duration=30, | ||
60 | sleep_for=.5 | ||
61 | )) | ||
62 | _, action_plans = self.client.list_action_plans( | ||
63 | audit_uuid=audit['uuid']) | ||
64 | action_plan = action_plans['action_plans'][0] | ||
65 | |||
66 | _, action_plan = self.client.show_action_plan(action_plan['uuid']) | ||
67 | |||
68 | self.client.delete_action_plan(action_plan['uuid']) | ||
69 | |||
70 | self.assertRaises(exceptions.NotFound, self.client.show_action_plan, | ||
71 | action_plan['uuid']) | ||
72 | |||
73 | |||
74 | class TestShowListActionPlan(base.BaseInfraOptimTest): | ||
75 | """Tests for action_plan.""" | ||
76 | |||
77 | @classmethod | ||
78 | def resource_setup(cls): | ||
79 | super(TestShowListActionPlan, cls).resource_setup() | ||
80 | _, cls.goal = cls.client.show_goal("dummy") | ||
81 | _, cls.audit_template = cls.create_audit_template(cls.goal['uuid']) | ||
82 | _, cls.audit = cls.create_audit(cls.audit_template['uuid']) | ||
83 | |||
84 | assert test_utils.call_until_true( | ||
85 | func=functools.partial(cls.has_audit_finished, cls.audit['uuid']), | ||
86 | duration=30, | ||
87 | sleep_for=.5 | ||
88 | ) | ||
89 | _, action_plans = cls.client.list_action_plans( | ||
90 | audit_uuid=cls.audit['uuid']) | ||
91 | if len(action_plans['action_plans']) > 0: | ||
92 | cls.action_plan = action_plans['action_plans'][0] | ||
93 | |||
94 | @decorators.attr(type='smoke') | ||
95 | def test_show_action_plan(self): | ||
96 | _, action_plan = self.client.show_action_plan( | ||
97 | self.action_plan['uuid']) | ||
98 | |||
99 | self.assert_expected(self.action_plan, action_plan) | ||
100 | |||
101 | @decorators.attr(type='smoke') | ||
102 | def test_show_action_plan_detail(self): | ||
103 | _, action_plans = self.client.list_action_plans_detail( | ||
104 | audit_uuid=self.audit['uuid']) | ||
105 | |||
106 | action_plan = action_plans['action_plans'][0] | ||
107 | |||
108 | self.assert_expected(self.action_plan, action_plan) | ||
109 | |||
110 | @decorators.attr(type='smoke') | ||
111 | def test_show_action_plan_with_links(self): | ||
112 | _, action_plan = self.client.show_action_plan( | ||
113 | self.action_plan['uuid']) | ||
114 | self.assertIn('links', action_plan.keys()) | ||
115 | self.assertEqual(2, len(action_plan['links'])) | ||
116 | self.assertIn(action_plan['uuid'], | ||
117 | action_plan['links'][0]['href']) | ||
118 | |||
119 | @decorators.attr(type="smoke") | ||
120 | def test_list_action_plans(self): | ||
121 | _, body = self.client.list_action_plans() | ||
122 | self.assertIn(self.action_plan['uuid'], | ||
123 | [i['uuid'] for i in body['action_plans']]) | ||
124 | # Verify self links. | ||
125 | for action_plan in body['action_plans']: | ||
126 | self.validate_self_link('action_plans', action_plan['uuid'], | ||
127 | action_plan['links'][0]['href']) | ||
128 | |||
129 | @decorators.attr(type='smoke') | ||
130 | def test_list_with_limit(self): | ||
131 | # We create 3 extra audits to exceed the limit we fix | ||
132 | for _ in range(3): | ||
133 | self.create_action_plan(self.audit_template['uuid']) | ||
134 | |||
135 | _, body = self.client.list_action_plans(limit=3) | ||
136 | |||
137 | next_marker = body['action_plans'][-1]['uuid'] | ||
138 | |||
139 | self.assertEqual(3, len(body['action_plans'])) | ||
140 | self.assertIn(next_marker, body['next']) | ||