Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -module(cluster_test).
- -include_lib("eunit/include/eunit.hrl").
- -compile(export_all).
- -include("cluster.hrl").
- cluster_formation_suite_test_() ->
- {
- foreach,
- fun setup/0,
- fun teardown/1,
- [
- fun cluster_formation/0
- ]
- }.
- setup() ->
- application:ensure_all_started(cluster, permanent),
- %% Go outside eunit folder /home/marcos/code/cluster/apps/cluster/.eunit
- c:cd('../../../'),
- ok.
- teardown(_) ->
- application:stop(cluster),
- ok.
- cluster_formation() ->
- Host = '127.0.0.1',
- Args = " -pa ebin deps/*/ebin -setcookie secret -rsh ssh",
- {ok, Slave1} = slave:start(Host, slave1, Args),
- {ok, Slave2} = slave:start(Host, slave2, Args),
- rpc:call(Slave1, application ,ensure_all_started,[cluster,permanent]),
- rpc:call(Slave2, application ,ensure_all_started,[cluster,permanent]),
- ?assertEqual(pong, net_adm:ping(Slave1)),
- ?assertEqual(pong, net_adm:ping(Slave2)),
- Result1 = rpc:call(Slave1, cluster, join,[node()]),
- ?assertEqual(ok, Result1),
- Result2 = rpc:call(Slave2, cluster, join,[node()]),
- ?assertEqual(ok, Result2),
- ?assertEqual(
- cluster:status()
- ),
- io:format("Cluster formation, nodes: ~p ~n", [cluster:status()]),
- slave:stop(Slave1),
- slave:stop(Slave2).
Advertisement
Add Comment
Please, Sign In to add comment