ct_containers (ct_containers v0.1.1)

Link to this section Summary

Functions

Retrieves a configured container from common test config.
Starts the given image name using the configured container runtime (docker by default). The following options are available:
  • {runtime, RuntimeModule::module()}: The container runtime module to be used
  • {wait_strategy, WaitStrategyFunction::function()}: The applied wait strategy for the container - default: passthrough meaning the container will be considered as 'ready' as soon as it switched to 'running' state.
  • {timeout, Timeout::timeout()}: The timespan for a wait strategy to finish before being considered failed (default: 5000)
  • {ports, [port_mapping()]}: The open ports for this container
  • {network, {NetworkName::atom(), Alias::string()}}: The network this container will be attached to and the network alias for inter container networking
  • {}:
  • {}:

Link to this section Types

Link to this type

container_engine_cb_module/0

-type container_engine_cb_module() :: module().
Link to this type

container_id/0

-type container_id() :: string() | binary().
Link to this type

ct_container_context/0

-type ct_container_context() ::
    #{image => binary(),
      wait_strategy => wait_strategy(),
      wait_timeout => number(),
      port_mapping => list(),
      labels => labels(),
      binds => list(),
      network => {atom(), binary()},
      alias => binary(),
      env => #{binary() => binary()},
      container_engine_module => module()}.
-type labels() :: #{binary() => binary()}.
-type option() ::
    {wait_strategy, wait_strategy()} |
    {timeout, pos_integer()} |
    {ports, [port_mapping()]} |
    {volumes, list()} |
    {runtime, module()} |
    {network, {atom(), string()}} |
    {env, #{binary() => binary()}}.
-type options() :: [option()].
Link to this type

port_mapping/0

-type port_mapping() :: {1..65535, tcp | udp}.
Link to this type

wait_strategy/0

-type wait_strategy() ::
    fun((container_id(), container_engine_cb_module(), wait_strategy_ctx()) ->
            {true | false, wait_strategy_ctx()}).
Link to this type

wait_strategy_ctx/0

-type wait_strategy_ctx() :: map().

Link to this section Functions

Link to this function

delete_networks()

Link to this function

get_container(Id, Config)

-spec get_container(Id, Config) -> Container
                 when Id :: atom(), Config :: proplists:proplist(), Container :: any().
Retrieves a configured container from common test config.
-spec host(pid()) -> string() | inet:ip4_address().
Link to this function

port(Pid, PortMapping)

-spec port(pid(), port_mapping()) -> integer().
Link to this function

port(Pid, PortMapping, _)

Link to this function

start(ImageName)

Link to this function

start(ImageName, Options)

-spec start(string(), options()) -> {ok, pid()} | {error, container_exited}.
Starts the given image name using the configured container runtime (docker by default). The following options are available:
  • {runtime, RuntimeModule::module()}: The container runtime module to be used
  • {wait_strategy, WaitStrategyFunction::function()}: The applied wait strategy for the container - default: passthrough meaning the container will be considered as 'ready' as soon as it switched to 'running' state.
  • {timeout, Timeout::timeout()}: The timespan for a wait strategy to finish before being considered failed (default: 5000)
  • {ports, [port_mapping()]}: The open ports for this container
  • {network, {NetworkName::atom(), Alias::string()}}: The network this container will be attached to and the network alias for inter container networking
  • {}:
  • {}:
-spec stop(pid()) -> ok.