DevCluster (DevCluster v0.1.0)

Copy Markdown View Source

Starts local BEAM nodes for distributed Elixir tests.

Each cluster has its own linked controller process. Nodes are configured with the manager's code paths, Mix environment, application environment and selected applications. When :cover is running, new nodes are attached to it so remotely executed code contributes to the coverage report.

Summary

Functions

Returns a supervisor child specification for a cluster.

Returns all members owned by a cluster.

Returns all distributed node names owned by a cluster.

Returns the local :peer controller PIDs owned by a cluster.

Adds nodes to an existing cluster transactionally.

Starts Erlang distribution for the current VM.

Starts a linked cluster containing amount nodes.

Stops a cluster and all of its nodes within the default public deadline.

Stops a cluster with custom deadlines, or stops one selected member.

Stops Erlang distribution for the current VM.

Types

cluster()

@type cluster() :: GenServer.server()

option()

@type option() ::
  {:applications, [atom()]}
  | {:cluster_shutdown_timeout, pos_integer()}
  | {:environment, keyword()}
  | {:files, [Path.t()]}
  | {:hidden, boolean()}
  | {:name, GenServer.name()}
  | {:prefix, atom() | String.t()}
  | {:shutdown_timeout, pos_integer()}

Functions

child_spec(arg)

@spec child_spec({pos_integer(), [option()]}) :: Supervisor.child_spec()

Returns a supervisor child specification for a cluster.

members(cluster)

@spec members(cluster()) :: {:ok, [DevCluster.Member.t()]}

Returns all members owned by a cluster.

nodes(cluster)

@spec nodes(cluster()) :: {:ok, [node()]}

Returns all distributed node names owned by a cluster.

pids(cluster)

@spec pids(cluster()) :: {:ok, [pid()]}

Returns the local :peer controller PIDs owned by a cluster.

start()

@spec start() :: :ok | {:error, term()}

Alias for start_distribution/0.

start(cluster, amount)

@spec start(cluster(), pos_integer()) ::
  {:ok, [DevCluster.Member.t()]} | {:error, term()}

Adds nodes to an existing cluster transactionally.

start_distribution(opts \\ [])

@spec start_distribution(keyword()) :: :ok | {:error, term()}

Starts Erlang distribution for the current VM.

Calling this function again is safe. The default manager name includes the OS process ID to avoid collisions with other test VMs on the same machine.

start_link(amount, opts \\ [])

@spec start_link(pos_integer(), [option()]) :: GenServer.on_start()

Starts a linked cluster containing amount nodes.

stop(cluster)

@spec stop(cluster()) :: :ok | {:error, term()}

Stops a cluster and all of its nodes within the default public deadline.

Use stop/2 when a custom :cluster_shutdown_timeout requires a longer public :timeout.

stop(cluster, opts_or_selector)

@spec stop(cluster(), keyword() | DevCluster.Member.t() | node() | pid()) ::
  :ok | {:error, term()}

Stops a cluster with custom deadlines, or stops one selected member.

A keyword list accepts :timeout and :controller_timeout, both in milliseconds. A member can instead be selected by struct, node name, or peer PID.

stop_distribution()

@spec stop_distribution() :: :ok | {:error, term()}

Stops Erlang distribution for the current VM.