Steve Baker | 60bd2e0 | 2016-07-27 22:57:31 +0000 | [diff] [blame] | 1 | # |
| 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 | |
| 16 | import os |
| 17 | |
| 18 | from gabbi import driver |
| 19 | from six.moves.urllib import parse as urlparse |
| 20 | |
| 21 | from heat_integrationtests.common import clients |
| 22 | from heat_integrationtests.common import config |
| 23 | from heat_integrationtests.common import test |
| 24 | |
| 25 | TESTS_DIR = 'gabbits' |
| 26 | |
| 27 | |
| 28 | def 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 Herve | 0f4c6f0 | 2017-01-19 16:49:59 +0100 | [diff] [blame] | 33 | if conf.auth_url is None: |
| 34 | # It's not configured, let's not load tests |
| 35 | return |
Steve Baker | 60bd2e0 | 2016-07-27 22:57:31 +0000 | [diff] [blame] | 36 | 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__) |