Matthew Treinish | a33037e | 2013-12-05 23:16:39 +0000 | [diff] [blame] | 1 | # 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 Treinish | 827a6fb | 2014-03-20 19:30:08 +0000 | [diff] [blame] | 15 | import os |
| 16 | |
Doug Hellmann | 583ce2c | 2015-03-11 14:55:46 +0000 | [diff] [blame] | 17 | from oslo_concurrency import lockutils |
| 18 | from oslo_config import cfg |
| 19 | from oslo_config import fixture as conf_fixture |
Matthew Treinish | a33037e | 2013-12-05 23:16:39 +0000 | [diff] [blame] | 20 | |
Matthew Treinish | ff59848 | 2014-02-28 16:13:58 -0500 | [diff] [blame] | 21 | from tempest import config |
Matthew Treinish | a33037e | 2013-12-05 23:16:39 +0000 | [diff] [blame] | 22 | |
Matthew Treinish | a33037e | 2013-12-05 23:16:39 +0000 | [diff] [blame] | 23 | |
Matthew Treinish | ff59848 | 2014-02-28 16:13:58 -0500 | [diff] [blame] | 24 | class ConfigFixture(conf_fixture.Config): |
Matthew Treinish | a33037e | 2013-12-05 23:16:39 +0000 | [diff] [blame] | 25 | |
Matthew Treinish | ff59848 | 2014-02-28 16:13:58 -0500 | [diff] [blame] | 26 | def __init__(self): |
Johan Pas | 0ae551f | 2015-12-28 22:44:04 +0100 | [diff] [blame] | 27 | cfg.CONF([], default_config_files=[]) |
Matthew Treinish | ff59848 | 2014-02-28 16:13:58 -0500 | [diff] [blame] | 28 | config.register_opts() |
| 29 | super(ConfigFixture, self).__init__() |
Mauro S. M. Rodrigues | dbe4cb6 | 2014-02-07 13:03:27 +0000 | [diff] [blame] | 30 | |
Matthew Treinish | ff59848 | 2014-02-28 16:13:58 -0500 | [diff] [blame] | 31 | 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') |
nh202b | c67bb19 | 2018-06-29 17:07:50 -0700 | [diff] [blame] | 35 | self.conf.set_default('image_ref', 'fake_image_id', group='compute') |
Matthew Treinish | ff59848 | 2014-02-28 16:13:58 -0500 | [diff] [blame] | 36 | self.conf.set_default('disable_ssl_certificate_validation', True, |
Daniel Mellado | cad3f3d | 2016-08-19 14:17:16 +0000 | [diff] [blame] | 37 | group='identity') |
Matthew Treinish | ff59848 | 2014-02-28 16:13:58 -0500 | [diff] [blame] | 38 | 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 Igawa | 4778205 | 2017-12-08 19:18:59 +0900 | [diff] [blame] | 43 | 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 Hellmann | 583ce2c | 2015-03-11 14:55:46 +0000 | [diff] [blame] | 47 | lockutils.set_defaults( |
Masayuki Igawa | 4778205 | 2017-12-08 19:18:59 +0900 | [diff] [blame] | 48 | lock_path=lock_path, |
Doug Hellmann | 583ce2c | 2015-03-11 14:55:46 +0000 | [diff] [blame] | 49 | ) |
Andrea Frittoli | 7d707a5 | 2014-04-06 11:46:32 +0100 | [diff] [blame] | 50 | self.conf.set_default('auth_version', 'v2', group='identity') |
Sean Dague | ed6e586 | 2016-04-04 10:49:13 -0400 | [diff] [blame] | 51 | for config_option in ['username', 'password', 'project_name']: |
Andrea Frittoli | 7d707a5 | 2014-04-06 11:46:32 +0100 | [diff] [blame] | 52 | # Identity group items |
Matthew Treinish | 40847ac | 2016-01-04 13:16:03 -0500 | [diff] [blame] | 53 | self.conf.set_default('admin_' + config_option, |
| 54 | 'fake_' + config_option, |
| 55 | group='auth') |
Mauro S. M. Rodrigues | dbe4cb6 | 2014-02-07 13:03:27 +0000 | [diff] [blame] | 56 | |
Mauro S. M. Rodrigues | dbe4cb6 | 2014-02-07 13:03:27 +0000 | [diff] [blame] | 57 | |
Matthew Treinish | ff59848 | 2014-02-28 16:13:58 -0500 | [diff] [blame] | 58 | class FakePrivate(config.TempestConfigPrivate): |
Joe Gordon | 28a84ae | 2014-07-17 15:38:28 +0000 | [diff] [blame] | 59 | def __init__(self, parse_conf=True, config_path=None): |
Matthew Treinish | ff59848 | 2014-02-28 16:13:58 -0500 | [diff] [blame] | 60 | self._set_attrs() |
Johan Pas | 0ae551f | 2015-12-28 22:44:04 +0100 | [diff] [blame] | 61 | self.lock_path = cfg.CONF.oslo_concurrency.lock_path |
Andrea Frittoli (andreaf) | de5fb0c | 2016-06-13 12:15:00 +0100 | [diff] [blame] | 62 | |
Stephen Finucane | 7f4a621 | 2018-07-06 13:58:21 +0100 | [diff] [blame] | 63 | |
Andrea Frittoli (andreaf) | de5fb0c | 2016-06-13 12:15:00 +0100 | [diff] [blame] | 64 | fake_service1_group = cfg.OptGroup(name='fake-service1', title='Fake service1') |
| 65 | |
| 66 | FakeService1Group = [ |
| 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 | |
| 73 | fake_service2_group = cfg.OptGroup(name='fake-service2', title='Fake service2') |
| 74 | |
| 75 | FakeService2Group = [ |
| 76 | cfg.StrOpt('catalog_type', default='fake-service2'), |
| 77 | cfg.StrOpt('endpoint_type', default='faketype')] |
| 78 | |
| 79 | |
| 80 | class 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 Mellado | cad3f3d | 2016-08-19 14:17:16 +0000 | [diff] [blame] | 95 | group='identity') |
Andrea Frittoli (andreaf) | de5fb0c | 2016-06-13 12:15:00 +0100 | [diff] [blame] | 96 | self.conf.set_default('ca_certificates_file', '/fake/certificates', |
Daniel Mellado | cad3f3d | 2016-08-19 14:17:16 +0000 | [diff] [blame] | 97 | group='identity') |
Andrea Frittoli (andreaf) | de5fb0c | 2016-06-13 12:15:00 +0100 | [diff] [blame] | 98 | self.conf.set_default('region', 'fake_region', 'identity') |
Andrea Frittoli (andreaf) | de5fb0c | 2016-06-13 12:15:00 +0100 | [diff] [blame] | 99 | # 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 | |
| 104 | class 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) | de5fb0c | 2016-06-13 12:15:00 +0100 | [diff] [blame] | 109 | self.lock_path = cfg.CONF.oslo_concurrency.lock_path |