Guest User

Untitled

a guest
Aug 1st, 2014
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Erlang 1.49 KB | None | 0 0
  1. -module(cluster_test).
  2. -include_lib("eunit/include/eunit.hrl").
  3. -compile(export_all).
  4. -include("cluster.hrl").
  5.  
  6. cluster_formation_suite_test_() ->
  7.     {
  8.         foreach,
  9.         fun setup/0,
  10.         fun teardown/1,
  11.         [
  12.             fun cluster_formation/0
  13.         ]
  14.     }.
  15.  
  16. setup() ->
  17.     application:ensure_all_started(cluster, permanent),
  18.     %% Go outside eunit folder /home/marcos/code/cluster/apps/cluster/.eunit
  19.     c:cd('../../../'),
  20.  
  21.     ok.
  22.  
  23. teardown(_) ->
  24.     application:stop(cluster),
  25.     ok.
  26.  
  27. cluster_formation() ->
  28.     Host = '127.0.0.1',
  29.     Args = " -pa ebin deps/*/ebin -setcookie secret -rsh ssh",
  30.     {ok, Slave1} =  slave:start(Host, slave1, Args),
  31.     {ok, Slave2} = slave:start(Host, slave2, Args),
  32.  
  33.     rpc:call(Slave1, application ,ensure_all_started,[cluster,permanent]),
  34.     rpc:call(Slave2, application ,ensure_all_started,[cluster,permanent]),
  35.  
  36.     ?assertEqual(pong, net_adm:ping(Slave1)),
  37.     ?assertEqual(pong, net_adm:ping(Slave2)),
  38.  
  39.     ?assertEqual(Slave1, '[email protected]'),
  40.     ?assertEqual(Slave2, '[email protected]'),
  41.  
  42.     Result1 = rpc:call(Slave1, cluster, join,[node()]),
  43.     ?assertEqual(ok, Result1),
  44.     Result2 = rpc:call(Slave2, cluster, join,[node()]),
  45.     ?assertEqual(ok, Result2),
  46.  
  47.     ?assertEqual(
  48.         cluster:status()
  49.     ),
  50.     io:format("Cluster formation, nodes: ~p ~n", [cluster:status()]),
  51.     slave:stop(Slave1),
  52.     slave:stop(Slave2).
Advertisement
Add Comment
Please, Sign In to add comment