To write a test suite for my [virtual actor framework] will require starting, or simulating multiple nodes.
i.e. I am trying to write a test that asserts an actor can only be running on one node at a time.
Is it possible to have multiple nodes running a single test suite. are there any good examples of projects that do this?
Firenest would probably be a prime example of doing that.
2 Likes
idi527
July 15, 2018, 3:17pm
3
1 Like
Thanks for this. I have tried to follow the setup as in firenest but can’t work out to start Elixir on the other node.
My test setup is as follows.
:net_kernel.start([:"suite@127.0.0.1"])
|> IO.inspect()
:erl_boot_server.start([])
{:ok, ipv4} = :inet.parse_ipv4_address('127.0.0.1')
:erl_boot_server.add_slave(ipv4)
:ok
{:ok, peer_1} =
:slave.start_link('127.0.0.1', :peer_1, inet_loader_args())
|> IO.inspect()
Node.list()
|> IO.inspect()
Node.spawn(peer_1, Node, :list, [])
|> IO.inspect()
However this results in the following error
16:41:06.338 [error] Error in process #PID<17485.44.0> on node :"peer_1@127.0.0.1" with exit value:
{:undef, [{Node, :list, [], []}]}
Gazler
July 16, 2018, 8:08am
5
I think this is the relevant part from Firenest:
apply(module, function, args)
send(parent, self())
Process.sleep(:infinity)
end)
receive do
^task -> :ok
end
end
defp spawn_node(node_host) do
with_deadline(30_000, fn ->
{:ok, node} = :slave.start_link('127.0.0.1', node_name(node_host), inet_loader_args())
add_code_paths(node)
transfer_configuration(node)
ensure_applications_started(node)
{:ok, node}
end)
end
defp with_deadline(timeout, fun) do
1 Like
Thanks this is helpful. I wonder if there is any reusable pattern here to wrap up all the steps involved in transferring code_paths/config etc