Erlang logo
User's Guide
Reference Manual
Release Notes
PDF
Top

Common Test
Reference Manual
Version 1.10


Expand All
Contract All

Table of Contents

ct_slave

MODULE

ct_slave

MODULE SUMMARY

Common Test Framework functions for starting and stopping nodes for Large Scale Testing.

DESCRIPTION

Common Test Framework functions for starting and stopping nodes for Large Scale Testing.

This module exports functions which are used by the Common Test Master to start and stop "slave" nodes. It is the default callback module for the {init, node_start} term of the Test Specification.

EXPORTS

start(Node) -> Result

Types:

Node = atom()
Result = {ok, NodeName} | {error, Reason, NodeName}
Reason = already_started | started_not_connected | boot_timeout | init_timeout | startup_timeout | not_alive
NodeName = atom()

Starts an Erlang node with name Node on the local host.

See also: start/3.

start(HostOrNode, NodeOrOpts) -> Result

Types:

HostOrNode = atom()
NodeOrOpts = atom() | list()
Result = {ok, NodeName} | {error, Reason, NodeName}
Reason = already_started | started_not_connected | boot_timeout | init_timeout | startup_timeout | not_alive
NodeName = atom()

Starts an Erlang node with default options on a specified host, or on the local host with specified options. That is, the call is interpreted as start(Host, Node) when the second argument is atom-valued and start(Node, Opts) when it's list-valued.

See also: start/3.

start(Host, Node, Opts) -> Result

Types:

Node = atom()
Host = atom()
Opts = [OptTuples]
OptTuples = {username, Username} | {password, Password} | {boot_timeout, BootTimeout} | {init_timeout, InitTimeout} | {startup_timeout, StartupTimeout} | {startup_functions, StartupFunctions} | {monitor_master, Monitor} | {kill_if_fail, KillIfFail} | {erl_flags, ErlangFlags} | {env, [{EnvVar, Value}]}
Username = string()
Password = string()
BootTimeout = integer()
InitTimeout = integer()
StartupTimeout = integer()
StartupFunctions = [StartupFunctionSpec]
StartupFunctionSpec = {Module, Function, Arguments}
Module = atom()
Function = atom()
Arguments = [term]
Monitor = bool()
KillIfFail = bool()
ErlangFlags = string()
EnvVar = string()
Value = string()
Result = {ok, NodeName} | {error, Reason, NodeName}
Reason = already_started | started_not_connected | boot_timeout | init_timeout | startup_timeout | not_alive
NodeName = atom()

Starts an Erlang node with name Node on host Host as specified by the combination of options in Opts.

Options Username and Password will be used to log in onto the remote host Host. Username, if omitted, defaults to the current user name, and password is empty by default.

A list of functions specified in the Startup option will be executed after startup of the node. Note that all used modules should be present in the code path on the Host.

The timeouts are applied as follows:

  • BootTimeout - time to start the Erlang node, in seconds. Defaults to 3 seconds. If node does not become pingable within this time, the result {error, boot_timeout, NodeName} is returned;
  • InitTimeout - time to wait for the node until it calls the internal callback function informing master about successfull startup. Defaults to one second. In case of timed out message the result {error, init_timeout, NodeName} is returned;
  • StartupTimeout - time to wait intil the node finishes to run the StartupFunctions. Defaults to one second. If this timeout occurs, the result {error, startup_timeout, NodeName} is returned.

Option monitor_master specifies, if the slave node should be stopped in case of master node stop. Defaults to false.

Option kill_if_fail specifies, if the slave node should be killed in case of a timeout during initialization or startup. Defaults to true. Note that node also may be still alive it the boot timeout occurred, but it will not be killed in this case.

Option erlang_flags specifies, which flags will be added to the parameters of the erl executable.

Option env specifies a list of environment variables that will extended the environment.

Special return values are:

  • {error, already_started, NodeName} - if the node with the given name is already started on a given host;
  • {error, started_not_connected, NodeName} - if node is started, but not connected to the master node.
  • {error, not_alive, NodeName} - if node on which the ct_slave:start/3 is called, is not alive. Note that NodeName is the name of current node in this case.

stop(Node) -> Result

Types:

Node = atom()
Result = {ok, NodeName} | {error, Reason, NodeName}
Reason = not_started | not_connected | stop_timeout

Stops the running Erlang node with name Node on the localhost.

stop(Host, Node) -> Result

Types:

Host = atom()
Node = atom()
Result = {ok, NodeName} | {error, Reason, NodeName}
Reason = not_started | not_connected | stop_timeout
NodeName = atom()

Stops the running Erlang node with name Node on host Host.