Пример #1
0
    def setup_clients(self, conf, admin_credentials=False):
        self.manager = clients.ClientManager(conf, admin_credentials)
        self.identity_client = self.manager.identity_client
        self.orchestration_client = self.manager.orchestration_client
        self.compute_client = self.manager.compute_client
        self.network_client = self.manager.network_client
        self.volume_client = self.manager.volume_client
        self.object_client = self.manager.object_client
        self.metric_client = self.manager.metric_client

        self.client = self.orchestration_client
Пример #2
0
    def decorator(test_method):
        conf = getattr(config.CONF, 'heat_plugin', None)
        if not conf or conf.auth_url is None:
            return test_method

        global _resource_types
        if not _resource_types:
            manager = clients.ClientManager(conf)
            obj_rtypes = manager.orchestration_client.resource_types.list()
            _resource_types = list(t.resource_type for t in obj_rtypes)
        rtype_available = resource_type and resource_type in _resource_types
        skipper = testtools.skipUnless(
            rtype_available,
            "%s resource type not available, skipping test." % resource_type)
        return skipper(test_method)
Пример #3
0
    def decorator(test_method):
        conf = getattr(config.CONF, 'heat_plugin', None)
        if not conf or conf.auth_url is None:
            return test_method

        manager = clients.ClientManager(conf)
        try:
            manager.identity_client.get_endpoint_url(service_type, conf.region,
                                                     conf.endpoint_type)
        except kc_exceptions.EndpointNotFound:
            skipper = testtools.skip(
                "%s service not available, skipping test." % service_type)
            return skipper(test_method)
        else:
            return test_method
Пример #4
0
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', region=conf.region, endpoint_type=conf.endpoint_type)
    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__)
Пример #5
0
def load_tests(loader, tests, pattern):
    """Provide a TestSuite to the discovery process."""
    test_dir = os.path.join(os.path.dirname(__file__), TESTS_DIR)

    endpoint = None
    conf = config.CONF.heat_plugin
    if conf.auth_url:
        try:
            manager = clients.ClientManager(conf)
            endpoint = manager.identity_client.get_endpoint_url(
                'orchestration',
                region=conf.region,
                endpoint_type=conf.endpoint_type)
            os.environ['PREFIX'] = test.rand_name('api')

        # Catch the authentication exceptions that can happen if one of the
        # following conditions occur:
        #   1. conf.auth_url IP/port is incorrect or keystone not available
        #      (ConnectFailure)
        #   2. conf.auth_url is malformed (BadRequest, UnknownConnectionError,
        #      EndpointNotFound, NotFound, or DiscoveryFailure)
        #   3. conf.username/password is incorrect (Unauthorized)
        #   4. conf.project_name is missing/incorrect (EmptyCatalog)
        # These exceptions should not prevent a test list from being returned,
        # so just issue a warning log and move forward with test listing.
        except (keystoneauth1.exceptions.http.BadRequest,
                keystoneauth1.exceptions.http.Unauthorized,
                keystoneauth1.exceptions.http.NotFound,
                keystoneauth1.exceptions.catalog.EmptyCatalog,
                keystoneauth1.exceptions.catalog.EndpointNotFound,
                keystoneauth1.exceptions.discovery.DiscoveryFailure,
                keystoneauth1.exceptions.connection.UnknownConnectionError,
                keystoneauth1.exceptions.connection.ConnectFailure):
            LOG.warn("Keystone auth exception: %s: %s" %
                     (sys.exc_info()[0], sys.exc_info()[1]))
            # Clear the auth_url, as there is no point in tempest trying
            # to authenticate later with mis-configured or unreachable endpoint
            conf.auth_url = None

        except Exception:
            LOG.error("Fatal exception: %s: %s" %
                      (sys.exc_info()[0], sys.exc_info()[1]))
            raise

    def register_test_case_id(test_case):
        tempest_id = test_case.test_data.get('desc')
        test_name = test_case.id()
        if not tempest_id:
            raise AssertionError("No Tempest ID registered for API test %s" %
                                 test_name)

        def test_id():
            return test_name + '[id-%s]' % tempest_id

        test_case.id = test_id

    def register_test_suite_ids(test_suite):
        for test_case in test_suite:
            if isinstance(test_case, unittest.TestSuite):
                register_test_suite_ids(test_case)
            else:
                register_test_case_id(test_case)

    api_tests = driver.build_tests(test_dir,
                                   loader,
                                   url=endpoint,
                                   host="",
                                   fixture_module=fixtures,
                                   test_loader_name=__name__)
    register_test_suite_ids(api_tests)
    return api_tests
 def start_fixture(self):
     conf = config.CONF.heat_plugin
     manager = clients.ClientManager(conf)
     os.environ['OS_TOKEN'] = manager.identity_client.auth_token