labtest package

Submodules

labtest.cli module

labtest.config module

class labtest.config.LabTestConfig(**kwargs)[source]

Bases: labtest.configobj.Config

default_config_files = ['.labtest.yml', '.labtest.yaml', 'setup.cfg', 'package.json']
dependencies = {'build_provider': {'default': ['code_repo_url', 'app_build_image', 'app_build_command', 'container_build_command', 'container_provider']}}
get_default_app_build_command()[source]

Make the app build image command optional

get_default_app_build_image()[source]

Make the app build image config optional

get_default_app_name()[source]

The default app_name is the name of the directory containing the .git directory

get_default_before_start_command()[source]

There is no default before_start_command

get_default_build_provider()[source]

The default provider of the build

get_default_container_build_command()[source]
get_default_container_provider()[source]

Where are the images stored by default?

get_default_docker_image_pattern()[source]

Return the default docker image name pattern

get_default_environment()[source]

Return an empty list as the default environment

get_default_host_name_pattern()[source]

Return the default host name pattern

get_default_services()[source]

The services the experiment requires. Defaults to an empty dict

get_default_use_ssh_config()[source]
get_default_verbose()[source]
get_secrets()[source]

Retrieves the secret provider from state and caches it

get_state()[source]

Retrieves the state object and caches it

namespace = 'labtest'
required_attrs = ['app_build_command', 'app_build_image', 'app_name', 'before_start_command', 'build_provider', 'container_provider', 'docker_image_pattern', 'environment', 'host', 'host_name_pattern', 'services', 'test_domain', 'verbose']
set_environment(value)[source]

Make sure the environment is a list

set_use_ssh_config(value)[source]

Make sure the value is converted to a boolean

validate_dependencies()[source]

Make sure extra options are set, if necessary

labtest.config.get_config(filepath='', **kwargs)[source]

Get the configuration based off all the ways you can pass it

Can raise IOError if the filepath passed in doesn’t exist

Precedence:
  1. Command-line arguments

  2. Configuration file

labtest.config.get_state[source]

Task to get the state provider from the remote server and return a State object

Returns

A subclass instance of BaseState or None

labtest.configobj module

class labtest.configobj.Config(**kwargs)[source]

Bases: future.types.newobject.newobject

config

This returns the configuration as a dict.

This method will use the logic in __getattr__ to set the values. It doesn’t just return the default _config dict.

default_config_files = [u'.labtest.yml', u'setup.cfg', u'package.json']
extension_map = {u'.cfg': u'read_ini_config', u'.ini': u'read_ini_config', u'.json': u'read_json_config', u'.yaml': u'read_yaml_config', u'.yml': u'read_yaml_config'}
namespace = u'config'
parse_default_config()[source]

Look for the default config path from the default_config_files.

parse_file(filepath)[source]

Determine which method to use to parse the file, based on the file extension

read_ini_config(filepath)[source]

Read a configuration from an INI file

read_json_config(filepath)[source]

Read a configuration from a JSON file

read_yaml_config(filepath)[source]

Reads a configuration from a YAML file

required_attrs = []
validate()[source]

Validate the configuration. Set the attribute validation_errors

validate_dependencies()[source]

Subclasses should override this command to provide validation for options that are required based on other option’s values

validation_message()[source]

Convenience method to format the validation errors, if any

labtest.filesystem module

Provides helpers for filesystem operations that extend Fabric’s

labtest.filesystem.create_dir(remote_path, owner=None, group='docker', mode=None)[source]

Create a directory and the intermediate paths as required.

The group will always be set to group. The owner and mode will not be set unless specified

Parameters
  • remote_path – The remote directory path

  • owner – The name of the user to set the owner of the directory

  • group – The name of the group to set the group of the directory

  • mode – The mode to set the directory, as a string

labtest.filesystem.get_file_contents(remote_path)[source]

Reads the file contents into a buffer.

The buffer is a BytesIO buffer, so it works for binary and text documents.

For text documents, you will have to coerce it appropriately.

Parameters

remote_path – The path to the remote file

Returns

A BytesIO buffer.

labtest.filesystem.is_dir(remote_path)[source]

Check if the remote path is a directory

labtest.instance module

labtest.instance.create_instance[source]

The Fabric tasks that create a test instance

labtest.instance.delete_instance[source]

The Fabric task to delete an instance

labtest.instance.list_instances[source]

Return a list of test instances on the server

labtest.instance.test_task[source]
labtest.instance.update_instance[source]

The Fabric task to update an instance

labtest.secrets module

labtest.secrets.encrypt_task[source]

Encrypt a secret with the configured secret provider

Parameters

plaintext – The text to encrypt

Returns

The encrypted ciphertext

labtest.services module

A collection of common functions to setup and destroy OS services

labtest.services.delete_service(service_name, quiet=False)[source]

Remove the service and clean up

Parameters
  • service_name – The name of the service

  • quiet – Set to True to suppress Fabric output

labtest.services.setup_service(service_name, local_template_path, context, quiet=False)[source]

Setup a service using a template and context to render the correct service file

Parameters
  • service_name – The name of the service

  • local_template_path – The path to the template to use to render the service

  • context – A dict containing values to use in the rendering of the template

  • quiet – Set to True to suppress Fabric output

labtest.services.start_service(service_name, quiet=False)[source]

Make sure the service is running

Module contents