Does anyone know of an example/blog post about integration testing that involves bringing up another beam instance and running code in the new instance? It can be with or without clustering since I’m not sure about the trade-offs involved there.
You mean like ct_slave or local-cluster?
Pretty manual but we’re starting multiple beams for our peer to peer networking test: diode_server/test/test_helper.exs at 44c02a45c204fae635cb06642b208c1ca25b4e48 · diodechain/diode_server · GitHub
This is the core snippet:
spawn_link(fn ->
iex = System.find_executable("iex")
args = ["--cookie", @cookie, "-S", "mix", "run"]
env =
[
{"MIX_ENV", "test"},
{"DATA_DIR", clonedir},
{"RPC_PORT", "#{rpc_port(num)}"},
{"RPCS_PORT", "#{rpcs_port(num)}"},
{"EDGE2_PORT", "#{edge2_port(num)}"},
{"PEER_PORT", "#{peer_port(num)}"},
{"SEED", "none"}
]
|> Enum.map(fn {key, value} -> {String.to_charlist(key), String.to_charlist(value)} end)
port =
Port.open({:spawn_executable, iex}, [
{:args, args},
{:env, env},
:stream,
:exit_status,
:hide,
:use_stdio,
:stderr_to_stdout
])
true = Process.register(port, String.to_atom("clone_#{num}"))
clone_loop(port, file)
end)
You can take a look at the archived firenest repo, which iirc did do multi node testing.
Thanks for all the examples! I’ll take a look at them and base my work on them.






















