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') |
| 35 | self.conf.set_default('disable_ssl_certificate_validation', True, |
Daniel Mellado | cad3f3d | 2016-08-19 14:17:16 +0000 | [diff] [blame] | 36 | group='identity') |
Matthew Treinish | ff59848 | 2014-02-28 16:13:58 -0500 | [diff] [blame] | 37 | self.conf.set_default('uri', 'http://fake_uri.com/auth', |
| 38 | group='identity') |
| 39 | self.conf.set_default('uri_v3', 'http://fake_uri_v3.com/auth', |
| 40 | group='identity') |
| 41 | self.conf.set_default('neutron', True, group='service_available') |
| 42 | self.conf.set_default('heat', True, group='service_available') |
Matthew Treinish | 827a6fb | 2014-03-20 19:30:08 +0000 | [diff] [blame] | 43 | if not os.path.exists(str(os.environ.get('OS_TEST_LOCK_PATH'))): |
| 44 | os.mkdir(str(os.environ.get('OS_TEST_LOCK_PATH'))) |
Doug Hellmann | 583ce2c | 2015-03-11 14:55:46 +0000 | [diff] [blame] | 45 | lockutils.set_defaults( |
| 46 | lock_path=str(os.environ.get('OS_TEST_LOCK_PATH')), |
| 47 | ) |
Andrea Frittoli | 7d707a5 | 2014-04-06 11:46:32 +0100 | [diff] [blame] | 48 | self.conf.set_default('auth_version', 'v2', group='identity') |
Sean Dague | ed6e586 | 2016-04-04 10:49:13 -0400 | [diff] [blame] | 49 | for config_option in ['username', 'password', 'project_name']: |
Andrea Frittoli | 7d707a5 | 2014-04-06 11:46:32 +0100 | [diff] [blame] | 50 | # Identity group items |
Matthew Treinish | 40847ac | 2016-01-04 13:16:03 -0500 | [diff] [blame] | 51 | self.conf.set_default('admin_' + config_option, |
| 52 | 'fake_' + config_option, |
| 53 | group='auth') |
Mauro S. M. Rodrigues | dbe4cb6 | 2014-02-07 13:03:27 +0000 | [diff] [blame] | 54 | |
Mauro S. M. Rodrigues | dbe4cb6 | 2014-02-07 13:03:27 +0000 | [diff] [blame] | 55 | |
Matthew Treinish | ff59848 | 2014-02-28 16:13:58 -0500 | [diff] [blame] | 56 | class FakePrivate(config.TempestConfigPrivate): |
Joe Gordon | 28a84ae | 2014-07-17 15:38:28 +0000 | [diff] [blame] | 57 | def __init__(self, parse_conf=True, config_path=None): |
Matthew Treinish | ff59848 | 2014-02-28 16:13:58 -0500 | [diff] [blame] | 58 | self._set_attrs() |
Johan Pas | 0ae551f | 2015-12-28 22:44:04 +0100 | [diff] [blame] | 59 | self.lock_path = cfg.CONF.oslo_concurrency.lock_path |
Andrea Frittoli (andreaf) | de5fb0c | 2016-06-13 12:15:00 +0100 | [diff] [blame] | 60 | |
| 61 | fake_service1_group = cfg.OptGroup(name='fake-service1', title='Fake service1') |
| 62 | |
| 63 | FakeService1Group = [ |
| 64 | cfg.StrOpt('catalog_type', default='fake-service1'), |
| 65 | cfg.StrOpt('endpoint_type', default='faketype'), |
| 66 | cfg.StrOpt('region', default='fake_region'), |
| 67 | cfg.IntOpt('build_timeout', default=99), |
| 68 | cfg.IntOpt('build_interval', default=9)] |
| 69 | |
| 70 | fake_service2_group = cfg.OptGroup(name='fake-service2', title='Fake service2') |
| 71 | |
| 72 | FakeService2Group = [ |
| 73 | cfg.StrOpt('catalog_type', default='fake-service2'), |
| 74 | cfg.StrOpt('endpoint_type', default='faketype')] |
| 75 | |
| 76 | |
| 77 | class ServiceClientsConfigFixture(conf_fixture.Config): |
| 78 | |
| 79 | def __init__(self): |
| 80 | cfg.CONF([], default_config_files=[]) |
| 81 | config._opts.append((fake_service1_group, FakeService1Group)) |
| 82 | config._opts.append((fake_service2_group, FakeService2Group)) |
| 83 | config.register_opts() |
| 84 | super(ServiceClientsConfigFixture, self).__init__() |
| 85 | |
| 86 | def setUp(self): |
| 87 | super(ServiceClientsConfigFixture, self).setUp() |
| 88 | # Debug default values |
| 89 | self.conf.set_default('trace_requests', 'fake_module', 'debug') |
| 90 | # Identity default values |
| 91 | self.conf.set_default('disable_ssl_certificate_validation', True, |
Daniel Mellado | cad3f3d | 2016-08-19 14:17:16 +0000 | [diff] [blame] | 92 | group='identity') |
Andrea Frittoli (andreaf) | de5fb0c | 2016-06-13 12:15:00 +0100 | [diff] [blame] | 93 | self.conf.set_default('ca_certificates_file', '/fake/certificates', |
Daniel Mellado | cad3f3d | 2016-08-19 14:17:16 +0000 | [diff] [blame] | 94 | group='identity') |
Andrea Frittoli (andreaf) | de5fb0c | 2016-06-13 12:15:00 +0100 | [diff] [blame] | 95 | self.conf.set_default('region', 'fake_region', 'identity') |
Andrea Frittoli (andreaf) | de5fb0c | 2016-06-13 12:15:00 +0100 | [diff] [blame] | 96 | # Compute default values |
| 97 | self.conf.set_default('build_interval', 88, group='compute') |
| 98 | self.conf.set_default('build_timeout', 8, group='compute') |
| 99 | |
| 100 | |
| 101 | class ServiceClientsFakePrivate(config.TempestConfigPrivate): |
| 102 | def __init__(self, parse_conf=True, config_path=None): |
| 103 | self._set_attrs() |
| 104 | self.fake_service1 = cfg.CONF['fake-service1'] |
| 105 | self.fake_service2 = cfg.CONF['fake-service2'] |
Andrea Frittoli (andreaf) | de5fb0c | 2016-06-13 12:15:00 +0100 | [diff] [blame] | 106 | self.lock_path = cfg.CONF.oslo_concurrency.lock_path |