ct_slave(3erl)

πŸ“¦
version 25.3.2.8 Β· 4 versions
, in ubuntu noble

πŸŽ€ ct_slave β€” the Erlang module that's literally the blueprint for starting and stopping nodes πŸŽ€

okay so bestie, this is the manual page for ct_slave from the Erlang Module Definition collectionβ€”it's part of the Common Test framework, and it's giving main character energy for Large-Scale Testing. no cap, this is the module that the Common Test Master uses to spin up and tear down those "slave" nodes. it's the default callback module for the {init, node_start} term in the Test Specification. periodt. πŸ’…


✨ NAME ✨

ct_slave β€” Common Test framework functions for starting and stopping nodes for Large-Scale Testing. that's the whole vibe. πŸ¦‹


🌸 DESCRIPTION 🌸

so like, this is the Common Test framework's functions for starting and stopping nodes for Large-Scale Testing. yes, that's the same sentence twice, and yes, it's iconic. the module exports functions used by the Common Test Master to start and stop "slave" nodes. and it's the default callback module for the {init, node_start} term in the Test Specification. iykyk. 🫢


πŸ‘‘ 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 the name Node on the local host. that's it, that's the function.

see also ct_slave: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 is list-valued. it's like a vibe check on the second argument, and it slays either way. ✨

see also ct_slave: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. this is the big one, the main event, the moment. πŸ’…

options Username and Password are used to log on to the remote host Host. Username, if omitted, defaults to the current username. Password is empty by default. no stress. πŸ“

a list of functions specified in option Startup are executed after startup of the node. notice that all used modules are to be present in the code path on Host. that's a real caveat, bestie, don't skip it. ⭐

the time-outs are applied as follows:

  • BootTimeout: the time to start the Erlang node, in seconds. defaults to 3 seconds. if the node is not pingable within this time, the result {error, boot_timeout, NodeName} is returned. ⏰
  • InitTimeout: the time to wait for the node until it calls the internal callback function informing master about a successful startup. defaults to 1 second. in case of a timed out message, the result {error, init_timeout, NodeName} is returned. 😭
  • StartupTimeout: the time to wait until the node stops to run StartupFunctions. defaults to 1 second. if this time-out occurs, the result {error, startup_timeout, NodeName} is returned. πŸ”₯

Options:

  • monitor_master β€” specifies if the slave node is to be stopped if the master node stops. defaults to false. πŸ‘€
  • kill_if_fail β€” specifies if the slave node is to be killed if a time-out occurs during initialization or startup. defaults to true. notice that the node can also be still alive it the boot time-out occurred, but it is not killed in this case. (yes, "it the boot time-out" is in the original, we don't fix, we report. πŸ’€)
  • erl_flags β€” specifies which flags are added to the parameters of the executable erl. πŸ› οΈ
  • env β€” specifies a list of environment variables that will extend the environment. 🌈

Special return values:

  • {error, already_started, NodeName} if the node with the specified name is already started on a specified host. πŸ™ˆ
  • {error, started_not_connected, NodeName} if the node is started, but not connected to the master node. πŸ”Œ
  • {error, not_alive, NodeName} if the node on which ct_slave:start/3 is called, is not alive. notice that NodeName is the name of the 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 local host. bye bestie. πŸ‘‹


🌸 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. that's the whole thing, no cap. πŸ’œ


ngl, this module is lowkey iconic for anyone doing Large-Scale Testing with Common Test. the timeouts are short by default (3s, 1s, 1s) so like… pay attention, bestie. and kill_if_fail defaults to true, so the node gets killed on init/startup timeoutsβ€”but not on boot timeouts, and that's a real detail you should not skip. πŸ”₯

anyway, that's the whole page, bestie. this was Ericsson AB's common_test version 1.24.0.1, and the page itself is ct_slave(3erl). slay. πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from