goncalotomas / FMKe

🛠️ Realistic benchmark for key value stores
Other
23 stars 8 forks source link

Node setup process in Eunit tests fails transiently #152

Closed goncalotomas closed 6 years ago

goncalotomas commented 6 years ago

I suspect that in test_fmke_operations_travis:start/0 there is an issue with the code that sets the node cookie:

start() ->
    Task = rand:uniform(100),
    Pname = build_generic_op("test_ops_travis_~p@127.0.0.1",[Task]),
    net_kernel:start([Pname,longnames]),
    erlang:set_cookie(node(),fmke),
    'fmke@127.0.0.1'.

In this case, if net_kernel:start/1 is asynchronous or if it's otherwise possible to continue (which sometimes failing tests would lead me to believe), there is a chance that node() will return it's previous value and in that case the erlang:set_cookie/2 call will fail.

If this turns out to be the case, then a slightly modified version would make sense:

start() ->
    Task = rand:uniform(100),
    Pname = build_generic_op("test_ops_travis_~p@127.0.0.1",[Task]),
    {ok, _Pid} = net_kernel:start([Pname,longnames]),
    true = erlang:set_cookie(Pname,fmke),
    'fmke@127.0.0.1'.