gproc_dist_tests.erl уже предоставляет пример кода для объяснения.
dist_test_() ->
{timeout, 120,
[{setup,
fun() ->
Ns = start_slaves([dist_test_n1, dist_test_n2]),
?assertMatch({[ok,ok],[]},
rpc:multicall(Ns, application, set_env,
[gproc, gproc_dist, Ns])),
?assertMatch({[ok,ok],[]},
rpc:multicall(Ns, application, start, [gproc])),
Ns
end,
fun(Ns) ->
[rpc:call(N, init, stop, []) || N <- Ns]
end,
fun(Ns) ->
{inorder,
[
{inparallel, [
fun() ->
?debugVal(t_simple_reg(Ns))
end,
fun() ->
?debugVal(t_simple_counter(Ns))
end,
fun() ->
?debugVal(t_aggr_counter(Ns))
end,
fun() ->
?debugVal(t_update_counters(Ns))
end,
fun() ->
?debugVal(t_shared_counter(Ns))
end,
fun() ->
?debugVal(t_mreg(Ns))
end,
fun() ->
?debugVal(t_await_reg(Ns))
end,
fun() ->
?debugVal(t_await_self(Ns))
end,
fun() ->
?debugVal(t_await_reg_exists(Ns))
end,
fun() ->
?debugVal(t_give_away(Ns))
end,
fun() ->
?debugVal(t_sync(Ns))
end,
fun() ->
?debugVal(t_monitor(Ns))
end,
fun() ->
?debugVal(t_subscribe(Ns))
end
]
},
fun() ->
?debugVal(t_sync_cand_dies(Ns))
end,
{timeout, 90, [fun() ->
?debugVal(t_fail_node(Ns))
end]}
]}
end
}]}.