blob: 2e219e7223983c506b65a17c0f9d6662eafe86f9 [file] [log] [blame]
Steve Baker60bd2e02016-07-27 22:57:31 +00001#
2# Licensed under the Apache License, Version 2.0 (the "License"); you may
3# not use this file except in compliance with the License. You may obtain
4# a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11# License for the specific language governing permissions and limitations
12# under the License.
13
14"""A test module to exercise the Heat API with gabbi. """
15
16import os
17
18from gabbi import driver
19from six.moves.urllib import parse as urlparse
20
21from heat_integrationtests.common import clients
22from heat_integrationtests.common import config
23from heat_integrationtests.common import test
24
25TESTS_DIR = 'gabbits'
26
27
28def load_tests(loader, tests, pattern):
29 """Provide a TestSuite to the discovery process."""
30 test_dir = os.path.join(os.path.dirname(__file__), TESTS_DIR)
31
32 conf = config.CONF.heat_plugin
Thomas Herve0f4c6f02017-01-19 16:49:59 +010033 if conf.auth_url is None:
34 # It's not configured, let's not load tests
35 return
Steve Baker60bd2e02016-07-27 22:57:31 +000036 manager = clients.ClientManager(conf)
37 endpoint = manager.identity_client.get_endpoint_url(
38 'orchestration', conf.region)
39 host = urlparse.urlparse(endpoint).hostname
40 os.environ['OS_TOKEN'] = manager.identity_client.auth_token
41 os.environ['PREFIX'] = test.rand_name('api')
42
43 return driver.build_tests(test_dir, loader, host=host,
44 url=endpoint, test_loader_name=__name__)