summaryrefslogtreecommitdiff
path: root/watcher_tempest_plugin/tests/api/admin/test_action.py
diff options
context:
space:
mode:
Diffstat (limited to 'watcher_tempest_plugin/tests/api/admin/test_action.py')
-rw-r--r--watcher_tempest_plugin/tests/api/admin/test_action.py110
1 files changed, 0 insertions, 110 deletions
diff --git a/watcher_tempest_plugin/tests/api/admin/test_action.py b/watcher_tempest_plugin/tests/api/admin/test_action.py
deleted file mode 100644
index 3fa2d94..0000000
--- a/watcher_tempest_plugin/tests/api/admin/test_action.py
+++ /dev/null
@@ -1,110 +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
17from __future__ import unicode_literals
18
19import collections
20import functools
21
22from tempest.lib.common.utils import test_utils
23from tempest.lib import decorators
24
25from watcher_tempest_plugin.tests.api.admin import base
26
27
28class TestShowListAction(base.BaseInfraOptimTest):
29 """Tests for actions"""
30
31 @classmethod
32 def resource_setup(cls):
33 super(TestShowListAction, cls).resource_setup()
34 _, cls.goal = cls.client.show_goal("DUMMY")
35 _, cls.audit_template = cls.create_audit_template(cls.goal['uuid'])
36 _, cls.audit = cls.create_audit(cls.audit_template['uuid'])
37
38 assert test_utils.call_until_true(
39 func=functools.partial(cls.has_audit_finished, cls.audit['uuid']),
40 duration=30,
41 sleep_for=.5
42 )
43 _, action_plans = cls.client.list_action_plans(
44 audit_uuid=cls.audit['uuid'])
45 cls.action_plan = action_plans['action_plans'][0]
46
47 @decorators.attr(type='smoke')
48 def test_show_one_action(self):
49 _, body = self.client.list_actions(
50 action_plan_uuid=self.action_plan["uuid"])
51 actions = body['actions']
52
53 _, action = self.client.show_action(actions[0]["uuid"])
54
55 self.assertEqual(self.action_plan["uuid"], action['action_plan_uuid'])
56 self.assertEqual("PENDING", action['state'])
57
58 @decorators.attr(type='smoke')
59 def test_show_action_with_links(self):
60 _, body = self.client.list_actions(
61 action_plan_uuid=self.action_plan["uuid"])
62 actions = body['actions']
63
64 _, action = self.client.show_action(actions[0]["uuid"])
65
66 self.assertIn('links', action.keys())
67 self.assertEqual(2, len(action['links']))
68 self.assertIn(action['uuid'], action['links'][0]['href'])
69
70 @decorators.attr(type="smoke")
71 def test_list_actions(self):
72 _, body = self.client.list_actions()
73
74 # Verify self links.
75 for action in body['actions']:
76 self.validate_self_link('actions', action['uuid'],
77 action['links'][0]['href'])
78
79 @decorators.attr(type="smoke")
80 def test_list_actions_by_action_plan(self):
81 _, body = self.client.list_actions(
82 action_plan_uuid=self.action_plan["uuid"])
83
84 for item in body['actions']:
85 self.assertEqual(self.action_plan["uuid"],
86 item['action_plan_uuid'])
87
88 action_counter = collections.Counter(
89 act['action_type'] for act in body['actions'])
90
91 # A dummy strategy generates 2 "nop" actions and 1 "sleep" action
92 self.assertEqual(3, len(body['actions']))
93 self.assertEqual(2, action_counter.get("nop"))
94 self.assertEqual(1, action_counter.get("sleep"))
95
96 @decorators.attr(type="smoke")
97 def test_list_actions_by_audit(self):
98 _, body = self.client.list_actions(audit_uuid=self.audit["uuid"])
99
100 for item in body['actions']:
101 self.assertEqual(self.action_plan["uuid"],
102 item['action_plan_uuid'])
103
104 action_counter = collections.Counter(
105 act['action_type'] for act in body['actions'])
106
107 # A dummy strategy generates 2 "nop" actions and 1 "sleep" action
108 self.assertEqual(3, len(body['actions']))
109 self.assertEqual(2, action_counter.get("nop"))
110 self.assertEqual(1, action_counter.get("sleep"))