blob: 25e99d53c914c51327a9dea9bc2f4e184cf1f1d1 [file] [log] [blame]
Matthew Treinisha33037e2013-12-05 23:16:39 +00001# Copyright 2013 IBM Corp.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# 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, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
Matthew Treinish827a6fb2014-03-20 19:30:08 +000015import os
16
Doug Hellmann583ce2c2015-03-11 14:55:46 +000017from oslo_concurrency import lockutils
18from oslo_config import cfg
19from oslo_config import fixture as conf_fixture
Matthew Treinisha33037e2013-12-05 23:16:39 +000020
Matthew Treinishff598482014-02-28 16:13:58 -050021from tempest import config
Matthew Treinisha33037e2013-12-05 23:16:39 +000022
Matthew Treinisha33037e2013-12-05 23:16:39 +000023
Matthew Treinishff598482014-02-28 16:13:58 -050024class ConfigFixture(conf_fixture.Config):
Matthew Treinisha33037e2013-12-05 23:16:39 +000025
Matthew Treinishff598482014-02-28 16:13:58 -050026 def __init__(self):
Johan Pas0ae551f2015-12-28 22:44:04 +010027 cfg.CONF([], default_config_files=[])
Matthew Treinishff598482014-02-28 16:13:58 -050028 config.register_opts()
29 super(ConfigFixture, self).__init__()
Mauro S. M. Rodriguesdbe4cb62014-02-07 13:03:27 +000030
Matthew Treinishff598482014-02-28 16:13:58 -050031 def setUp(self):
32 super(ConfigFixture, self).setUp()
33 self.conf.set_default('build_interval', 10, group='compute')
34 self.conf.set_default('build_timeout', 10, group='compute')
nh202bc67bb192018-06-29 17:07:50 -070035 self.conf.set_default('image_ref', 'fake_image_id', group='compute')
Matthew Treinishff598482014-02-28 16:13:58 -050036 self.conf.set_default('disable_ssl_certificate_validation', True,
Daniel Melladocad3f3d2016-08-19 14:17:16 +000037 group='identity')
Matthew Treinishff598482014-02-28 16:13:58 -050038 self.conf.set_default('uri', 'http://fake_uri.com/auth',
39 group='identity')
40 self.conf.set_default('uri_v3', 'http://fake_uri_v3.com/auth',
41 group='identity')
42 self.conf.set_default('neutron', True, group='service_available')
Masayuki Igawa47782052017-12-08 19:18:59 +090043 lock_path = str(os.environ.get('OS_TEST_LOCK_PATH',
44 os.environ.get('TMPDIR', '/tmp')))
45 if not os.path.exists(lock_path):
46 os.mkdir(lock_path)
Doug Hellmann583ce2c2015-03-11 14:55:46 +000047 lockutils.set_defaults(
Masayuki Igawa47782052017-12-08 19:18:59 +090048 lock_path=lock_path,
Doug Hellmann583ce2c2015-03-11 14:55:46 +000049 )
Andrea Frittoli7d707a52014-04-06 11:46:32 +010050 self.conf.set_default('auth_version', 'v2', group='identity')
Sean Dagueed6e5862016-04-04 10:49:13 -040051 for config_option in ['username', 'password', 'project_name']:
Andrea Frittoli7d707a52014-04-06 11:46:32 +010052 # Identity group items
Matthew Treinish40847ac2016-01-04 13:16:03 -050053 self.conf.set_default('admin_' + config_option,
54 'fake_' + config_option,
55 group='auth')
Mauro S. M. Rodriguesdbe4cb62014-02-07 13:03:27 +000056
Mauro S. M. Rodriguesdbe4cb62014-02-07 13:03:27 +000057
Matthew Treinishff598482014-02-28 16:13:58 -050058class FakePrivate(config.TempestConfigPrivate):
Joe Gordon28a84ae2014-07-17 15:38:28 +000059 def __init__(self, parse_conf=True, config_path=None):
Matthew Treinishff598482014-02-28 16:13:58 -050060 self._set_attrs()
Johan Pas0ae551f2015-12-28 22:44:04 +010061 self.lock_path = cfg.CONF.oslo_concurrency.lock_path
Andrea Frittoli (andreaf)de5fb0c2016-06-13 12:15:00 +010062
Stephen Finucane7f4a6212018-07-06 13:58:21 +010063
Andrea Frittoli (andreaf)de5fb0c2016-06-13 12:15:00 +010064fake_service1_group = cfg.OptGroup(name='fake-service1', title='Fake service1')
65
66FakeService1Group = [
67 cfg.StrOpt('catalog_type', default='fake-service1'),
68 cfg.StrOpt('endpoint_type', default='faketype'),
69 cfg.StrOpt('region', default='fake_region'),
70 cfg.IntOpt('build_timeout', default=99),
71 cfg.IntOpt('build_interval', default=9)]
72
73fake_service2_group = cfg.OptGroup(name='fake-service2', title='Fake service2')
74
75FakeService2Group = [
76 cfg.StrOpt('catalog_type', default='fake-service2'),
77 cfg.StrOpt('endpoint_type', default='faketype')]
78
79
80class ServiceClientsConfigFixture(conf_fixture.Config):
81
82 def __init__(self):
83 cfg.CONF([], default_config_files=[])
84 config._opts.append((fake_service1_group, FakeService1Group))
85 config._opts.append((fake_service2_group, FakeService2Group))
86 config.register_opts()
87 super(ServiceClientsConfigFixture, self).__init__()
88
89 def setUp(self):
90 super(ServiceClientsConfigFixture, self).setUp()
91 # Debug default values
92 self.conf.set_default('trace_requests', 'fake_module', 'debug')
93 # Identity default values
94 self.conf.set_default('disable_ssl_certificate_validation', True,
Daniel Melladocad3f3d2016-08-19 14:17:16 +000095 group='identity')
Andrea Frittoli (andreaf)de5fb0c2016-06-13 12:15:00 +010096 self.conf.set_default('ca_certificates_file', '/fake/certificates',
Daniel Melladocad3f3d2016-08-19 14:17:16 +000097 group='identity')
Andrea Frittoli (andreaf)de5fb0c2016-06-13 12:15:00 +010098 self.conf.set_default('region', 'fake_region', 'identity')
Andrea Frittoli (andreaf)de5fb0c2016-06-13 12:15:00 +010099 # Compute default values
100 self.conf.set_default('build_interval', 88, group='compute')
101 self.conf.set_default('build_timeout', 8, group='compute')
102
103
104class ServiceClientsFakePrivate(config.TempestConfigPrivate):
105 def __init__(self, parse_conf=True, config_path=None):
106 self._set_attrs()
107 self.fake_service1 = cfg.CONF['fake-service1']
108 self.fake_service2 = cfg.CONF['fake-service2']
Andrea Frittoli (andreaf)de5fb0c2016-06-13 12:15:00 +0100109 self.lock_path = cfg.CONF.oslo_concurrency.lock_path