blob: d41c9a1c955b9b8db95bf0b63f04b4ca8919a79e [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
Bo Wanga5bfe022016-02-16 20:04:59 +080013from oslo_utils import reflection
14
Anastasia Kuznetsovae45bfff2015-02-25 12:50:34 +040015from heat_integrationtests.common import test
16
17
18class ScenarioTestsBase(test.HeatIntegrationTest):
Peter Razumovskyf0ac9582015-09-24 16:49:03 +030019 """This class defines common parameters for scenario tests."""
Anastasia Kuznetsovae45bfff2015-02-25 12:50:34 +040020
21 def setUp(self):
22 super(ScenarioTestsBase, self).setUp()
Steven Hardyd6b8ddf2016-01-18 17:23:20 +000023 self.check_skip()
Rabi Mishra477efc92015-07-31 13:01:45 +053024
Anastasia Kuznetsovae45bfff2015-02-25 12:50:34 +040025 self.client = self.orchestration_client
26 self.sub_dir = 'templates'
27 self.assign_keypair()
Anastasia Kuznetsova673fc432015-03-12 16:41:36 +040028
29 if not self.conf.fixed_network_name:
30 raise self.skipException("No default network configured to test")
31 self.net = self._get_network()
Anastasia Kuznetsovae45bfff2015-02-25 12:50:34 +040032
33 if not self.conf.image_ref:
34 raise self.skipException("No image configured to test")
35 if not self.conf.instance_type:
36 raise self.skipException("No flavor configured to test")
37
Pavlo Shchelokovskyy46e5cb22015-03-23 12:01:25 +000038 if not self.conf.minimal_image_ref:
39 raise self.skipException("No minimal image configured to test")
40 if not self.conf.minimal_instance_type:
41 raise self.skipException("No minimal flavor configured to test")
42
Anastasia Kuznetsovae45bfff2015-02-25 12:50:34 +040043 def launch_stack(self, template_name, expected_status='CREATE_COMPLETE',
44 parameters=None, **kwargs):
45 template = self._load_template(__file__, template_name, self.sub_dir)
46
47 parameters = parameters or {}
48
49 if kwargs.get('add_parameters'):
50 parameters.update(kwargs['add_parameters'])
51
52 stack_id = self.stack_create(
53 stack_name=kwargs.get('stack_name'),
54 template=template,
55 files=kwargs.get('files'),
56 parameters=parameters,
57 environment=kwargs.get('environment'),
58 expected_status=expected_status
59 )
60
61 return stack_id
Rabi Mishra477efc92015-07-31 13:01:45 +053062
Steven Hardyd6b8ddf2016-01-18 17:23:20 +000063 def check_skip(self):
Bo Wanga5bfe022016-02-16 20:04:59 +080064 test_cls_name = reflection.get_class_name(self, fully_qualified=False)
Rabi Mishra94c43722015-08-12 18:39:38 +053065 test_method_name = '.'.join([test_cls_name, self._testMethodName])
66 test_skipped = (self.conf.skip_scenario_test_list and (
67 test_cls_name in self.conf.skip_scenario_test_list or
68 test_method_name in self.conf.skip_scenario_test_list))
Rabi Mishra477efc92015-07-31 13:01:45 +053069 if self.conf.skip_scenario_tests or test_skipped:
70 self.skipTest('Test disabled in conf, skipping')