Common Test Docker Compose Hook

A Common Test hook for starting and stopping docker-compose services.

To use this hook simply place a docker-compose.yml file in the suite's data_dir, the top level of the project or declare the path explicitly with docker_compose_file -- see the configuration section below for more on how the compose file is found.

Then hooks must be declared in the ct_opts, the config returned by a function in the test suite or in a test spec. Some examples of enabling the hook are in the next section.

Shutdown of the services happens in the hook's terminate function which is called depending on when the hook was installed: CTH Scope. But the configuration for the hook can include #{stop => never} and the hook will not shutdown the services during terminate.

Examples

Hooks can be declared in rebar.config with ct_opts:

{ct_opts, [{ct_hooks, [docker_compose_cth]}]}.

It can be added on a per-suite either with the suite/0 function in the suite module:

suite() ->
    [{ct_hooks, [docker_compose_cth]}].

or in the return of init_per_suite/1:

init_per_suite(Config) ->
    [{ct_hooks, [docker_compose_cth]} | Config].

For groups it can be added per-group in the return of init_per_group/2 function in the suite module:

init_per_group(Group, Config) ->
    [{ct_hooks, [docker_compose_cth]} | Config].

Configuration