Sergey Lukjanov | 03c95c8 | 2013-12-10 16:42:37 +0400 | [diff] [blame] | 1 | # 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 | |
| 16 | from tempest import config |
| 17 | import tempest.test |
| 18 | |
| 19 | |
| 20 | CONF = config.CONF |
| 21 | |
| 22 | |
| 23 | class BaseDataProcessingTest(tempest.test.BaseTestCase): |
| 24 | _interface = 'json' |
| 25 | |
| 26 | @classmethod |
| 27 | def setUpClass(cls): |
| 28 | super(BaseDataProcessingTest, cls).setUpClass() |
| 29 | os = cls.get_client_manager() |
| 30 | if not CONF.service_available.savanna: |
| 31 | raise cls.skipException("Savanna support is required") |
| 32 | cls.client = os.data_processing_client |
| 33 | |
| 34 | # set some constants |
| 35 | cls.flavor_ref = CONF.compute.flavor_ref |
| 36 | cls.simple_node_group_template = { |
| 37 | 'plugin_name': 'vanilla', |
| 38 | 'hadoop_version': '1.2.1', |
| 39 | 'node_processes': [ |
| 40 | "datanode", |
| 41 | "tasktracker" |
| 42 | ], |
| 43 | 'flavor_id': cls.flavor_ref, |
| 44 | 'node_configs': { |
| 45 | 'HDFS': { |
| 46 | 'Data Node Heap Size': 1024 |
| 47 | }, |
| 48 | 'MapReduce': { |
| 49 | 'Task Tracker Heap Size': 1024 |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | # add lists for watched resources |
| 55 | cls._node_group_templates = [] |
| 56 | |
| 57 | @classmethod |
| 58 | def tearDownClass(cls): |
| 59 | # cleanup node group templates |
| 60 | for ngt_id in cls._node_group_templates: |
| 61 | try: |
| 62 | cls.client.delete_node_group_template(ngt_id) |
| 63 | except Exception: |
| 64 | # ignore errors while auto removing created resource |
| 65 | pass |
Matthew Treinish | 92dae93 | 2014-01-31 16:43:32 +0000 | [diff] [blame] | 66 | cls.clear_isolated_creds() |
Sergey Lukjanov | 03c95c8 | 2013-12-10 16:42:37 +0400 | [diff] [blame] | 67 | super(BaseDataProcessingTest, cls).tearDownClass() |
| 68 | |
| 69 | @classmethod |
| 70 | def create_node_group_template(cls, name, plugin_name, hadoop_version, |
| 71 | node_processes, flavor_id, |
| 72 | node_configs=None, **kwargs): |
| 73 | """Creates watched node group template with specified params. |
| 74 | |
| 75 | It supports passing additional params using kwargs and returns created |
| 76 | object. All resources created in this method will be automatically |
| 77 | removed in tearDownClass method. |
| 78 | """ |
| 79 | |
| 80 | resp, body = cls.client.create_node_group_template(name, plugin_name, |
| 81 | hadoop_version, |
| 82 | node_processes, |
| 83 | flavor_id, |
| 84 | node_configs, |
| 85 | **kwargs) |
| 86 | |
| 87 | # store id of created node group template |
| 88 | template_id = body['id'] |
| 89 | cls._node_group_templates.append(template_id) |
| 90 | |
| 91 | return resp, body, template_id |