blob: 14b8cec4b488e10a9f9b3218f6616f1956ab9898 [file] [log] [blame]
Anastasia Kuznetsovae45bfff2015-02-25 12:50:34 +04001# 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
13from heat_integrationtests.common import test
14
15
16class ScenarioTestsBase(test.HeatIntegrationTest):
Peter Razumovskyf0ac9582015-09-24 16:49:03 +030017 """This class defines common parameters for scenario tests."""
Anastasia Kuznetsovae45bfff2015-02-25 12:50:34 +040018
19 def setUp(self):
20 super(ScenarioTestsBase, self).setUp()
Rabi Mishra477efc92015-07-31 13:01:45 +053021 self.check_skip_test()
22
Anastasia Kuznetsovae45bfff2015-02-25 12:50:34 +040023 self.client = self.orchestration_client
24 self.sub_dir = 'templates'
25 self.assign_keypair()
Anastasia Kuznetsova673fc432015-03-12 16:41:36 +040026
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 Kuznetsovae45bfff2015-02-25 12:50:34 +040030
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 Shchelokovskyy46e5cb22015-03-23 12:01:25 +000036 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 Kuznetsovae45bfff2015-02-25 12:50:34 +040041 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 Mishra477efc92015-07-31 13:01:45 +053060
61 def check_skip_test(self):
Rabi Mishra94c43722015-08-12 18:39:38 +053062 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 Mishra477efc92015-07-31 13:01:45 +053067 if self.conf.skip_scenario_tests or test_skipped:
68 self.skipTest('Test disabled in conf, skipping')