Hi.
For various reasons I want to have each ExUnit test to run in its own node. I reviewed the code for ExUnit in 1.2.6. and I have questions.
The work horse for actually executing a test seems to be spawn_test/3
defined here:
https://github.com/elixir-lang/elixir/blob/v1.2/lib/ex_unit/lib/ex_unit/runner.ex#L234
Now, I think I could modify this to run in a slave node. Startup of the slave node will be handled like here: https://github.com/stavro/hello_master/blob/master/lib/hello_master/slave_node.ex
So, basically:
- Start slave
- Set code load paths to match that of master
- Retain hostname of slave
- Call
Node.spawn
with the slave hostname instead ofspawn_monitor
- Monitor the PID returned by
Node.spawn
(there seems to be noNode.spawn_monitor
atomic function) - Through the magic of
Node.spawn
the spawned process on the slave should send its response back to the process running on master (the PID is handed over in the closure of the lambda to execute) - Leave timeout and other monitoring as is
- Add a stop of the slave after the
Process.exit
andProcess.demonitor
calls.
I guess I will have to copy the code of ExUnit in order to do this experiment.
Now, can anybody advise me if what I just described is feasible? Or did I overlook something vital?