labtest.provider package

Submodules

labtest.provider.base_secret module

class labtest.provider.base_secret.BaseSecret(config)[source]

Bases: object

Base class for secret providers

When initialized, the BaseSecret sets its config attribute and sets an attribute for each key, value in the config.

Example

>>> state = BaseSecret({'dir': 'foo', 'length': 5})
>>> state.config
{'dir': 'foo', 'length': 5}
>>> state.dir
'foo'
>>> state.length
5
Parameters

config – The configuration for the state

decrypt(ciphertext)[source]

Decrypt the ciphertext and return the result

Parameters

ciphertext – The encrypted secret to decrypt

Returns

The plaintext

default_config = None
encrypt(plaintext)[source]

Encrypt the plaintext and return the result

Parameters

plaintext – The text to encrypt

Returns

The encrypted secret

labtest.provider.base_service module

class labtest.provider.base_service.BaseService(service, create_function=None, destroy_function=None, check_config_function=None)[source]

Bases: object

Base class for managing a backing service

Parameters
  • service – The type of the service, like mysql or redis

  • create_function – The function to call to create the service

  • destroy_function – The function to call to destroy the service

  • check_config_function – The function to call to check for a valid configuration for this service

check_config(config)[source]

Check the configuration to make sure it is valid for this service.

Note

If sub-classes don’t provide a check_config_function, it will always return True.

Parameters
  • self – The object

  • config – The configuration

Returns

True if the configuration is valid, otherwise False.

create(config, name)[source]

Creates the service (if necessary)

Parameters
  • config – The configuration for the service

  • name – The name of the service

Returns

A dict that may include environment or hosts keys. These are a method of communication back to the experiment to potentially alter its own container

Example result:

{
    'environment': [],  # Items to add to the environment of the container (--env)
    'hosts': []  # Add hosts using the --add-host option
}

destroy(config, name)[source]

Removes the service, if it is still there, and cleans up

Parameters
  • config – The configuration of the service

  • name – The name of the service

labtest.provider.base_state module

class labtest.provider.base_state.BaseState(config)[source]

Bases: object

Base class for state providers

When initialized, the BaseState sets its config attribute and sets an attribute for each key, value in the config.

Example

>>> state = BaseState({'dir': 'foo', 'length': 5})
>>> state.config
{'dir': 'foo', 'length': 5}
>>> state.dir
'foo'
>>> state.length
5
Parameters

config – The configuration for the state

default_config = None
get(key)[source]

Get the key from state

It should search the state in the following manner for key=/a/b/c:

  1. /a/b/c

  2. /a/b/c/default

  3. /a/b/default

  4. /a/default

  5. /default

Parameters

key – The key to get the value for

Returns

The value of the key or None

labtest.provider.secrets module

Module contents

labtest.provider.check_services_config(services)[source]

Make sure the services are configured correctly

Parameters

services – The services confgiuration to check

Raises

ClickException – If there is an error