blob: c7669b78854fb4a0e79821d0f2476b31f13aaf00 [file] [log] [blame]
ZhiQiang Fan39f97222013-09-20 04:49:44 +08001# Copyright 2012 OpenStack Foundation
Jay Pipes3f981df2012-03-27 18:59:44 -04002# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
Dirk Muellere746fc22013-06-29 16:29:29 +020016from __future__ import print_function
17
Graham Hayes0bfe8bd2017-02-21 19:31:53 +000018import functools
Jay Pipes7f757632011-12-02 15:53:32 -050019import os
Matthew Treinishaa29c7e2015-04-23 16:35:09 -040020import tempfile
Jay Pipes3f981df2012-03-27 18:59:44 -040021
Jordan Pittierbd4361d2017-02-21 21:28:16 +010022import debtcollector.removals
Matthew Treinishaa29c7e2015-04-23 16:35:09 -040023from oslo_concurrency import lockutils
Doug Hellmann583ce2c2015-03-11 14:55:46 +000024from oslo_config import cfg
Doug Hellmann583ce2c2015-03-11 14:55:46 +000025from oslo_log import log as logging
Graham Hayes0bfe8bd2017-02-21 19:31:53 +000026import testtools
Jay Pipes7f757632011-12-02 15:53:32 -050027
Andrea Frittoli (andreaf)de5fb0c2016-06-13 12:15:00 +010028from tempest.lib import exceptions
Andrea Frittoli (andreaf)8420abe2016-07-27 11:47:43 +010029from tempest.lib.services import clients
Matthew Treinisha966d0f2015-07-01 17:37:31 -040030from tempest.test_discover import plugins
31
Daryl Walleck1465d612011-11-02 02:22:15 -050032
Maru Newbyf440c292015-03-31 15:58:47 +000033# TODO(marun) Replace use of oslo_config's global ConfigOpts
34# (cfg.CONF) instance with a local instance (cfg.ConfigOpts()) once
35# the cli tests move to the clients. The cli tests rely on oslo
36# incubator modules that use the global cfg.CONF.
37_CONF = cfg.CONF
38
39
DennyZhang88a2dd82013-10-07 12:55:35 -050040def register_opt_group(conf, opt_group, options):
Andrea Frittoli (andreaf)8def7ca2015-05-13 14:24:19 +010041 if opt_group:
42 conf.register_group(opt_group)
DennyZhang88a2dd82013-10-07 12:55:35 -050043 for opt in options:
Andrea Frittoli (andreaf)8def7ca2015-05-13 14:24:19 +010044 conf.register_opt(opt, group=getattr(opt_group, 'name', None))
DennyZhang88a2dd82013-10-07 12:55:35 -050045
46
Matthew Treinishc791ac42014-07-16 09:15:23 -040047auth_group = cfg.OptGroup(name='auth',
48 title="Options for authentication and credentials")
49
50
51AuthGroup = [
52 cfg.StrOpt('test_accounts_file',
Matthew Treinishc791ac42014-07-16 09:15:23 -040053 help="Path to the yaml file that contains the list of "
Matthew Treinishfc7cd8f2015-03-30 11:51:55 -040054 "credentials to use for running tests. If used when "
55 "running in parallel you have to make sure sufficient "
56 "credentials are provided in the accounts file. For "
57 "example if no tests with roles are being run it requires "
58 "at least `2 * CONC` distinct accounts configured in "
59 " the `test_accounts_file`, with CONC == the "
60 "number of concurrent test processes."),
Andrea Frittoli (andreaf)17209bb2015-05-22 10:16:57 -070061 cfg.BoolOpt('use_dynamic_credentials',
Attila Fazekas5dda1582015-02-18 17:16:02 +010062 default=True,
Sean Dagueed6e5862016-04-04 10:49:13 -040063 help="Allows test cases to create/destroy projects and "
Andrea Frittoli8283b4e2014-07-17 13:28:58 +010064 "users. This option requires that OpenStack Identity "
65 "API admin credentials are known. If false, isolated "
66 "test cases and parallel execution, can still be "
67 "achieved configuring a list of test accounts",
68 deprecated_opts=[cfg.DeprecatedOpt('allow_tenant_isolation',
Andrea Frittoli (andreaf)17209bb2015-05-22 10:16:57 -070069 group='auth'),
70 cfg.DeprecatedOpt('allow_tenant_isolation',
Andrea Frittoli8283b4e2014-07-17 13:28:58 +010071 group='compute'),
72 cfg.DeprecatedOpt('allow_tenant_isolation',
73 group='orchestration')]),
Matthew Treinish167b2be2015-01-15 17:20:27 -050074 cfg.ListOpt('tempest_roles',
75 help="Roles to assign to all users created by tempest",
Andrea Frittolic3280152015-02-26 12:42:34 +000076 default=[]),
David Kranz87fc7e92015-07-28 14:05:20 -040077 cfg.StrOpt('default_credentials_domain_name',
78 default='Default',
79 help="Default domain used when getting v3 credentials. "
80 "This is the name keystone uses for v2 compatibility.",
81 deprecated_opts=[cfg.DeprecatedOpt(
82 'tenant_isolation_domain_name',
83 group='auth')]),
Matthew Treinish2219d382015-04-24 10:33:04 -040084 cfg.BoolOpt('create_isolated_networks',
85 default=True,
Andrea Frittoli (andreaf)17209bb2015-05-22 10:16:57 -070086 help="If use_dynamic_credentials is set to True and Neutron "
87 "is enabled Tempest will try to create a usable network, "
Sean Dagueed6e5862016-04-04 10:49:13 -040088 "subnet, and router when needed for each project it "
Matthew Treinish2219d382015-04-24 10:33:04 -040089 "creates. However in some neutron configurations, like "
90 "with VLAN provider networks, this doesn't work. So if "
91 "set to False the isolated networks will not be created"),
Matthew Treinish16cf1e52015-08-11 10:39:23 -040092 cfg.StrOpt('admin_username',
93 help="Username for an administrative user. This is needed for "
Sean Dagueed6e5862016-04-04 10:49:13 -040094 "authenticating requests made by project isolation to "
Matthew Treinish16cf1e52015-08-11 10:39:23 -040095 "create users and projects",
96 deprecated_group='identity'),
Sean Dagueed6e5862016-04-04 10:49:13 -040097 cfg.StrOpt('admin_project_name',
Ken'ichi Ohmichi79a71ac2016-04-22 20:02:51 -070098 help="Project name to use for an administrative user. This is "
Sean Dagueed6e5862016-04-04 10:49:13 -040099 "needed for authenticating requests made by project "
Matthew Treinish16cf1e52015-08-11 10:39:23 -0400100 "isolation to create users and projects",
Sean Dagueed6e5862016-04-04 10:49:13 -0400101 deprecated_opts=[cfg.DeprecatedOpt('admin_tenant_name',
102 group='auth'),
103 cfg.DeprecatedOpt('admin_tenant_name',
104 group='identity')]),
Matthew Treinish16cf1e52015-08-11 10:39:23 -0400105 cfg.StrOpt('admin_password',
Ken'ichi Ohmichi79a71ac2016-04-22 20:02:51 -0700106 help="Password to use for an administrative user. This is "
Sean Dagueed6e5862016-04-04 10:49:13 -0400107 "needed for authenticating requests made by project "
Matthew Treinish16cf1e52015-08-11 10:39:23 -0400108 "isolation to create users and projects",
109 secret=True,
110 deprecated_group='identity'),
111 cfg.StrOpt('admin_domain_name',
112 help="Admin domain name for authentication (Keystone V3)."
113 "The same domain applies to user and project",
114 deprecated_group='identity'),
Matthew Treinishc791ac42014-07-16 09:15:23 -0400115]
116
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500117identity_group = cfg.OptGroup(name='identity',
118 title="Keystone Configuration Options")
Daryl Walleck1465d612011-11-02 02:22:15 -0500119
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500120IdentityGroup = [
121 cfg.StrOpt('catalog_type',
122 default='identity',
123 help="Catalog type of the Identity service."),
Daniel Melladocad3f3d2016-08-19 14:17:16 +0000124 cfg.BoolOpt('disable_ssl_certificate_validation',
125 default=False,
126 help="Set to True if using self-signed SSL certificates."),
127 cfg.StrOpt('ca_certificates_file',
128 default=None,
129 help='Specify a CA bundle file to use in verifying a '
130 'TLS (https) server certificate.'),
Jay Pipes7c88eb22013-01-16 21:32:43 -0500131 cfg.StrOpt('uri',
Brant Knudsonc7ca3342013-03-28 21:08:50 -0500132 help="Full URI of the OpenStack Identity API (Keystone), v2"),
133 cfg.StrOpt('uri_v3',
134 help='Full URI of the OpenStack Identity API (Keystone), v3'),
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000135 cfg.StrOpt('auth_version',
Ken'ichi Ohmichia6065a62017-03-03 16:40:22 -0800136 default='v3',
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000137 help="Identity API version to be used for authentication "
Andrea Frittoli77f9da42014-02-06 11:18:19 +0000138 "for API tests."),
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500139 cfg.StrOpt('region',
Attila Fazekascadcb1f2013-01-21 23:10:53 +0100140 default='RegionOne',
Arata Notsu8f440392013-09-13 16:14:20 +0900141 help="The identity region name to use. Also used as the other "
142 "services' region name unless they are set explicitly. "
143 "If no such region is found in the service catalog, the "
144 "first found one is used."),
Jane Zadorozhnac7862132015-07-10 14:34:50 +0300145 cfg.StrOpt('v2_admin_endpoint_type',
146 default='adminURL',
147 choices=['public', 'admin', 'internal',
148 'publicURL', 'adminURL', 'internalURL'],
149 help="The admin endpoint type to use for OpenStack Identity "
ghanshyamf58b9fd2015-09-01 16:11:39 +0900150 "(Keystone) API v2"),
Jane Zadorozhnac7862132015-07-10 14:34:50 +0300151 cfg.StrOpt('v2_public_endpoint_type',
JordanP5d29b2c2013-12-18 13:56:03 +0000152 default='publicURL',
153 choices=['public', 'admin', 'internal',
154 'publicURL', 'adminURL', 'internalURL'],
Jane Zadorozhnac7862132015-07-10 14:34:50 +0300155 help="The public endpoint type to use for OpenStack Identity "
156 "(Keystone) API v2",
157 deprecated_opts=[cfg.DeprecatedOpt('endpoint_type',
158 group='identity')]),
159 cfg.StrOpt('v3_endpoint_type',
160 default='adminURL',
161 choices=['public', 'admin', 'internal',
162 'publicURL', 'adminURL', 'internalURL'],
163 help="The endpoint type to use for OpenStack Identity "
ghanshyamf58b9fd2015-09-01 16:11:39 +0900164 "(Keystone) API v3"),
Russell Sim7f894a52013-09-13 10:35:21 +1000165 cfg.StrOpt('admin_role',
166 default='admin',
167 help="Role required to administrate keystone."),
Martin Pavlasek4c3f2ab2014-04-15 17:15:15 +0200168 cfg.StrOpt('default_domain_id',
169 default='default',
170 help="ID of the default domain"),
Andrea Frittoli (andreaf)100d18d2016-05-05 23:34:52 +0100171 cfg.BoolOpt('admin_domain_scope',
172 default=False,
173 help="Whether keystone identity v3 policy required "
Rodrigo Duarte Sousa2d78e8e2016-09-28 10:38:08 -0300174 "a domain scoped token to use admin APIs"),
175 # Security Compliance (PCI-DSS)
176 cfg.IntOpt('user_lockout_failure_attempts',
177 default=2,
178 help="The number of unsuccessful login attempts the user is "
179 "allowed before having the account locked."),
180 cfg.IntOpt('user_lockout_duration',
181 default=5,
182 help="The number of seconds a user account will remain "
183 "locked."),
184 cfg.IntOpt('user_unique_last_password_count',
185 default=2,
186 help="The number of passwords for a user that must be unique "
187 "before an old password can be reused."),
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500188]
Jay Pipes3f981df2012-03-27 18:59:44 -0400189
zhufl071e94c2016-07-12 10:26:34 +0800190service_clients_group = cfg.OptGroup(name='service-clients',
191 title="Service Clients Options")
192
193ServiceClientsGroup = [
194 cfg.IntOpt('http_timeout',
195 default=60,
196 help='Timeout in seconds to wait for the http request to '
197 'return'),
198]
199
Matthew Treinishd5021a72014-01-09 18:42:51 +0000200identity_feature_group = cfg.OptGroup(name='identity-feature-enabled',
201 title='Enabled Identity Features')
202
203IdentityFeatureGroup = [
204 cfg.BoolOpt('trust',
205 default=True,
206 help='Does the identity service have delegation and '
Matthew Treinishdb2c5972014-01-31 22:18:59 +0000207 'impersonation enabled'),
208 cfg.BoolOpt('api_v2',
209 default=True,
210 help='Is the v2 identity API enabled'),
211 cfg.BoolOpt('api_v3',
212 default=True,
213 help='Is the v3 identity API enabled'),
Jane Zadorozhna121576d2015-06-23 12:57:13 +0300214 cfg.ListOpt('api_extensions',
215 default=['all'],
216 help="A list of enabled identity extensions with a special "
217 "entry all which indicates every extension is enabled. "
218 "Empty list indicates all extensions are disabled. "
Rodrigo Duarte4ee6b912016-02-26 17:52:25 -0300219 "To get the list of extensions run: 'keystone discover'"),
220 # TODO(rodrigods): Remove the reseller flag when Kilo and Liberty is end
221 # of life.
222 cfg.BoolOpt('reseller',
Jordan Pittiercf6a0352017-01-04 18:34:52 +0100223 default=True,
224 help='Does the environment support reseller?',
225 deprecated_for_removal=True,
Jordan Pittieree880412017-03-15 14:00:23 +0100226 deprecated_reason="All supported versions of OpenStack now "
227 "support the 'reseller' feature"),
Rodrigo Duarte Sousa592148c2017-01-31 15:26:16 -0300228 # TODO(rodrigods): This is a feature flag for bug 1590578 which is fixed
229 # in Newton and Ocata. This option can be removed after Mitaka is end of
230 # life.
231 cfg.BoolOpt('forbid_global_implied_dsr',
232 default=False,
233 help='Does the environment forbid global roles implying '
234 'domain specific ones?'),
Rodrigo Duarte Sousa2d78e8e2016-09-28 10:38:08 -0300235 cfg.BoolOpt('security_compliance',
236 default=False,
237 help='Does the environment have the security compliance '
238 'settings enabled?')
Matthew Treinishd5021a72014-01-09 18:42:51 +0000239]
240
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500241compute_group = cfg.OptGroup(name='compute',
242 title='Compute Service Options')
Rohit Karajgie1b050d2011-12-02 16:13:18 -0800243
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500244ComputeGroup = [
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500245 cfg.StrOpt('image_ref',
Matthew Treinishafcb6b42014-05-27 13:50:02 -0400246 help="Valid primary image reference to be used in tests. "
247 "This is a required option"),
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500248 cfg.StrOpt('image_ref_alt',
Matthew Treinishafcb6b42014-05-27 13:50:02 -0400249 help="Valid secondary image reference to be used in tests. "
250 "This is a required option, but if only one image is "
251 "available duplicate the value of image_ref above"),
Ken'ichi Ohmichi35772602013-11-14 15:03:27 +0900252 cfg.StrOpt('flavor_ref',
253 default="1",
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500254 help="Valid primary flavor to use in tests."),
Ken'ichi Ohmichi35772602013-11-14 15:03:27 +0900255 cfg.StrOpt('flavor_ref_alt',
256 default="2",
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500257 help='Valid secondary flavor to be used in tests.'),
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500258 cfg.IntOpt('build_interval',
Sean Dague82190852014-05-24 07:42:59 -0400259 default=1,
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500260 help="Time in seconds between build status checks."),
261 cfg.IntOpt('build_timeout',
262 default=300,
Hugh Saunders5b139ad2014-12-15 09:08:41 +0000263 help="Timeout in seconds to wait for an instance to build. "
264 "Other services that do not define build_timeout will "
Lucian Petrut1cfe2982015-01-06 13:57:36 +0200265 "inherit this value."),
Attila Fazekas0abbc952013-07-01 19:19:42 +0200266 cfg.IntOpt('ready_wait',
267 default=0,
DennyZhang8912d012013-09-25 18:08:34 -0500268 help="Additional wait time for clean state, when there is "
269 "no OS-EXT-STS extension available"),
Attila Fazekasb0661652013-05-08 13:01:36 +0200270 cfg.StrOpt('fixed_network_name',
Chris Hoge8f1401b2014-11-19 14:00:37 -0800271 help="Name of the fixed network that is visible to all test "
Sean Dagueed6e5862016-04-04 10:49:13 -0400272 "projects. If multiple networks are available for a "
273 "project, this is the network which will be used for "
274 "creating servers if tempest does not create a network or "
zhufl0bad33e2016-10-14 17:21:46 +0800275 "a network is not specified elsewhere. It may be used for "
Joseph Lanoux2f81cc12015-01-12 16:01:20 +0000276 "ssh validation only if floating IPs are disabled."),
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500277 cfg.StrOpt('catalog_type',
278 default='compute',
279 help="Catalog type of the Compute service."),
Arata Notsu8f440392013-09-13 16:14:20 +0900280 cfg.StrOpt('region',
281 default='',
282 help="The compute region name to use. If empty, the value "
283 "of identity.region is used instead. If no such region "
284 "is found in the service catalog, the first found one is "
285 "used."),
JordanP5d29b2c2013-12-18 13:56:03 +0000286 cfg.StrOpt('endpoint_type',
287 default='publicURL',
288 choices=['public', 'admin', 'internal',
289 'publicURL', 'adminURL', 'internalURL'],
290 help="The endpoint type to use for the compute service."),
Ryan Hsucb2e1252013-09-03 21:44:49 -0700291 cfg.StrOpt('volume_device_name',
292 default='vdb',
293 help="Expected device name when a volume is attached to "
Kevin_Zheng79ec3342017-03-25 17:33:27 +0800294 "an instance. Not all hypervisors guarantee that they "
295 "will respect the user defined device name, tests may "
296 "fail if inappropriate device name is set."),
Ken'ichi Ohmichi39437e22013-10-06 00:21:38 +0900297 cfg.IntOpt('shelved_offload_time',
298 default=0,
299 help='Time in seconds before a shelved instance is eligible '
300 'for removing from a host. -1 never offload, 0 offload '
301 'when shelved. This time should be the same as the time '
302 'of nova.conf, and some tests will run for as long as the '
Ghanshyam06a5b4a2014-04-11 17:32:45 +0900303 'time.'),
Sean Dague782f6772015-11-11 11:26:45 -0500304 cfg.IntOpt('min_compute_nodes',
305 default=1,
306 help=('The minimum number of compute nodes expected. This will '
307 'be utilized by some multinode specific tests to ensure '
308 'that requests match the expected size of the cluster '
ghanshyam29591532016-03-11 17:12:43 +0900309 'you are testing with.')),
Ken'ichi Ohmichi49db4fe2016-08-12 15:26:51 -0700310 cfg.StrOpt('hypervisor_type',
311 default=None,
312 help="Hypervisor type of the test target on heterogeneous "
313 "compute environment. The value can be 'QEMU', 'xen' or "
314 "something."),
Ken'ichi Ohmichi4d237e72015-11-05 06:32:33 +0000315 cfg.StrOpt('min_microversion',
316 default=None,
317 help="Lower version of the test target microversion range. "
318 "The format is 'X.Y', where 'X' and 'Y' are int values. "
319 "Tempest selects tests based on the range between "
320 "min_microversion and max_microversion. "
Ghanshyam395c5b52015-12-04 17:27:16 +0900321 "If both values are not specified, Tempest avoids tests "
322 "which require a microversion. Valid values are string "
ghanshyam8889d2b2017-02-14 02:29:06 +0000323 "with format 'X.Y' or string 'latest'"),
Ken'ichi Ohmichi4d237e72015-11-05 06:32:33 +0000324 cfg.StrOpt('max_microversion',
325 default=None,
326 help="Upper version of the test target microversion range. "
327 "The format is 'X.Y', where 'X' and 'Y' are int values. "
328 "Tempest selects tests based on the range between "
329 "min_microversion and max_microversion. "
Ghanshyam395c5b52015-12-04 17:27:16 +0900330 "If both values are not specified, Tempest avoids tests "
331 "which require a microversion. Valid values are string "
ghanshyam8889d2b2017-02-14 02:29:06 +0000332 "with format 'X.Y' or string 'latest'"),
ghanshyam29591532016-03-11 17:12:43 +0900333]
334
335compute_features_group = cfg.OptGroup(name='compute-feature-enabled',
336 title="Enabled Compute Service Features")
337
338ComputeFeaturesGroup = [
Markus Zoeller156b5da2016-07-11 18:10:31 +0200339 # NOTE(mriedem): This is a feature toggle for bug 1175464 which is fixed in
340 # mitaka and newton. This option can be removed after liberty-eol.
341 cfg.BoolOpt('allow_port_security_disabled',
Jordan Pittierb2926fc2017-01-04 17:40:08 +0100342 default=True,
Markus Zoeller156b5da2016-07-11 18:10:31 +0200343 help='Does the test environment support creating ports in a '
Jordan Pittierb2926fc2017-01-04 17:40:08 +0100344 'network where port security is disabled?',
345 deprecated_for_removal=True,
346 deprecated_reason='This config switch was added for Liberty '
347 'which is not supported anymore.'),
Matthew Treinishd5c96022013-10-17 21:51:23 +0000348 cfg.BoolOpt('disk_config',
349 default=True,
350 help="If false, skip disk config tests"),
Matthew Treinishe3d26142013-11-26 19:14:58 +0000351 cfg.ListOpt('api_extensions',
352 default=['all'],
Zhi Kun Liude25c022014-02-14 13:25:19 +0800353 help='A list of enabled compute extensions with a special '
Ken'ichi Ohmichia7e68712014-05-06 10:47:26 +0900354 'entry all which indicates every extension is enabled. '
Simeon Monov5d7effe2014-07-16 07:32:38 +0300355 'Each extension should be specified with alias name. '
Matthew Treinish5078e8b2016-09-16 11:13:11 -0400356 'Empty list indicates all extensions are disabled',
357 deprecated_for_removal=True,
358 deprecated_reason='The Nova extensions API and mechanism '
359 'is deprecated. This option will be '
360 'removed when all releases supported '
361 'by tempest no longer contain the Nova '
362 'extensions API and mechanism.'),
Matthew Treinishd5c96022013-10-17 21:51:23 +0000363 cfg.BoolOpt('change_password',
364 default=False,
365 help="Does the test environment support changing the admin "
366 "password?"),
Adam Gandelmanc6eefb42014-07-15 16:44:08 -0700367 cfg.BoolOpt('console_output',
368 default=True,
369 help="Does the test environment support obtaining instance "
370 "serial console output?"),
Matthew Treinishd5c96022013-10-17 21:51:23 +0000371 cfg.BoolOpt('resize',
372 default=False,
373 help="Does the test environment support resizing?"),
Eric Windischb5538072014-03-09 23:47:35 -0400374 cfg.BoolOpt('pause',
375 default=True,
376 help="Does the test environment support pausing?"),
David Shrewsbury25f666f2014-07-22 12:17:59 -0400377 cfg.BoolOpt('shelve',
378 default=True,
379 help="Does the test environment support shelving/unshelving?"),
Eric Windischaeb7e842014-03-10 01:10:50 -0400380 cfg.BoolOpt('suspend',
381 default=True,
382 help="Does the test environment support suspend/resume?"),
Ludovic Beliveauae314882016-09-15 13:34:14 -0400383 cfg.BoolOpt('cold_migration',
384 default=True,
zhufl0bad33e2016-10-14 17:21:46 +0800385 help="Does the test environment support cold migration?"),
Matthew Treinishd5c96022013-10-17 21:51:23 +0000386 cfg.BoolOpt('live_migration',
Joe Gordon31a139a2014-11-17 16:39:04 -0800387 default=True,
zhufl0bad33e2016-10-14 17:21:46 +0800388 help="Does the test environment support live migration?"),
YAMAMOTO Takashi1f62af22015-06-16 03:29:50 +0900389 cfg.BoolOpt('metadata_service',
390 default=True,
391 help="Does the test environment support metadata service? "
392 "Ignored unless validation.run_validation=true."),
Matthew Treinishd5c96022013-10-17 21:51:23 +0000393 cfg.BoolOpt('block_migration_for_live_migration',
394 default=False,
395 help="Does the test environment use block devices for live "
396 "migration"),
397 cfg.BoolOpt('block_migrate_cinder_iscsi',
398 default=False,
399 help="Does the test environment block migration support "
Joe Gordon0a5788f2015-03-17 11:29:38 -0700400 "cinder iSCSI volumes. Note, libvirt doesn't support this, "
401 "see https://bugs.launchpad.net/nova/+bug/1398999"),
Ghanshyam Mann41c17572014-02-27 18:52:56 +0900402 cfg.BoolOpt('vnc_console',
403 default=False,
404 help='Enable VNC console. This configuration value should '
Ghanshyam70876d02014-03-11 11:40:18 +0900405 'be same as [nova.vnc]->vnc_enabled in nova.conf'),
406 cfg.BoolOpt('spice_console',
407 default=False,
408 help='Enable Spice console. This configuration value should '
409 'be same as [nova.spice]->enabled in nova.conf'),
410 cfg.BoolOpt('rdp_console',
411 default=False,
412 help='Enable RDP console. This configuration value should '
Adam Gandelman2e37b4f2014-06-18 17:34:21 -0700413 'be same as [nova.rdp]->enabled in nova.conf'),
414 cfg.BoolOpt('rescue',
415 default=True,
416 help='Does the test environment support instance rescue '
Ghanshyam9c2e50d2014-07-22 21:32:05 +0900417 'mode?'),
418 cfg.BoolOpt('enable_instance_password',
419 default=True,
420 help='Enables returning of the instance password by the '
421 'relevant server API calls such as create, rebuild '
zhufle8a703b2016-09-09 15:23:03 +0800422 'or rescue. This configuration value should be same as '
423 'nova.conf: DEFAULT.enable_instance_password'),
Adam Gandelman7186f7a2014-07-23 09:28:56 -0400424 cfg.BoolOpt('interface_attach',
425 default=True,
426 help='Does the test environment support dynamic network '
Adam Gandelmanfbc95ac2014-06-19 17:33:43 -0700427 'interface attachment?'),
428 cfg.BoolOpt('snapshot',
429 default=True,
430 help='Does the test environment support creating snapshot '
Matthew Treinishdfd7ac02015-02-09 17:47:31 -0500431 'images of running instances?'),
Takeaki Matsumotodf4ab7c2015-08-25 17:49:23 +0900432 cfg.BoolOpt('nova_cert',
Sean Dague6943acb2016-08-08 15:28:17 -0400433 default=False,
434 help='Does the test environment have the nova cert running?',
Ken'ichi Ohmichid65cf9c2016-11-23 16:56:04 -0800435 deprecated_for_removal=True,
436 deprecated_reason="On Nova side, the nova-cert service is "
437 "deprecated and the service will be removed "
438 "as early as Ocata."),
Takeaki Matsumotod7e04b22015-09-04 15:13:38 +0900439 cfg.BoolOpt('personality',
Matt Riedemann0baba702016-07-03 19:24:08 -0400440 default=False,
Takeaki Matsumotod7e04b22015-09-04 15:13:38 +0900441 help='Does the test environment support server personality'),
Matt Riedemann79b3b492015-06-20 14:20:44 -0700442 cfg.BoolOpt('attach_encrypted_volume',
443 default=True,
444 help='Does the test environment support attaching an '
445 'encrypted volume to a running server instance? This may '
446 'depend on the combination of compute_driver in nova and '
447 'the volume_driver(s) in cinder.'),
Alexander Gubanov509e2842015-06-09 15:29:51 +0300448 cfg.BoolOpt('config_drive',
449 default=True,
450 help='Enable special configuration drive with metadata.'),
Yair Friedca5cfb52016-01-04 15:41:55 +0200451 cfg.ListOpt('scheduler_available_filters',
452 default=['all'],
453 help="A list of enabled filters that nova will accept as hints"
454 " to the scheduler when creating a server. A special "
ghanshyam5817e142016-12-01 11:38:46 +0900455 "entry 'all' indicates all filters that are included "
456 "with nova are enabled. Empty list indicates all filters "
457 "are disabled. The full list of available filters is in "
458 "nova.conf: DEFAULT.scheduler_available_filters. If the "
459 "default value is overridden in nova.conf by the test "
460 "environment (which means that a different set of "
461 "filters is enabled than what is included in Nova by "
462 "default) then, this option must be configured to "
463 "contain the same filters that Nova uses in the test "
464 "environment."),
Matt Riedemann342b37c2016-09-21 15:38:12 -0400465 cfg.BoolOpt('swap_volume',
466 default=False,
467 help='Does the test environment support in-place swapping of '
468 'volumes attached to a server instance?'),
Matthew Treinishd5c96022013-10-17 21:51:23 +0000469]
470
471
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500472image_group = cfg.OptGroup(name='image',
473 title="Image Service Options")
Jay Pipesf38eaac2012-06-21 13:37:35 -0400474
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500475ImageGroup = [
Matthew Treinish72ea4422013-02-07 14:42:49 -0500476 cfg.StrOpt('catalog_type',
477 default='image',
Sean Dague83401992013-05-06 17:46:36 -0400478 help='Catalog type of the Image service.'),
Arata Notsu8f440392013-09-13 16:14:20 +0900479 cfg.StrOpt('region',
480 default='',
481 help="The image region name to use. If empty, the value "
482 "of identity.region is used instead. If no such region "
483 "is found in the service catalog, the first found one is "
484 "used."),
JordanP5d29b2c2013-12-18 13:56:03 +0000485 cfg.StrOpt('endpoint_type',
486 default='publicURL',
487 choices=['public', 'admin', 'internal',
488 'publicURL', 'adminURL', 'internalURL'],
489 help="The endpoint type to use for the image service."),
Sean Dague83401992013-05-06 17:46:36 -0400490 cfg.StrOpt('http_image',
491 default='http://download.cirros-cloud.net/0.3.1/'
492 'cirros-0.3.1-x86_64-uec.tar.gz',
Lucian Petrut1cfe2982015-01-06 13:57:36 +0200493 help='http accessible image'),
494 cfg.IntOpt('build_timeout',
495 default=300,
496 help="Timeout in seconds to wait for an image to "
497 "become available."),
498 cfg.IntOpt('build_interval',
499 default=1,
500 help="Time in seconds between image operation status "
Takashi NATSUME12a48512015-08-10 18:33:16 +0900501 "checks."),
502 cfg.ListOpt('container_formats',
503 default=['ami', 'ari', 'aki', 'bare', 'ovf', 'ova'],
504 help="A list of image's container formats "
505 "users can specify."),
506 cfg.ListOpt('disk_formats',
507 default=['ami', 'ari', 'aki', 'vhd', 'vmdk', 'raw', 'qcow2',
508 'vdi', 'iso'],
509 help="A list of image's disk formats "
510 "users can specify.")
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500511]
Jay Pipesf38eaac2012-06-21 13:37:35 -0400512
Matthew Treinish2b5287d2013-10-22 17:40:34 +0000513image_feature_group = cfg.OptGroup(name='image-feature-enabled',
514 title='Enabled image service features')
515
516ImageFeaturesGroup = [
517 cfg.BoolOpt('api_v2',
518 default=True,
ghanshyam6b0b8b72017-03-08 04:22:53 +0000519 help="Is the v2 image API enabled",
520 deprecated_for_removal=True,
521 deprecated_reason='Glance v1 APIs are deprecated and v2 APIs '
522 'are current one. In future, Tempest will '
523 'test v2 APIs only so this config option '
524 'will be removed.'),
Matthew Treinish2b5287d2013-10-22 17:40:34 +0000525 cfg.BoolOpt('api_v1',
526 default=True,
ghanshyam6b0b8b72017-03-08 04:22:53 +0000527 help="Is the v1 image API enabled",
528 deprecated_for_removal=True,
529 deprecated_reason='Glance v1 APIs are deprecated and v2 APIs '
530 'are current one. In future, Tempest will '
531 'test v2 APIs only so this config option '
532 'will be removed.'),
bkopilov81aaae72015-05-15 23:46:25 +0300533 cfg.BoolOpt('deactivate_image',
534 default=False,
535 help="Is the deactivate-image feature enabled."
Jordan Pittieree880412017-03-15 14:00:23 +0100536 " The feature has been integrated since Kilo.",
537 deprecated_for_removal=True,
538 deprecated_reason="All supported versions of OpenStack now "
539 "support the 'deactivate_image' feature"),
Matthew Treinish2b5287d2013-10-22 17:40:34 +0000540]
Jay Pipesf38eaac2012-06-21 13:37:35 -0400541
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500542network_group = cfg.OptGroup(name='network',
543 title='Network Service Options')
Daryl Walleck587385b2012-03-03 13:00:26 -0600544
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500545NetworkGroup = [
546 cfg.StrOpt('catalog_type',
547 default='network',
Mark McClainf2982e82013-07-06 17:48:03 -0400548 help='Catalog type of the Neutron service.'),
Arata Notsu8f440392013-09-13 16:14:20 +0900549 cfg.StrOpt('region',
550 default='',
551 help="The network region name to use. If empty, the value "
552 "of identity.region is used instead. If no such region "
553 "is found in the service catalog, the first found one is "
554 "used."),
JordanP5d29b2c2013-12-18 13:56:03 +0000555 cfg.StrOpt('endpoint_type',
556 default='publicURL',
557 choices=['public', 'admin', 'internal',
558 'publicURL', 'adminURL', 'internalURL'],
559 help="The endpoint type to use for the network service."),
Sean Dagueed6e5862016-04-04 10:49:13 -0400560 cfg.StrOpt('project_network_cidr',
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500561 default="10.100.0.0/16",
Sean Dagueed6e5862016-04-04 10:49:13 -0400562 help="The cidr block to allocate project ipv4 subnets from"),
563 cfg.IntOpt('project_network_mask_bits',
Attila Fazekas8ea181b2013-07-13 16:26:14 +0200564 default=28,
Sean Dagueed6e5862016-04-04 10:49:13 -0400565 help="The mask bits for project ipv4 subnets"),
566 cfg.StrOpt('project_network_v6_cidr',
Sergey Shnaidman1f3659a2014-08-27 18:26:42 +0400567 default="2003::/48",
Sean Dagueed6e5862016-04-04 10:49:13 -0400568 help="The cidr block to allocate project ipv6 subnets from"),
569 cfg.IntOpt('project_network_v6_mask_bits',
Sergey Shnaidman1f3659a2014-08-27 18:26:42 +0400570 default=64,
Sean Dagueed6e5862016-04-04 10:49:13 -0400571 help="The mask bits for project ipv6 subnets"),
572 cfg.BoolOpt('project_networks_reachable',
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500573 default=False,
Sean Dagueed6e5862016-04-04 10:49:13 -0400574 help="Whether project networks can be reached directly from "
Joseph Lanoux2f81cc12015-01-12 16:01:20 +0000575 "the test client. This must be set to True when the "
Matt Riedemann4b0f7e72016-08-08 15:29:26 -0400576 "'fixed' connect_method is selected."),
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500577 cfg.StrOpt('public_network_id',
578 default="",
579 help="Id of the public network that provides external "
580 "connectivity"),
Joseph Lanoux2f81cc12015-01-12 16:01:20 +0000581 cfg.StrOpt('floating_network_name',
582 help="Default floating network name. Used to allocate floating "
583 "IPs when neutron is enabled."),
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500584 cfg.StrOpt('public_router_id',
585 default="",
586 help="Id of the public router that provides external "
Yair Fried1eb27f52014-11-10 15:24:19 +0200587 "connectivity. This should only be used when Neutron's "
588 "'allow_overlapping_ips' is set to 'False' in "
589 "neutron.conf. usually not needed past 'Grizzly' release"),
izikpensod9a01a62014-02-17 20:02:32 +0200590 cfg.IntOpt('build_timeout',
591 default=300,
592 help="Timeout in seconds to wait for network operation to "
593 "complete."),
594 cfg.IntOpt('build_interval',
Sean Dague82190852014-05-24 07:42:59 -0400595 default=1,
izikpensod9a01a62014-02-17 20:02:32 +0200596 help="Time in seconds between network operation status "
597 "checks."),
Attila Fazekas640392b2014-06-12 15:58:10 +0200598 cfg.ListOpt('dns_servers',
599 default=["8.8.8.8", "8.8.4.4"],
Itzik Brown5be44582014-12-24 09:05:13 +0200600 help="List of dns servers which should be used"
Itzik Brown2ca01cd2014-12-08 12:58:20 +0200601 " for subnet creation"),
602 cfg.StrOpt('port_vnic_type',
603 choices=[None, 'normal', 'direct', 'macvtap'],
604 help="vnic_type to use when Launching instances"
605 " with pre-configured ports."
606 " Supported ports are:"
607 " ['normal','direct','macvtap']"),
piyush11078648e35d52015-09-24 12:56:43 +0530608 cfg.ListOpt('default_network',
609 default=["1.0.0.0/16", "2.0.0.0/16"],
610 help="List of ip pools"
611 " for subnetpools creation"),
Thiago Paiva66cded22016-08-15 14:55:58 -0300612 cfg.BoolOpt('shared_physical_network',
613 default=False,
614 help="The environment does not support network separation "
615 "between tenants."),
Yaroslav Lobankov86b6b742016-09-14 18:44:52 +0300616 # TODO(ylobankov): Delete this option once the Liberty release is EOL.
617 cfg.BoolOpt('dvr_extra_resources',
618 default=True,
619 help="Whether or not to create internal network, subnet, "
620 "port and add network interface to distributed router "
621 "in L3 agent scheduler test. Extra resources need to be "
622 "provisioned in order to bind router to L3 agent in the "
623 "Liberty release or older, and are not required since "
Jordan Pittierd1ef1292017-03-15 13:46:55 +0100624 "the Mitaka release.",
625 deprecated_for_removal=True,
626 deprecated_reason='This config switch was added for Liberty '
627 'which is not supported anymore.')
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500628]
Jay Pipes3f981df2012-03-27 18:59:44 -0400629
Matthew Treinishe3d26142013-11-26 19:14:58 +0000630network_feature_group = cfg.OptGroup(name='network-feature-enabled',
631 title='Enabled network service features')
632
633NetworkFeaturesGroup = [
Matthew Treinishe2e33cf2014-03-03 19:28:41 +0000634 cfg.BoolOpt('ipv6',
635 default=True,
636 help="Allow the execution of IPv6 tests"),
Matthew Treinishe3d26142013-11-26 19:14:58 +0000637 cfg.ListOpt('api_extensions',
638 default=['all'],
Alexander Gubanov36e1f9b2015-06-12 18:02:10 +0300639 help="A list of enabled network extensions with a special "
640 "entry all which indicates every extension is enabled. "
641 "Empty list indicates all extensions are disabled. "
642 "To get the list of extensions run: 'neutron ext-list'"),
Sean M. Collinsdd27a4d2014-05-13 10:33:15 -0400643 cfg.BoolOpt('ipv6_subnet_attributes',
644 default=False,
645 help="Allow the execution of IPv6 subnet tests that use "
646 "the extended IPv6 attributes ipv6_ra_mode "
647 "and ipv6_address_mode"
Mark McClain6e07c0d2014-10-10 11:25:03 -0400648 ),
Itzik Brownbeb30d32015-03-29 09:42:54 +0300649 cfg.BoolOpt('port_admin_state_change',
650 default=True,
651 help="Does the test environment support changing"
652 " port admin state"),
Matt Riedemann039b2fe2016-09-15 16:12:24 -0400653 cfg.BoolOpt('port_security',
654 default=False,
655 help="Does the test environment support port security?"),
Matthew Treinishe3d26142013-11-26 19:14:58 +0000656]
657
Joseph Lanoux2f81cc12015-01-12 16:01:20 +0000658validation_group = cfg.OptGroup(name='validation',
659 title='SSH Validation options')
660
661ValidationGroup = [
Matthew Treinishe5cca002015-05-11 15:36:50 -0400662 cfg.BoolOpt('run_validation',
663 default=False,
664 help='Enable ssh on created servers and creation of additional'
lanoux283273b2015-12-04 03:01:54 -0800665 ' validation resources to enable remote access'),
Brandon Palmc6cc91d2015-08-19 13:20:21 -0500666 cfg.BoolOpt('security_group',
667 default=True,
668 help='Enable/disable security groups.'),
669 cfg.BoolOpt('security_group_rules',
670 default=True,
671 help='Enable/disable security group rules.'),
Joseph Lanoux2f81cc12015-01-12 16:01:20 +0000672 cfg.StrOpt('connect_method',
673 default='floating',
674 choices=['fixed', 'floating'],
675 help='Default IP type used for validation: '
676 '-fixed: uses the first IP belonging to the fixed network '
ghanshyamade71d22017-02-15 05:36:14 +0000677 '-floating: creates and uses a floating IP'),
Joseph Lanoux2f81cc12015-01-12 16:01:20 +0000678 cfg.StrOpt('auth_method',
679 default='keypair',
680 choices=['keypair'],
681 help='Default authentication method to the instance. '
682 'Only ssh via keypair is supported for now. '
ghanshyamade71d22017-02-15 05:36:14 +0000683 'Additional methods will be handled in a separate spec.'),
Joseph Lanoux2f81cc12015-01-12 16:01:20 +0000684 cfg.IntOpt('ip_version_for_ssh',
685 default=4,
lanoux283273b2015-12-04 03:01:54 -0800686 help='Default IP version for ssh connections.'),
Joseph Lanoux2f81cc12015-01-12 16:01:20 +0000687 cfg.IntOpt('ping_timeout',
688 default=120,
lanoux283273b2015-12-04 03:01:54 -0800689 help='Timeout in seconds to wait for ping to succeed.',
690 deprecated_opts=[cfg.DeprecatedOpt('ping_timeout',
691 group='compute')]),
Joseph Lanoux2f81cc12015-01-12 16:01:20 +0000692 cfg.IntOpt('connect_timeout',
693 default=60,
694 help='Timeout in seconds to wait for the TCP connection to be '
lanoux283273b2015-12-04 03:01:54 -0800695 'successful.'),
Joseph Lanoux2f81cc12015-01-12 16:01:20 +0000696 cfg.IntOpt('ssh_timeout',
697 default=300,
lanoux283273b2015-12-04 03:01:54 -0800698 help='Timeout in seconds to wait for the ssh banner.'),
699 cfg.StrOpt('image_ssh_user',
700 default="root",
701 help="User name used to authenticate to an instance.",
702 deprecated_opts=[cfg.DeprecatedOpt('image_ssh_user',
703 group='compute'),
704 cfg.DeprecatedOpt('ssh_user',
705 group='compute'),
706 cfg.DeprecatedOpt('ssh_user',
707 group='scenario')]),
708 cfg.StrOpt('image_ssh_password',
709 default="password",
ghanshyamade71d22017-02-15 05:36:14 +0000710 help="Password used to authenticate to an instance."),
lanoux283273b2015-12-04 03:01:54 -0800711 cfg.StrOpt('ssh_shell_prologue',
712 default="set -eu -o pipefail; PATH=$$PATH:/sbin;",
713 help="Shell fragments to use before executing a command "
ghanshyamade71d22017-02-15 05:36:14 +0000714 "when sshing to a guest."),
lanoux283273b2015-12-04 03:01:54 -0800715 cfg.IntOpt('ping_size',
716 default=56,
717 help="The packet size for ping packets originating "
ghanshyamade71d22017-02-15 05:36:14 +0000718 "from remote linux hosts"),
lanoux283273b2015-12-04 03:01:54 -0800719 cfg.IntOpt('ping_count',
720 default=1,
721 help="The number of ping packets originating from remote "
ghanshyamade71d22017-02-15 05:36:14 +0000722 "linux hosts"),
lanoux283273b2015-12-04 03:01:54 -0800723 cfg.StrOpt('floating_ip_range',
724 default='10.0.0.0/29',
725 help='Unallocated floating IP range, which will be used to '
726 'test the floating IP bulk feature for CRUD operation. '
727 'This block must not overlap an existing floating IP '
ghanshyamade71d22017-02-15 05:36:14 +0000728 'pool.'),
lanoux283273b2015-12-04 03:01:54 -0800729 cfg.StrOpt('network_for_ssh',
730 default='public',
731 help="Network used for SSH connections. Ignored if "
Matt Riedemanna83cd522016-08-08 17:07:50 -0400732 "connect_method=floating.",
lanoux283273b2015-12-04 03:01:54 -0800733 deprecated_opts=[cfg.DeprecatedOpt('network_for_ssh',
nithya-ganesan67da2872015-02-08 23:13:48 +0000734 group='compute')]),
Joseph Lanoux2f81cc12015-01-12 16:01:20 +0000735]
736
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500737volume_group = cfg.OptGroup(name='volume',
738 title='Block Storage Options')
Daryl Walleck587385b2012-03-03 13:00:26 -0600739
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500740VolumeGroup = [
741 cfg.IntOpt('build_interval',
Sean Dague82190852014-05-24 07:42:59 -0400742 default=1,
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500743 help='Time in seconds between volume availability checks.'),
744 cfg.IntOpt('build_timeout',
745 default=300,
Eric Harney9b1f89c2014-10-14 14:40:19 -0400746 help='Timeout in seconds to wait for a volume to become '
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500747 'available.'),
748 cfg.StrOpt('catalog_type',
Matthew Treinisheb724512013-10-25 15:12:59 +0000749 default='volume',
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500750 help="Catalog type of the Volume Service"),
Arata Notsu8f440392013-09-13 16:14:20 +0900751 cfg.StrOpt('region',
752 default='',
753 help="The volume region name to use. If empty, the value "
754 "of identity.region is used instead. If no such region "
755 "is found in the service catalog, the first found one is "
756 "used."),
JordanP5d29b2c2013-12-18 13:56:03 +0000757 cfg.StrOpt('endpoint_type',
758 default='publicURL',
759 choices=['public', 'admin', 'internal',
760 'publicURL', 'adminURL', 'internalURL'],
761 help="The endpoint type to use for the volume service."),
Benny Kopilovaf136a92015-11-10 07:37:23 +0200762 cfg.ListOpt('backend_names',
763 default=['BACKEND_1', 'BACKEND_2'],
april4be58dc2015-12-29 00:07:22 +0800764 help='A list of backend names separated by comma. '
bkopilov27905cc2016-04-12 14:29:13 +0300765 'The backend name must be declared in cinder.conf'),
Adam Gandelman827ad332013-06-24 17:04:09 -0700766 cfg.StrOpt('storage_protocol',
767 default='iSCSI',
768 help='Backend protocol to target when creating volume types'),
769 cfg.StrOpt('vendor_name',
770 default='Open Source',
771 help='Backend vendor to target when creating volume types'),
Ryan Hsua67f4632013-08-29 16:03:06 -0700772 cfg.StrOpt('disk_format',
773 default='raw',
774 help='Disk format to use when copying a volume to image'),
Jerry Cai9733d0e2014-03-19 15:50:49 +0800775 cfg.IntOpt('volume_size',
776 default=1,
777 help='Default size in GB for volumes created by volumes tests'),
jeremy.zhangf4fbf302017-03-22 11:25:53 +0800778 cfg.ListOpt('manage_volume_ref',
779 default=['source-name', 'volume-%s'],
780 help="A reference to existing volume for volume manage. "
781 "It contains two elements, the first is ref type "
782 "(like 'source-name', 'source-id', etc), the second is "
783 "volume name template used in storage backend"),
Andrew Kerrfcb0b682016-04-01 16:01:34 -0400784 cfg.StrOpt('min_microversion',
785 default=None,
786 help="Lower version of the test target microversion range. "
787 "The format is 'X.Y', where 'X' and 'Y' are int values. "
788 "Tempest selects tests based on the range between "
789 "min_microversion and max_microversion. "
790 "If both values are not specified, Tempest avoids tests "
791 "which require a microversion. Valid values are string "
792 "with format 'X.Y' or string 'latest'",),
793 cfg.StrOpt('max_microversion',
794 default=None,
795 help="Upper version of the test target microversion range. "
796 "The format is 'X.Y', where 'X' and 'Y' are int values. "
797 "Tempest selects tests based on the range between "
798 "min_microversion and max_microversion. "
799 "If both values are not specified, Tempest avoids tests "
800 "which require a microversion. Valid values are string "
801 "with format 'X.Y' or string 'latest'",),
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500802]
K Jonathan Harkerd6ba4b42012-12-18 13:50:47 -0800803
Matthew Treinishd5c96022013-10-17 21:51:23 +0000804volume_feature_group = cfg.OptGroup(name='volume-feature-enabled',
805 title='Enabled Cinder Features')
806
807VolumeFeaturesGroup = [
808 cfg.BoolOpt('multi_backend',
809 default=False,
Matthew Treinishe3d26142013-11-26 19:14:58 +0000810 help="Runs Cinder multi-backend test (requires 2 backends)"),
Giulio Fidente74b08ad2014-01-18 04:02:51 +0100811 cfg.BoolOpt('backup',
812 default=True,
813 help='Runs Cinder volumes backup test'),
JordanPbce55532014-03-19 12:10:32 +0100814 cfg.BoolOpt('snapshot',
815 default=True,
816 help='Runs Cinder volume snapshot test'),
Takeaki Matsumoto1702aed2015-08-25 08:44:26 +0900817 cfg.BoolOpt('clone',
818 default=True,
819 help='Runs Cinder volume clone test'),
Jordan Pittier31256252017-01-11 14:29:49 +0100820 cfg.BoolOpt('manage_snapshot',
821 default=False,
822 help='Runs Cinder manage snapshot tests'),
jeremy.zhangf4fbf302017-03-22 11:25:53 +0800823 cfg.BoolOpt('manage_volume',
824 default=False,
825 help='Runs Cinder manage volume tests'),
Matthew Treinishe3d26142013-11-26 19:14:58 +0000826 cfg.ListOpt('api_extensions',
827 default=['all'],
Zhi Kun Liude25c022014-02-14 13:25:19 +0800828 help='A list of enabled volume extensions with a special '
Simeon Monov5d7effe2014-07-16 07:32:38 +0300829 'entry all which indicates every extension is enabled. '
830 'Empty list indicates all extensions are disabled'),
Zhi Kun Liubb363a22013-11-28 18:47:39 +0800831 cfg.BoolOpt('api_v1',
Ken'ichi Ohmichi7a0811e2017-03-15 17:32:09 -0700832 default=False,
833 help="Is the v1 volume API enabled",
834 deprecated_for_removal=True,
835 deprecated_reason="The v1 volume API has been deprecated "
836 "since Juno release, and the API will be "
837 "removed."),
Zhi Kun Liu8cc3c842014-01-07 10:44:34 +0800838 cfg.BoolOpt('api_v2',
839 default=True,
840 help="Is the v2 volume API enabled"),
Andrew Kerrfcb0b682016-04-01 16:01:34 -0400841 cfg.BoolOpt('api_v3',
842 default=False,
Sean McGinnis6d84d312017-02-25 19:48:37 -0600843 help="Is the v3 volume API enabled")
Matthew Treinishd5c96022013-10-17 21:51:23 +0000844]
845
Daryl Walleck587385b2012-03-03 13:00:26 -0600846
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500847object_storage_group = cfg.OptGroup(name='object-storage',
848 title='Object Storage Service Options')
Attila Fazekasa23f5002012-10-23 19:32:45 +0200849
DennyZhang1e71b612013-09-26 12:35:40 -0500850ObjectStoreGroup = [
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500851 cfg.StrOpt('catalog_type',
852 default='object-store',
853 help="Catalog type of the Object-Storage service."),
Arata Notsu8f440392013-09-13 16:14:20 +0900854 cfg.StrOpt('region',
855 default='',
856 help="The object-storage region name to use. If empty, the "
857 "value of identity.region is used instead. If no such "
858 "region is found in the service catalog, the first found "
859 "one is used."),
JordanP5d29b2c2013-12-18 13:56:03 +0000860 cfg.StrOpt('endpoint_type',
861 default='publicURL',
862 choices=['public', 'admin', 'internal',
863 'publicURL', 'adminURL', 'internalURL'],
864 help="The endpoint type to use for the object-store service."),
Matthew Treinishf319a732013-10-24 21:39:24 +0000865 cfg.IntOpt('container_sync_timeout',
Daisuke Morita1ac3ee02014-08-25 12:59:18 +0900866 default=600,
Fabien Boucher2178d312013-12-31 15:38:57 +0100867 help="Number of seconds to time on waiting for a container "
nayna-patelb4989b32013-01-09 06:25:13 +0000868 "to container synchronization complete."),
Matthew Treinishf319a732013-10-24 21:39:24 +0000869 cfg.IntOpt('container_sync_interval',
nayna-patelb4989b32013-01-09 06:25:13 +0000870 default=5,
Fabien Boucher2178d312013-12-31 15:38:57 +0100871 help="Number of seconds to wait while looping to check the "
nayna-patelb4989b32013-01-09 06:25:13 +0000872 "status of a container to container synchronization"),
Matthew Treinish3fdb80c2013-08-15 11:13:19 -0400873 cfg.StrOpt('operator_role',
874 default='Member',
875 help="Role to add to users created for swift tests to "
876 "enable creating containers"),
Matthew Treinish998c91d2014-03-01 12:39:49 -0500877 cfg.StrOpt('reseller_admin_role',
878 default='ResellerAdmin',
879 help="User role that has reseller admin"),
Daisuke Morita1ac3ee02014-08-25 12:59:18 +0900880 cfg.StrOpt('realm_name',
881 default='realm1',
882 help="Name of sync realm. A sync realm is a set of clusters "
883 "that have agreed to allow container syncing with each "
884 "other. Set the same realm name as Swift's "
885 "container-sync-realms.conf"),
886 cfg.StrOpt('cluster_name',
887 default='name1',
888 help="One name of cluster which is set in the realm whose name "
889 "is set in 'realm_name' item in this file. Set the "
890 "same cluster name as Swift's container-sync-realms.conf"),
Matthew Treinish39e48ef2012-12-21 13:36:15 -0500891]
Attila Fazekasa23f5002012-10-23 19:32:45 +0200892
Matthew Treinishd5c96022013-10-17 21:51:23 +0000893object_storage_feature_group = cfg.OptGroup(
894 name='object-storage-feature-enabled',
895 title='Enabled object-storage features')
896
897ObjectStoreFeaturesGroup = [
Matthew Treinish20345382013-12-13 17:04:23 +0000898 cfg.ListOpt('discoverable_apis',
899 default=['all'],
900 help="A list of the enabled optional discoverable apis. "
901 "A single entry, all, indicates that all of these "
902 "features are expected to be enabled"),
Daisuke Morita20a183f2014-08-25 14:43:36 +0900903 cfg.BoolOpt('container_sync',
904 default=True,
905 help="Execute (old style) container-sync tests"),
906 cfg.BoolOpt('object_versioning',
907 default=True,
908 help="Execute object-versioning tests"),
909 cfg.BoolOpt('discoverability',
910 default=True,
911 help="Execute discoverability tests"),
Matthew Treinishd5c96022013-10-17 21:51:23 +0000912]
913
Steve Bakerc60e4e32013-05-06 15:22:41 +1200914orchestration_group = cfg.OptGroup(name='orchestration',
915 title='Orchestration Service Options')
916
917OrchestrationGroup = [
918 cfg.StrOpt('catalog_type',
919 default='orchestration',
920 help="Catalog type of the Orchestration service."),
Arata Notsu8f440392013-09-13 16:14:20 +0900921 cfg.StrOpt('region',
922 default='',
923 help="The orchestration region name to use. If empty, the "
924 "value of identity.region is used instead. If no such "
925 "region is found in the service catalog, the first found "
926 "one is used."),
JordanP5d29b2c2013-12-18 13:56:03 +0000927 cfg.StrOpt('endpoint_type',
928 default='publicURL',
929 choices=['public', 'admin', 'internal',
930 'publicURL', 'adminURL', 'internalURL'],
931 help="The endpoint type to use for the orchestration service."),
Matthew Treinishdb9721d2015-03-18 14:21:28 -0400932 cfg.StrOpt('stack_owner_role', default='heat_stack_owner',
933 help='Role required for users to be able to manage stacks'),
Steve Bakerc60e4e32013-05-06 15:22:41 +1200934 cfg.IntOpt('build_interval',
935 default=1,
936 help="Time in seconds between build status checks."),
937 cfg.IntOpt('build_timeout',
Matthew Treinisha2dfd492014-04-15 11:15:34 -0400938 default=1200,
Steve Bakerc60e4e32013-05-06 15:22:41 +1200939 help="Timeout in seconds to wait for a stack to build."),
Steve Bakerc60e4e32013-05-06 15:22:41 +1200940 cfg.StrOpt('instance_type',
Steve Baker9e86b832013-05-22 15:40:28 +1200941 default='m1.micro',
Steve Bakerc60e4e32013-05-06 15:22:41 +1200942 help="Instance type for tests. Needs to be big enough for a "
943 "full OS plus the test workload"),
Steve Bakerc60e4e32013-05-06 15:22:41 +1200944 cfg.StrOpt('keypair_name',
Steve Bakerc60e4e32013-05-06 15:22:41 +1200945 help="Name of existing keypair to launch servers with."),
Clint Byrum71f27632013-09-09 11:41:32 -0700946 cfg.IntOpt('max_template_size',
Joe Gordon0e51b222013-10-24 14:11:10 +0100947 default=524288,
Clint Byrum71f27632013-09-09 11:41:32 -0700948 help="Value must match heat configuration of the same name."),
Steven Hardyfdc6bd72014-03-21 16:56:04 +0000949 cfg.IntOpt('max_resources_per_stack',
950 default=1000,
951 help="Value must match heat configuration of the same name."),
Steve Bakerc60e4e32013-05-06 15:22:41 +1200952]
953
Luigi Toscano14d172d2015-01-23 16:37:47 +0100954
Masayuki Igawa73d9f3a2013-05-24 10:30:01 +0900955scenario_group = cfg.OptGroup(name='scenario', title='Scenario Test Options')
956
957ScenarioGroup = [
958 cfg.StrOpt('img_dir',
959 default='/opt/stack/new/devstack/files/images/'
960 'cirros-0.3.1-x86_64-uec',
Matthew Treinish5d5e20a2016-01-14 10:54:30 -0500961 help='Directory containing image files',
962 deprecated_for_removal=True),
Alessandro Pilottib7c1daa2014-08-16 14:24:13 +0300963 cfg.StrOpt('img_file', deprecated_name='qcow2_img_file',
Masayuki Igawa4f71bf02014-02-21 14:02:29 +0900964 default='cirros-0.3.1-x86_64-disk.img',
Alessandro Pilottib7c1daa2014-08-16 14:24:13 +0300965 help='Image file name'),
966 cfg.StrOpt('img_disk_format',
967 default='qcow2',
968 help='Image disk format'),
969 cfg.StrOpt('img_container_format',
970 default='bare',
971 help='Image container format'),
Evgeny Antyshev7ba0d5f2015-04-28 13:18:07 +0000972 cfg.DictOpt('img_properties', help='Glance image properties. '
973 'Use for custom images which require them'),
Masayuki Igawa73d9f3a2013-05-24 10:30:01 +0900974 cfg.StrOpt('ami_img_file',
975 default='cirros-0.3.1-x86_64-blank.img',
Matthew Treinish5d5e20a2016-01-14 10:54:30 -0500976 help='AMI image file name',
977 deprecated_for_removal=True),
Masayuki Igawa73d9f3a2013-05-24 10:30:01 +0900978 cfg.StrOpt('ari_img_file',
979 default='cirros-0.3.1-x86_64-initrd',
Matthew Treinish5d5e20a2016-01-14 10:54:30 -0500980 help='ARI image file name',
981 deprecated_for_removal=True),
Masayuki Igawa73d9f3a2013-05-24 10:30:01 +0900982 cfg.StrOpt('aki_img_file',
983 default='cirros-0.3.1-x86_64-vmlinuz',
Matthew Treinish5d5e20a2016-01-14 10:54:30 -0500984 help='AKI image file name',
985 deprecated_for_removal=True),
Yair Fried413bf2d2014-11-19 17:07:11 +0200986 # TODO(yfried): add support for dhcpcd
987 cfg.StrOpt('dhcp_client',
988 default='udhcpc',
Yaroslav Lobankovceae2042015-09-09 19:25:14 +0300989 choices=["udhcpc", "dhclient", ""],
Yair Fried413bf2d2014-11-19 17:07:11 +0200990 help='DHCP client used by images to renew DCHP lease. '
991 'If left empty, update operation will be skipped. '
992 'Supported clients: "udhcpc", "dhclient"')
Masayuki Igawa73d9f3a2013-05-24 10:30:01 +0900993]
994
995
Matthew Treinish4c412922013-07-16 15:27:42 -0400996service_available_group = cfg.OptGroup(name="service_available",
997 title="Available OpenStack Services")
998
999ServiceAvailableGroup = [
1000 cfg.BoolOpt('cinder',
1001 default=True,
1002 help="Whether or not cinder is expected to be available"),
Matthew Treinishfaa340d2013-07-19 16:26:21 -04001003 cfg.BoolOpt('neutron',
1004 default=False,
1005 help="Whether or not neutron is expected to be available"),
Matthew Treinish853ae442013-07-19 16:36:07 -04001006 cfg.BoolOpt('glance',
1007 default=True,
1008 help="Whether or not glance is expected to be available"),
Matthew Treinish61e332b2013-07-19 16:42:31 -04001009 cfg.BoolOpt('swift',
1010 default=True,
1011 help="Whether or not swift is expected to be available"),
Matthew Treinish6b41e242013-07-19 16:49:28 -04001012 cfg.BoolOpt('nova',
1013 default=True,
1014 help="Whether or not nova is expected to be available"),
Matthew Treinisha9d43882013-07-19 16:54:52 -04001015 cfg.BoolOpt('heat',
1016 default=False,
1017 help="Whether or not Heat is expected to be available"),
Matthew Treinish4c412922013-07-16 15:27:42 -04001018]
1019
Attila Fazekasaeeeefd2013-08-06 17:01:56 +02001020debug_group = cfg.OptGroup(name="debug",
1021 title="Debug System")
1022
1023DebugGroup = [
Sean Daguec522c092014-03-24 10:43:22 -04001024 cfg.StrOpt('trace_requests',
1025 default='',
1026 help="""A regex to determine which requests should be traced.
1027
1028This is a regex to match the caller for rest client requests to be able to
1029selectively trace calls out of specific classes and methods. It largely
1030exists for test development, and is not expected to be used in a real deploy
1031of tempest. This will be matched against the discovered ClassName:method
1032in the test environment.
1033
1034Expected values for this field are:
1035
1036 * ClassName:test_method_name - traces one test_method
1037 * ClassName:setUp(Class) - traces specific setup functions
1038 * ClassName:tearDown(Class) - traces specific teardown functions
1039 * ClassName:_run_cleanups - traces the cleanup functions
1040
1041If nothing is specified, this feature is not enabled. To trace everything
1042specify .* as the regex.
1043""")
Attila Fazekasaeeeefd2013-08-06 17:01:56 +02001044]
1045
Andrea Frittoli (andreaf)8def7ca2015-05-13 14:24:19 +01001046DefaultGroup = [
1047 cfg.StrOpt('resources_prefix',
1048 default='tempest',
1049 help="Prefix to be added when generating the name for "
1050 "test resources. It can be used to discover all "
1051 "resources associated with a specific test run when "
Ken'ichi Ohmichi11cf2c52017-02-28 14:50:44 -08001052 "running tempest on a real-life cloud",
1053 deprecated_for_removal=True,
1054 deprecated_reason="It is enough to add 'tempest' as this "
1055 "prefix to ideintify resources which are "
1056 "created by Tempest and no projects set "
1057 "this option on OpenStack dev community."),
Andrea Frittoli (andreaf)8def7ca2015-05-13 14:24:19 +01001058]
1059
Jon Grimm270bd7f2014-08-05 18:11:29 +00001060_opts = [
1061 (auth_group, AuthGroup),
1062 (compute_group, ComputeGroup),
1063 (compute_features_group, ComputeFeaturesGroup),
1064 (identity_group, IdentityGroup),
zhufl071e94c2016-07-12 10:26:34 +08001065 (service_clients_group, ServiceClientsGroup),
Jon Grimm270bd7f2014-08-05 18:11:29 +00001066 (identity_feature_group, IdentityFeatureGroup),
1067 (image_group, ImageGroup),
1068 (image_feature_group, ImageFeaturesGroup),
1069 (network_group, NetworkGroup),
1070 (network_feature_group, NetworkFeaturesGroup),
Joseph Lanoux2f81cc12015-01-12 16:01:20 +00001071 (validation_group, ValidationGroup),
Jon Grimm270bd7f2014-08-05 18:11:29 +00001072 (volume_group, VolumeGroup),
1073 (volume_feature_group, VolumeFeaturesGroup),
1074 (object_storage_group, ObjectStoreGroup),
1075 (object_storage_feature_group, ObjectStoreFeaturesGroup),
Jon Grimm270bd7f2014-08-05 18:11:29 +00001076 (orchestration_group, OrchestrationGroup),
Jon Grimm270bd7f2014-08-05 18:11:29 +00001077 (scenario_group, ScenarioGroup),
1078 (service_available_group, ServiceAvailableGroup),
1079 (debug_group, DebugGroup),
Andrea Frittoli (andreaf)8def7ca2015-05-13 14:24:19 +01001080 (None, DefaultGroup)
Jon Grimm270bd7f2014-08-05 18:11:29 +00001081]
1082
Roman Prykhodchenko62b1ed12013-10-16 21:51:47 +03001083
Matthew Treinish43b296a2014-02-28 15:23:00 -05001084def register_opts():
Matthew Treinisha966d0f2015-07-01 17:37:31 -04001085 ext_plugins = plugins.TempestTestPluginManager()
1086 # Register in-tree tempest config options
Jon Grimm270bd7f2014-08-05 18:11:29 +00001087 for g, o in _opts:
Maru Newbyf440c292015-03-31 15:58:47 +00001088 register_opt_group(_CONF, g, o)
Matthew Treinisha966d0f2015-07-01 17:37:31 -04001089 # Call external plugin config option registration
1090 ext_plugins.register_plugin_opts(_CONF)
Jon Grimm270bd7f2014-08-05 18:11:29 +00001091
1092
1093def list_opts():
1094 """Return a list of oslo.config options available.
1095
1096 The purpose of this is to allow tools like the Oslo sample config file
1097 generator to discover the options exposed to users.
1098 """
Matthew Treinish83a19aa2015-07-23 13:06:13 -04001099 ext_plugins = plugins.TempestTestPluginManager()
Chris Hoged7b4fd12015-11-11 10:24:52 -08001100 # Make a shallow copy of the options list that can be
1101 # extended by plugins. Send back the group object
1102 # to allow group help text to be generated.
1103 opt_list = [(g, o) for g, o in _opts]
Matthew Treinish83a19aa2015-07-23 13:06:13 -04001104 opt_list.extend(ext_plugins.get_plugin_options_list())
1105 return opt_list
Matthew Treinish43b296a2014-02-28 15:23:00 -05001106
1107
Sean Dague3b9b1f32013-12-20 17:04:54 -05001108# this should never be called outside of this class
1109class TempestConfigPrivate(object):
Daryl Walleck1465d612011-11-02 02:22:15 -05001110 """Provides OpenStack configuration information."""
1111
David Patersonbe9f9832015-10-15 09:10:45 -07001112 DEFAULT_CONFIG_DIR = os.path.join(os.getcwd(), "etc")
Daryl Walleck1465d612011-11-02 02:22:15 -05001113
Brian Waldon738cd632011-12-12 18:45:09 -05001114 DEFAULT_CONFIG_FILE = "tempest.conf"
1115
Andrea Frittolia96ee212014-08-15 18:34:20 +01001116 def __getattr__(self, attr):
1117 # Handles config options from the default group
Maru Newbyf440c292015-03-31 15:58:47 +00001118 return getattr(_CONF, attr)
Andrea Frittolia96ee212014-08-15 18:34:20 +01001119
Matthew Treinish43b296a2014-02-28 15:23:00 -05001120 def _set_attrs(self):
Andrea Frittoli382a6f12017-03-09 11:52:17 +00001121 # This methods ensures that config options in Tempest as well as
1122 # in Tempest plugins can be accessed via:
1123 # CONF.<normalised_group_name>.<key_name>
1124 # where:
1125 # normalised_group_name = group_name.replace('-', '_')
1126 # Attributes are set at __init__ time *only* for known option groups
Maru Newbyf440c292015-03-31 15:58:47 +00001127 self.auth = _CONF.auth
1128 self.compute = _CONF.compute
1129 self.compute_feature_enabled = _CONF['compute-feature-enabled']
1130 self.identity = _CONF.identity
zhufl071e94c2016-07-12 10:26:34 +08001131 self.service_clients = _CONF['service-clients']
Maru Newbyf440c292015-03-31 15:58:47 +00001132 self.identity_feature_enabled = _CONF['identity-feature-enabled']
1133 self.image = _CONF.image
1134 self.image_feature_enabled = _CONF['image-feature-enabled']
1135 self.network = _CONF.network
1136 self.network_feature_enabled = _CONF['network-feature-enabled']
Joseph Lanoux2f81cc12015-01-12 16:01:20 +00001137 self.validation = _CONF.validation
Maru Newbyf440c292015-03-31 15:58:47 +00001138 self.volume = _CONF.volume
1139 self.volume_feature_enabled = _CONF['volume-feature-enabled']
1140 self.object_storage = _CONF['object-storage']
1141 self.object_storage_feature_enabled = _CONF[
Matthew Treinishd5c96022013-10-17 21:51:23 +00001142 'object-storage-feature-enabled']
Maru Newbyf440c292015-03-31 15:58:47 +00001143 self.orchestration = _CONF.orchestration
Maru Newbyf440c292015-03-31 15:58:47 +00001144 self.scenario = _CONF.scenario
1145 self.service_available = _CONF.service_available
1146 self.debug = _CONF.debug
Matthew Treinish46008082015-04-14 18:32:47 -04001147 logging.tempest_set_log_file('tempest.log')
Andrea Frittoli382a6f12017-03-09 11:52:17 +00001148 # Setting attributes for plugins
1149 # NOTE(andreaf) Plugins have no access to the TempestConfigPrivate
1150 # instance at discovery time, so they have no way of setting these
1151 # aliases themselves.
1152 ext_plugins = plugins.TempestTestPluginManager()
1153 for group, _ in ext_plugins.get_plugin_options_list():
1154 if isinstance(group, cfg.OptGroup):
1155 # If we have an OptGroup
1156 group_name = group.name
1157 group_dest = group.dest
1158 else:
1159 # If we have a group name as a string
1160 group_name = group
1161 group_dest = group.replace('-', '_')
1162 # NOTE(andreaf) We can set the attribute safely here since in
1163 # case of name conflict we would not have reached this point.
1164 setattr(self, group_dest, _CONF[group_name])
Sean Dague86bd8422013-12-20 09:56:44 -05001165
Joe Gordon28a84ae2014-07-17 15:38:28 +00001166 def __init__(self, parse_conf=True, config_path=None):
Matthew Treinish43b296a2014-02-28 15:23:00 -05001167 """Initialize a configuration from a conf directory and conf file."""
1168 super(TempestConfigPrivate, self).__init__()
1169 config_files = []
1170 failsafe_path = "/etc/tempest/" + self.DEFAULT_CONFIG_FILE
1171
Joe Gordon28a84ae2014-07-17 15:38:28 +00001172 if config_path:
1173 path = config_path
1174 else:
1175 # Environment variables override defaults...
1176 conf_dir = os.environ.get('TEMPEST_CONFIG_DIR',
1177 self.DEFAULT_CONFIG_DIR)
1178 conf_file = os.environ.get('TEMPEST_CONFIG',
1179 self.DEFAULT_CONFIG_FILE)
Matthew Treinish43b296a2014-02-28 15:23:00 -05001180
Joe Gordon28a84ae2014-07-17 15:38:28 +00001181 path = os.path.join(conf_dir, conf_file)
Matthew Treinish43b296a2014-02-28 15:23:00 -05001182
1183 if not os.path.isfile(path):
1184 path = failsafe_path
1185
1186 # only parse the config file if we expect one to exist. This is needed
1187 # to remove an issue with the config file up to date checker.
1188 if parse_conf:
1189 config_files.append(path)
Maru Newbyf440c292015-03-31 15:58:47 +00001190 logging.register_options(_CONF)
Matthew Treinish5440a402014-10-02 14:36:16 -04001191 if os.path.isfile(path):
Maru Newbyf440c292015-03-31 15:58:47 +00001192 _CONF([], project='tempest', default_config_files=config_files)
Matthew Treinish5440a402014-10-02 14:36:16 -04001193 else:
Maru Newbyf440c292015-03-31 15:58:47 +00001194 _CONF([], project='tempest')
Marc Kodererc81c7672015-12-17 12:10:12 +01001195
1196 logging_cfg_path = "%s/logging.conf" % os.path.dirname(path)
Tom Patzige6f7c7d2016-02-17 16:46:11 +01001197 if ((not hasattr(_CONF, 'log_config_append') or
1198 _CONF.log_config_append is None) and
Marc Kodererc81c7672015-12-17 12:10:12 +01001199 os.path.isfile(logging_cfg_path)):
1200 # if logging conf is in place we need to set log_config_append
1201 _CONF.log_config_append = logging_cfg_path
1202
Maru Newbyf440c292015-03-31 15:58:47 +00001203 logging.setup(_CONF, 'tempest')
Matthew Treinish43b296a2014-02-28 15:23:00 -05001204 LOG = logging.getLogger('tempest')
Jordan Pittier525ec712016-12-07 17:51:26 +01001205 LOG.info("Using tempest config file %s", path)
Matthew Treinish43b296a2014-02-28 15:23:00 -05001206 register_opts()
1207 self._set_attrs()
Masayuki Igawa9ec4cd82014-02-05 15:04:16 +09001208 if parse_conf:
Anusha Raminenif3eb9472017-01-13 08:54:01 +05301209 _CONF.log_opt_values(LOG, logging.DEBUG)
Masayuki Igawa9ec4cd82014-02-05 15:04:16 +09001210
Sean Dague86bd8422013-12-20 09:56:44 -05001211
1212class TempestConfigProxy(object):
1213 _config = None
Joe Gordon28a84ae2014-07-17 15:38:28 +00001214 _path = None
Sean Dague86bd8422013-12-20 09:56:44 -05001215
Sean Daguedb6ac6c2014-06-06 16:52:44 -04001216 _extra_log_defaults = [
Anusha Raminenif3eb9472017-01-13 08:54:01 +05301217 ('paramiko.transport', logging.INFO),
1218 ('requests.packages.urllib3.connectionpool', logging.WARN),
Sean Daguedb6ac6c2014-06-06 16:52:44 -04001219 ]
1220
1221 def _fix_log_levels(self):
1222 """Tweak the oslo log defaults."""
Doug Hellmann583ce2c2015-03-11 14:55:46 +00001223 for name, level in self._extra_log_defaults:
Anusha Raminenif3eb9472017-01-13 08:54:01 +05301224 logging.getLogger(name).logger.setLevel(level)
Sean Daguedb6ac6c2014-06-06 16:52:44 -04001225
Sean Dague86bd8422013-12-20 09:56:44 -05001226 def __getattr__(self, attr):
1227 if not self._config:
Sean Daguedb6ac6c2014-06-06 16:52:44 -04001228 self._fix_log_levels()
Matthew Treinishaa29c7e2015-04-23 16:35:09 -04001229 lock_dir = os.path.join(tempfile.gettempdir(), 'tempest-lock')
1230 lockutils.set_defaults(lock_dir)
Joe Gordon28a84ae2014-07-17 15:38:28 +00001231 self._config = TempestConfigPrivate(config_path=self._path)
Sean Dague86bd8422013-12-20 09:56:44 -05001232
Andrea Frittoli (andreaf)8420abe2016-07-27 11:47:43 +01001233 # Pushing tempest internal service client configuration to the
1234 # service clients register. Doing this in the config module ensures
1235 # that the configuration is available by the time we register the
1236 # service clients.
1237 # NOTE(andreaf) This has to be done at the time the first
1238 # attribute is accessed, to ensure all plugins have been already
1239 # loaded, options registered, and _config is set.
1240 _register_tempest_service_clients()
1241
Andrea Frittoli8b23c792017-03-09 13:17:01 +00001242 # Registering service clients and pushing their configuration to
1243 # the service clients register. Doing this in the config module
1244 # ensures that the configuration is available by the time we
1245 # discover tests from plugins.
1246 plugins.TempestTestPluginManager()._register_service_clients()
1247
Sean Dague86bd8422013-12-20 09:56:44 -05001248 return getattr(self._config, attr)
1249
Joe Gordon28a84ae2014-07-17 15:38:28 +00001250 def set_config_path(self, path):
1251 self._path = path
1252
Sean Dague86bd8422013-12-20 09:56:44 -05001253
1254CONF = TempestConfigProxy()
Matthew Treinishca5a9ff2016-04-16 15:04:34 -04001255
1256
Jordan Pittierbd4361d2017-02-21 21:28:16 +01001257@debtcollector.removals.remove(
1258 message='use testtools.skipUnless instead', removal_version='Queens')
Graham Hayes0bfe8bd2017-02-21 19:31:53 +00001259def skip_unless_config(*args):
1260 """Decorator to raise a skip if a config opt doesn't exist or is False
1261
1262 :param str group: The first arg, the option group to check
1263 :param str name: The second arg, the option name to check
1264 :param str msg: Optional third arg, the skip msg to use if a skip is raised
1265 :raises testtools.TestCaseskipException: If the specified config option
1266 doesn't exist or it exists and evaluates to False
1267 """
1268 def decorator(f):
1269 group = args[0]
1270 name = args[1]
1271
1272 @functools.wraps(f)
1273 def wrapper(self, *func_args, **func_kwargs):
1274 if not hasattr(CONF, group):
1275 msg = "Config group %s doesn't exist" % group
1276 raise testtools.TestCase.skipException(msg)
1277
1278 conf_group = getattr(CONF, group)
1279 if not hasattr(conf_group, name):
1280 msg = "Config option %s.%s doesn't exist" % (group,
1281 name)
1282 raise testtools.TestCase.skipException(msg)
1283
1284 value = getattr(conf_group, name)
1285 if not value:
1286 if len(args) == 3:
1287 msg = args[2]
1288 else:
1289 msg = "Config option %s.%s is false" % (group,
1290 name)
1291 raise testtools.TestCase.skipException(msg)
1292 return f(self, *func_args, **func_kwargs)
1293 return wrapper
1294 return decorator
1295
1296
Jordan Pittierbd4361d2017-02-21 21:28:16 +01001297@debtcollector.removals.remove(
1298 message='use testtools.skipIf instead', removal_version='Queens')
Graham Hayes0bfe8bd2017-02-21 19:31:53 +00001299def skip_if_config(*args):
1300 """Raise a skipException if a config exists and is True
1301
1302 :param str group: The first arg, the option group to check
1303 :param str name: The second arg, the option name to check
1304 :param str msg: Optional third arg, the skip msg to use if a skip is raised
1305 :raises testtools.TestCase.skipException: If the specified config option
1306 exists and evaluates to True
1307 """
1308 def decorator(f):
1309 group = args[0]
1310 name = args[1]
1311
1312 @functools.wraps(f)
1313 def wrapper(self, *func_args, **func_kwargs):
1314 if hasattr(CONF, group):
1315 conf_group = getattr(CONF, group)
1316 if hasattr(conf_group, name):
1317 value = getattr(conf_group, name)
1318 if value:
1319 if len(args) == 3:
1320 msg = args[2]
1321 else:
1322 msg = "Config option %s.%s is false" % (group,
1323 name)
1324 raise testtools.TestCase.skipException(msg)
1325 return f(self, *func_args, **func_kwargs)
1326 return wrapper
1327 return decorator
1328
1329
Andrea Frittoli (andreaf)de5fb0c2016-06-13 12:15:00 +01001330def service_client_config(service_client_name=None):
1331 """Return a dict with the parameters to init service clients
1332
1333 Extracts from CONF the settings specific to the service_client_name and
1334 api_version, and formats them as dict ready to be passed to the service
1335 clients __init__:
1336
1337 * `region` (default to identity)
1338 * `catalog_type`
1339 * `endpoint_type`
1340 * `build_timeout` (object-storage and identity default to compute)
1341 * `build_interval` (object-storage and identity default to compute)
1342
1343 The following common settings are always returned, even if
1344 `service_client_name` is None:
1345
1346 * `disable_ssl_certificate_validation`
1347 * `ca_certs`
1348 * `trace_requests`
zhufl071e94c2016-07-12 10:26:34 +08001349 * `http_timeout`
Andrea Frittoli (andreaf)de5fb0c2016-06-13 12:15:00 +01001350
1351 The dict returned by this does not fit a few service clients:
1352
1353 * The endpoint type is not returned for identity client, since it takes
1354 three different values for v2 admin, v2 public and v3
1355 * The `ServersClient` from compute accepts an optional
1356 `enable_instance_password` parameter, which is not returned.
1357 * The `VolumesClient` for both v1 and v2 volume accept an optional
1358 `default_volume_size` parameter, which is not returned.
1359 * The `TokenClient` and `V3TokenClient` have a very different
1360 interface, only auth_url is needed for them.
1361
1362 :param service_client_name: str Name of the service. Supported values are
1363 'compute', 'identity', 'image', 'network', 'object-storage', 'volume'
1364 :return: dictionary of __init__ parameters for the service clients
1365 :rtype: dict
1366 """
1367 _parameters = {
1368 'disable_ssl_certificate_validation':
Daniel Melladocad3f3d2016-08-19 14:17:16 +00001369 CONF.identity.disable_ssl_certificate_validation,
1370 'ca_certs': CONF.identity.ca_certificates_file,
zhufl071e94c2016-07-12 10:26:34 +08001371 'trace_requests': CONF.debug.trace_requests,
1372 'http_timeout': CONF.service_clients.http_timeout
Andrea Frittoli (andreaf)de5fb0c2016-06-13 12:15:00 +01001373 }
1374
1375 if service_client_name is None:
1376 return _parameters
1377
1378 # Get the group of options first, by normalising the service_group_name
1379 # Services with a '-' in the name have an '_' in the option group name
1380 config_group = service_client_name.replace('-', '_')
1381 # NOTE(andreaf) Check if the config group exists. This allows for this
1382 # helper to be used for settings from registered plugins as well
1383 try:
1384 options = getattr(CONF, config_group)
1385 except cfg.NoSuchOptError:
1386 # Option group not defined
1387 raise exceptions.UnknownServiceClient(services=service_client_name)
1388 # Set endpoint_type
1389 # Identity uses different settings depending on API version, so do not
1390 # return the endpoint at all.
1391 if service_client_name != 'identity':
1392 _parameters['endpoint_type'] = getattr(options, 'endpoint_type')
1393 # Set build_*
1394 # Object storage and identity groups do not have conf settings for
1395 # build_* parameters, and we default to compute in any case
1396 for setting in ['build_timeout', 'build_interval']:
1397 if not hasattr(options, setting) or not getattr(options, setting):
1398 _parameters[setting] = getattr(CONF.compute, setting)
1399 else:
1400 _parameters[setting] = getattr(options, setting)
1401 # Set region
1402 # If a service client does not define region or region is not set
1403 # default to the identity region
1404 if not hasattr(options, 'region') or not getattr(options, 'region'):
1405 _parameters['region'] = CONF.identity.region
1406 else:
1407 _parameters['region'] = getattr(options, 'region')
1408 # Set service
1409 _parameters['service'] = getattr(options, 'catalog_type')
1410 return _parameters
Andrea Frittoli (andreaf)8420abe2016-07-27 11:47:43 +01001411
1412
1413def _register_tempest_service_clients():
1414 # Register tempest own service clients using the same mechanism used
1415 # for external plugins.
1416 # The configuration data is pushed to the registry so that automatic
1417 # configuration of tempest own service clients is possible both for
1418 # tempest as well as for the plugins.
1419 service_clients = clients.tempest_modules()
1420 registry = clients.ClientsRegistry()
1421 all_clients = []
1422 for service_client in service_clients:
1423 module = service_clients[service_client]
1424 configs = service_client.split('.')[0]
1425 service_client_data = dict(
1426 name=service_client.replace('.', '_'),
1427 service_version=service_client,
1428 module_path=module.__name__,
1429 client_names=module.__all__,
1430 **service_client_config(configs)
1431 )
1432 all_clients.append(service_client_data)
1433 # NOTE(andreaf) Internal service clients do not actually belong
1434 # to a plugin, so using '__tempest__' to indicate a virtual plugin
1435 # which holds internal service clients.
1436 registry.register_service_client('__tempest__', all_clients)