heat/heat_integrationtests/api/test_heat_api.py
Thomas Herve a9db2634af Skip integration tests when not configured
The new API tests have a load test method, which requires the heat
tempest plugin to be configured to load. This can be called by random
test suite that don't want to run our tests, so let's skip when it's not
configured.

Change-Id: I04024f288aaba5cbb3ada2a5b68d3f0bf56fcf4b
2017-01-19 16:49:59 +01:00

45 lines
1.5 KiB
Python

#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""A test module to exercise the Heat API with gabbi. """
import os
from gabbi import driver
from six.moves.urllib import parse as urlparse
from heat_integrationtests.common import clients
from heat_integrationtests.common import config
from heat_integrationtests.common import test
TESTS_DIR = 'gabbits'
def load_tests(loader, tests, pattern):
"""Provide a TestSuite to the discovery process."""
test_dir = os.path.join(os.path.dirname(__file__), TESTS_DIR)
conf = config.CONF.heat_plugin
if conf.auth_url is None:
# It's not configured, let's not load tests
return
manager = clients.ClientManager(conf)
endpoint = manager.identity_client.get_endpoint_url(
'orchestration', conf.region)
host = urlparse.urlparse(endpoint).hostname
os.environ['OS_TOKEN'] = manager.identity_client.auth_token
os.environ['PREFIX'] = test.rand_name('api')
return driver.build_tests(test_dir, loader, host=host,
url=endpoint, test_loader_name=__name__)