blob: fc313f27f1ee54f57f510019b28b2d25264176c0 [file] [log] [blame]
Sergey Lukjanov03c95c82013-12-10 16:42:37 +04001# Copyright (c) 2013 Mirantis Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12# implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16from tempest import config
Yaroslav Lobankov93aa8192014-04-01 20:03:25 +040017from tempest import exceptions
Sergey Lukjanov03c95c82013-12-10 16:42:37 +040018import tempest.test
19
20
21CONF = config.CONF
22
23
24class BaseDataProcessingTest(tempest.test.BaseTestCase):
25 _interface = 'json'
26
27 @classmethod
28 def setUpClass(cls):
29 super(BaseDataProcessingTest, cls).setUpClass()
Sergey Lukjanov9c95a252014-03-13 23:59:22 +040030 if not CONF.service_available.sahara:
Yaroslav Lobankov93aa8192014-04-01 20:03:25 +040031 raise cls.skipException('Sahara support is required')
Zhi Kun Liu2259c972014-03-27 02:11:10 -050032
33 os = cls.get_client_manager()
Sergey Lukjanov03c95c82013-12-10 16:42:37 +040034 cls.client = os.data_processing_client
35
Sergey Lukjanov03c95c82013-12-10 16:42:37 +040036 cls.flavor_ref = CONF.compute.flavor_ref
Sergey Lukjanov03c95c82013-12-10 16:42:37 +040037
38 # add lists for watched resources
39 cls._node_group_templates = []
Yaroslav Lobankov93aa8192014-04-01 20:03:25 +040040 cls._cluster_templates = []
Sergey Lukjanov03c95c82013-12-10 16:42:37 +040041
42 @classmethod
43 def tearDownClass(cls):
Yaroslav Lobankov93aa8192014-04-01 20:03:25 +040044 cls.cleanup_resources(getattr(cls, '_cluster_templates', []),
45 cls.client.delete_cluster_template)
46 cls.cleanup_resources(getattr(cls, '_node_group_templates', []),
47 cls.client.delete_node_group_template)
Matthew Treinish92dae932014-01-31 16:43:32 +000048 cls.clear_isolated_creds()
Sergey Lukjanov03c95c82013-12-10 16:42:37 +040049 super(BaseDataProcessingTest, cls).tearDownClass()
50
Yaroslav Lobankov93aa8192014-04-01 20:03:25 +040051 @staticmethod
52 def cleanup_resources(resource_id_list, method):
53 for resource_id in resource_id_list:
54 try:
55 method(resource_id)
56 except exceptions.NotFound:
57 # ignore errors while auto removing created resource
58 pass
59
Sergey Lukjanov03c95c82013-12-10 16:42:37 +040060 @classmethod
61 def create_node_group_template(cls, name, plugin_name, hadoop_version,
62 node_processes, flavor_id,
63 node_configs=None, **kwargs):
64 """Creates watched node group template with specified params.
65
66 It supports passing additional params using kwargs and returns created
67 object. All resources created in this method will be automatically
68 removed in tearDownClass method.
69 """
Sergey Lukjanov03c95c82013-12-10 16:42:37 +040070 resp, body = cls.client.create_node_group_template(name, plugin_name,
71 hadoop_version,
72 node_processes,
73 flavor_id,
74 node_configs,
75 **kwargs)
Sergey Lukjanov03c95c82013-12-10 16:42:37 +040076 # store id of created node group template
Yaroslav Lobankov93aa8192014-04-01 20:03:25 +040077 cls._node_group_templates.append(body['id'])
Sergey Lukjanov03c95c82013-12-10 16:42:37 +040078
Yaroslav Lobankov93aa8192014-04-01 20:03:25 +040079 return resp, body
80
81 @classmethod
82 def create_cluster_template(cls, name, plugin_name, hadoop_version,
83 node_groups, cluster_configs=None, **kwargs):
84 """Creates watched cluster template with specified params.
85
86 It supports passing additional params using kwargs and returns created
87 object. All resources created in this method will be automatically
88 removed in tearDownClass method.
89 """
90 resp, body = cls.client.create_cluster_template(name, plugin_name,
91 hadoop_version,
92 node_groups,
93 cluster_configs,
94 **kwargs)
95 # store id of created cluster template
96 cls._cluster_templates.append(body['id'])
97
98 return resp, body