Tests make requests against APIs using service clients. Service clients are
specializations of the RestClient
class. The service clients that cover the
APIs exposed by a service should be grouped in a service clients module.
A service clients module is python module where all service clients are
defined. If major API versions are available, submodules should be defined,
one for each version.
The ClientsFactory
class helps initializing all clients of a specific
service client module from a set of shared parameters.
The ServiceClients
class provides a convenient way to get access to all
available service clients initialized with a provided set of credentials.
ClientsFactory
(module_path, client_names, auth_provider, **kwargs)[source]¶Builds service clients for a service client module
This class implements the logic of feeding service client parameters to service clients from a specific module. It allows setting the parameters once and obtaining new instances of the clients without the need of passing any parameter.
ClientsFactory can be used directly, or consumed via the ServiceClients class, which manages the authorization part.
ServiceClients
(credentials, identity_uri, region=None, scope='project', disable_ssl_certificate_validation=True, ca_certs=None, trace_requests='', client_parameters=None)[source]¶Service client provider class
The ServiceClients object provides a useful means for tests to access service clients configured for a specified set of credentials. It hides some of the complexity from the authorization and configuration layers.
Examples:
# johndoe is a tempest.lib.auth.Credentials type instance
johndoe_clients = clients.ServiceClients(johndoe, identity_uri)
# List servers in default region
johndoe_servers_client = johndoe_clients.compute.ServersClient()
johndoe_servers = johndoe_servers_client.list_servers()
# List servers in Region B
johndoe_servers_client_B = johndoe_clients.compute.ServersClient(
region='B')
johndoe_servers = johndoe_servers_client_B.list_servers()
register_service_client_module
(name, service_version, module_path, client_names, **kwargs)[source]¶Register a service client module
Initiates a client factory for the specified module, using this class auth_provider, and accessible via a name attribute in the service client.
Parameters: |
|
---|---|
Raises: |
|
available_modules
()[source]¶Set of service client modules available in Tempest and plugins
Set of stable service clients from Tempest and service clients exposed by plugins. This set of available modules can be used for automatic configuration.
Raises: | PluginRegistrationException -- if a plugin exposes a service_version already defined by Tempest or another plugin. |
---|
Examples:
from tempest import config
params = {}
for service_version in available_modules():
service = service_version.split('.')[0]
params[service] = config.service_client_config(service)
service_clients = ServiceClients(creds, identity_uri,
client_parameters=params)
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.