| Anastasia Kuznetsova | e45bfff | 2015-02-25 12:50:34 +0400 | [diff] [blame] | 1 | #    Licensed under the Apache License, Version 2.0 (the "License"); you may | 
|  | 2 | #    not use this file except in compliance with the License. You may obtain | 
|  | 3 | #    a copy of the License at | 
|  | 4 | # | 
|  | 5 | #         http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 6 | # | 
|  | 7 | #    Unless required by applicable law or agreed to in writing, software | 
|  | 8 | #    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | 
|  | 9 | #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | 
|  | 10 | #    License for the specific language governing permissions and limitations | 
|  | 11 | #    under the License. | 
|  | 12 |  | 
|  | 13 | from heat_integrationtests.common import test | 
|  | 14 |  | 
|  | 15 |  | 
|  | 16 | class ScenarioTestsBase(test.HeatIntegrationTest): | 
|  | 17 | "This class define common parameters for scenario tests" | 
|  | 18 |  | 
|  | 19 | def setUp(self): | 
|  | 20 | super(ScenarioTestsBase, self).setUp() | 
| Rabi Mishra | 477efc9 | 2015-07-31 13:01:45 +0530 | [diff] [blame] | 21 | self.check_skip_test() | 
|  | 22 |  | 
| Anastasia Kuznetsova | e45bfff | 2015-02-25 12:50:34 +0400 | [diff] [blame] | 23 | self.client = self.orchestration_client | 
|  | 24 | self.sub_dir = 'templates' | 
|  | 25 | self.assign_keypair() | 
| Anastasia Kuznetsova | 673fc43 | 2015-03-12 16:41:36 +0400 | [diff] [blame] | 26 |  | 
|  | 27 | if not self.conf.fixed_network_name: | 
|  | 28 | raise self.skipException("No default network configured to test") | 
|  | 29 | self.net = self._get_network() | 
| Anastasia Kuznetsova | e45bfff | 2015-02-25 12:50:34 +0400 | [diff] [blame] | 30 |  | 
|  | 31 | if not self.conf.image_ref: | 
|  | 32 | raise self.skipException("No image configured to test") | 
|  | 33 | if not self.conf.instance_type: | 
|  | 34 | raise self.skipException("No flavor configured to test") | 
|  | 35 |  | 
| Pavlo Shchelokovskyy | 46e5cb2 | 2015-03-23 12:01:25 +0000 | [diff] [blame] | 36 | if not self.conf.minimal_image_ref: | 
|  | 37 | raise self.skipException("No minimal image configured to test") | 
|  | 38 | if not self.conf.minimal_instance_type: | 
|  | 39 | raise self.skipException("No minimal flavor configured to test") | 
|  | 40 |  | 
| Anastasia Kuznetsova | e45bfff | 2015-02-25 12:50:34 +0400 | [diff] [blame] | 41 | def launch_stack(self, template_name, expected_status='CREATE_COMPLETE', | 
|  | 42 | parameters=None, **kwargs): | 
|  | 43 | template = self._load_template(__file__, template_name, self.sub_dir) | 
|  | 44 |  | 
|  | 45 | parameters = parameters or {} | 
|  | 46 |  | 
|  | 47 | if kwargs.get('add_parameters'): | 
|  | 48 | parameters.update(kwargs['add_parameters']) | 
|  | 49 |  | 
|  | 50 | stack_id = self.stack_create( | 
|  | 51 | stack_name=kwargs.get('stack_name'), | 
|  | 52 | template=template, | 
|  | 53 | files=kwargs.get('files'), | 
|  | 54 | parameters=parameters, | 
|  | 55 | environment=kwargs.get('environment'), | 
|  | 56 | expected_status=expected_status | 
|  | 57 | ) | 
|  | 58 |  | 
|  | 59 | return stack_id | 
| Rabi Mishra | 477efc9 | 2015-07-31 13:01:45 +0530 | [diff] [blame] | 60 |  | 
|  | 61 | def check_skip_test(self): | 
| Rabi Mishra | 94c4372 | 2015-08-12 18:39:38 +0530 | [diff] [blame^] | 62 | test_cls_name = self.__class__.__name__ | 
|  | 63 | test_method_name = '.'.join([test_cls_name, self._testMethodName]) | 
|  | 64 | test_skipped = (self.conf.skip_scenario_test_list and ( | 
|  | 65 | test_cls_name in self.conf.skip_scenario_test_list or | 
|  | 66 | test_method_name in self.conf.skip_scenario_test_list)) | 
| Rabi Mishra | 477efc9 | 2015-07-31 13:01:45 +0530 | [diff] [blame] | 67 | if self.conf.skip_scenario_tests or test_skipped: | 
|  | 68 | self.skipTest('Test disabled in conf, skipping') |