ct_rpc(3)
π NAME π
okay bestie, welcome to ct_rpc β it's the Common Test specific layer that sits on top of Erlang/OTP's rpc. yes, that rpc. the glow-up edition π
This is page ct_rpc(3) from the Erlang module definition collection, and she's here to make remote calls across your test nodes feel a whole lot less feral.
πΈ DESCRIPTION πΈ
ngl, this section is literally just vibes β the original page hands you the section header and then goes straight to the functions. no preamble, no lore, we're diving in. slay.
So likeβ¦ scroll down, the good stuff is in FUNCTIONS. π«Ά
β¨ FUNCTIONS β¨
app_node/2 π
app_node(App, Candidates) -> CandidateNode
when
App :: atom(),
Candidates :: [node()],
CandidateNode :: node().
So you've got a whole little squad of candidate nodes and you need to know which one is actually running the application App. That's it, that's the job. She looks at your set of candidate nodes and picks the one running App.
BUT β and this is important bestie β if none of your candidate nodes is running App, she makes the test case that called her fail. no soft launch, no "oops", it just fails. π
Also she's literally the same as calling app_node(App, Candidates, true). same energy, fr fr.
app_node/3 π
app_node(App, Candidates, FailOnBadRPC) -> CandidateNode
when
App :: atom(),
Candidates :: [node()],
FailOnBadRPC :: boolean(),
CandidateNode :: node().
Same as ct_rpc:app_node/2, except now you get a say in whether the search for a candidate node stops if badrpc gets received at some point. That's what FailOnBadRPC is for. iconic, honestly.
app_node/4 π
app_node(App, Candidates, FailOnBadRPC, Cookie) -> CandidateNode
when
App :: atom(),
Candidates :: [node()],
FailOnBadRPC :: boolean(),
Cookie :: atom() | [],
CandidateNode :: node().
Same as ct_rpc:app_node/2, except that argument FailOnBadRPC determines if the search for a candidate node is to stop if badrpc is received at some point. (yes, same sentence as the /3 version, she said what she said π
)
Extra thing though: the cookie on the client node is set to Cookie for this rpc operation, which is what you use to match the server node cookie. matching cookies = main character energy π₯
call/5 β
call(Node, Module, Function, Args, TimeOut) ->
term() | {badrpc, Reason}
when
Node :: {Function, Args} | node(),
Module :: module(),
Function :: atom(),
Args :: list(),
TimeOut :: timeout(),
Reason :: term().
She evaluates apply(Module, Function, Args) on the node Node. Then you get back either whatever Function returns, or {badrpc, Reason} if the remote procedure call fails. no cap.
And listen β if Node is {Fun, FunArgs}, then applying Fun to FunArgs is what returns a node name. cute little indirection moment π¦
call/6 πΈ
call(Node, Module, Function, Args, TimeOut, Cookie) ->
term() | {badrpc, Reason}
when
Node :: {Function, Args} | node(),
Module :: module(),
Function :: atom(),
Args :: list(),
TimeOut :: timeout(),
Cookie :: atom() | [],
Reason :: term().
She evaluates apply(Module, Function, Args) on the node Node. Returns either whatever Function returns, or {badrpc, Reason} if the remote procedure call fails. And if Node is {Fun, FunArgs}, applying Fun to FunArgs is to return a node name. same as her /5 sister, obsessed.
β¨ plus the glow-up: the cookie on the client node is set to Cookie for this rpc operation (used to match the server node cookie). iykyk π
cast/4 π§
cast(Node, Module, Function, Args) -> ok
when
Node :: {Function, Args} | node(),
Module :: module(),
Function :: atom(),
Args :: list().
She evaluates apply(Module, Function, Args) on the node Node β but this is the chill one. No response is delivered, and the process that makes the call is not suspended until the evaluation is completed, unlike what happens in the case of call/3,4. you just yeet it and keep it moving π
And yeah, if Node is {Fun, FunArgs}, applying Fun to FunArgs is to return a node name.
cast/5 π
cast(Node, Module, Function, Args, Cookie) -> ok
when
Node :: {Function, Args} | node(),
Module :: module(),
Function :: atom(),
Args :: list(),
Cookie :: atom() | [].
She evaluates apply(Module, Function, Args) on the node Node. No response is delivered and the process that makes the call is not suspended until the evaluation is completed as in the case of call/3,4. If Node is {Fun, FunArgs}, applying Fun to FunArgs is to return a node name. same as /4, yes bestie, we keep it consistent.
And the little extra: the cookie on the client node is set to Cookie for this rpc operation (used to match the server node cookie). π
lowkey a note for future you: this whole page is built and owned by Ericsson AB, and it ships as part ofcommon_testversion1.31.1. that's the whole sign-off, muah πβ¨
π¦ where this page comes from
- ubuntu stonking: erlang-doc 1:29.0.6+dfsg-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms