blob: c48d64dc33000ea6d442336b54cc81e87707e375 [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()
Anastasia Kuznetsovae45bfff2015-02-25 12:50:34 +040024 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
Pavlo Shchelokovskyy46e5cb22015-03-23 12:01:25 +000031 if not self.conf.minimal_image_ref:
32 raise self.skipException("No minimal image configured to test")
33 if not self.conf.minimal_instance_type:
34 raise self.skipException("No minimal flavor configured to test")
35
Anastasia Kuznetsovae45bfff2015-02-25 12:50:34 +040036 def launch_stack(self, template_name, expected_status='CREATE_COMPLETE',
37 parameters=None, **kwargs):
38 template = self._load_template(__file__, template_name, self.sub_dir)
39
40 parameters = parameters or {}
41
42 if kwargs.get('add_parameters'):
43 parameters.update(kwargs['add_parameters'])
44
45 stack_id = self.stack_create(
46 stack_name=kwargs.get('stack_name'),
47 template=template,
48 files=kwargs.get('files'),
49 parameters=parameters,
50 environment=kwargs.get('environment'),
51 expected_status=expected_status
52 )
53
54 return stack_id
Rabi Mishra477efc92015-07-31 13:01:45 +053055
Steven Hardyd6b8ddf2016-01-18 17:23:20 +000056 def check_skip(self):
Bo Wanga5bfe022016-02-16 20:04:59 +080057 test_cls_name = reflection.get_class_name(self, fully_qualified=False)
Rabi Mishra94c43722015-08-12 18:39:38 +053058 test_method_name = '.'.join([test_cls_name, self._testMethodName])
59 test_skipped = (self.conf.skip_scenario_test_list and (
60 test_cls_name in self.conf.skip_scenario_test_list or
61 test_method_name in self.conf.skip_scenario_test_list))
Rabi Mishra477efc92015-07-31 13:01:45 +053062 if self.conf.skip_scenario_tests or test_skipped:
63 self.skipTest('Test disabled in conf, skipping')