Skip to content

Commit

Permalink
Fix some test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
emqplus committed Nov 12, 2019
1 parent 7275689 commit a7b10c2
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 107 deletions.
1 change: 0 additions & 1 deletion src/ekka_node_monitor.erl
Expand Up @@ -72,7 +72,6 @@ run_after(Delay, Msg) ->
%%--------------------------------------------------------------------

init([]) ->
Envs = application:get_all_env(ekka),
process_flag(trap_exit, true),
rand:seed(exsplus, erlang:timestamp()),
net_kernel:monitor_nodes(true, [{node_type, visible}, nodedown_reason]),
Expand Down
17 changes: 8 additions & 9 deletions test/ekka_autocluster_SUITE.erl
Expand Up @@ -131,6 +131,7 @@ t_autocluster_via_k8s(_Config) ->

t_autocluster_via_mcast(_Config) ->
ok = reboot_ekka_with_mcast_env(),
ok = timer:sleep(1000),
N1 = ekka_ct:start_slave(ekka, n1),
try
ok = ekka_ct:wait_running(N1),
Expand All @@ -152,17 +153,15 @@ reboot_ekka_with_mcast_env() ->
%%--------------------------------------------------------------------

set_app_env(Node, Discovery) ->
Envs = [{cluster_name, ekka},
{cluster_enable, true},
{cluster_discovery, Discovery}
],
lists:foreach(
fun({Par, Val}) ->
rpc:call(Node, application, set_env, [ekka, Par, Val])
end, Envs).
Config = [{ekka, [{cluster_name, ekka},
{cluster_enable, true},
{cluster_discovery, Discovery}
]
}],
rpc:call(Node, application, set_env, [Config]).

wait_for_node(Node) ->
wait_for_node(Node, 10).
wait_for_node(Node, 20).
wait_for_node(Node, 0) ->
error({autocluster_timeout, Node});
wait_for_node(Node, Cnt) ->
Expand Down
67 changes: 0 additions & 67 deletions test/ekka_dist_SUITE.erl

This file was deleted.

6 changes: 5 additions & 1 deletion test/ekka_epmd_SUITE.erl
Expand Up @@ -31,7 +31,11 @@ t_register_node(_) ->
?assert(is_integer(X) and (1 =< X) and (X =< 3)).

t_port_please(_) ->
?assertEqual({port, 4370, 5}, ekka_epmd:port_please('n@127.0.0.1', {127,0,0,1})).
?assertEqual({port, 4370, 5}, ekka_epmd:port_please('n@127.0.0.1', {127,0,0,1})),
?assertEqual({port, 4370, 5}, ekka_epmd:port_please('n0@127.0.0.1', {127,0,0,1})),
?assertEqual({port, 4371, 5}, ekka_epmd:port_please('n1@127.0.0.1', {127,0,0,1})),
?assertEqual({port, 4372, 5}, ekka_epmd:port_please('n2@127.0.0.1', {127,0,0,1})),
?assertEqual({port, 4470, 5}, ekka_epmd:port_please('n100@127.0.0.1', {127,0,0,1})).

t_names(_) ->
?assertEqual({error, address}, ekka_epmd:names()).
Expand Down
66 changes: 37 additions & 29 deletions test/ekka_mnesia_SUITE.erl
Expand Up @@ -52,44 +52,52 @@ t_create_del_table(_) ->
%% -spec(leave_cluster(node()) -> ok | {error, any()}).
t_join_leave_cluster(_) ->
N0 = node(),
io:format("!!! N0: ~p~n", [N0]),
N1 = ekka_ct:start_slave(node, n1),
ok = rpc:call(N1, ekka_mnesia, start, []),
ok = rpc:call(N1, ekka_mnesia, join_cluster, [N0]),
#{running_nodes := [N0, N1]} = ekka_mnesia:cluster_info(),
[N0, N1] = lists:sort(ekka_mnesia:running_nodes()),
ok = rpc:call(N1, ekka_mnesia, leave_cluster, []),
#{running_nodes := [N0]} = ekka_mnesia:cluster_info(),
[N0] = ekka_mnesia:running_nodes(),
ok = rpc:call(N1, ekka_mnesia, ensure_stopped, []),
ok = ekka_ct:stop_slave(N1).
try
ok = rpc:call(N1, ekka_mnesia, start, []),
ok = rpc:call(N1, ekka_mnesia, join_cluster, [N0]),
#{running_nodes := [N0, N1]} = ekka_mnesia:cluster_info(),
[N0, N1] = lists:sort(ekka_mnesia:running_nodes()),
ok = rpc:call(N1, ekka_mnesia, leave_cluster, []),
#{running_nodes := [N0]} = ekka_mnesia:cluster_info(),
[N0] = ekka_mnesia:running_nodes(),
ok = rpc:call(N1, ekka_mnesia, ensure_stopped, [])
after
ok = ekka_ct:stop_slave(N1)
end.

%% -spec(cluster_status(node()) -> running | stopped | false).
t_cluster_status(_) ->
N0 = node(),
N1 = ekka_ct:start_slave(node, n1),
ok = rpc:call(N1, ekka_mnesia, start, []),
ok = rpc:call(N1, ekka_mnesia, join_cluster, [N0]),
running = ekka_mnesia:cluster_status(N1),
ok = rpc:call(N1, ekka_mnesia, leave_cluster, []),
ok = ekka_ct:stop_slave(N1).
try
ok = rpc:call(N1, ekka_mnesia, start, []),
ok = rpc:call(N1, ekka_mnesia, join_cluster, [N0]),
running = ekka_mnesia:cluster_status(N1),
ok = rpc:call(N1, ekka_mnesia, leave_cluster, [])
after
ok = ekka_ct:stop_slave(N1)
end.

%% -spec(remove_from_cluster(node()) -> ok | {error, any()}).
t_remove_from_cluster(_) ->
N0 = node(),
N1 = ekka_ct:start_slave(node, n1),
ok = rpc:call(N1, ekka_mnesia, start, []),
ok = rpc:call(N1, ekka_mnesia, join_cluster, [N0]),
#{running_nodes := [N0, N1]} = ekka_mnesia:cluster_info(),
[N0, N1] = lists:sort(ekka_mnesia:running_nodes()),
[N0, N1] = lists:sort(ekka_mnesia:cluster_nodes(all)),
[N0, N1] = lists:sort(ekka_mnesia:cluster_nodes(running)),
[] = ekka_mnesia:cluster_nodes(stopped),
ok = ekka_mnesia:remove_from_cluster(N1),
#{running_nodes := [N0]} = ekka_mnesia:cluster_info(),
[N0] = ekka_mnesia:running_nodes(),
[N0] = ekka_mnesia:cluster_nodes(all),
[N0] = ekka_mnesia:cluster_nodes(running),
ok = rpc:call(N1, ekka_mnesia, ensure_stopped, []),
ok = ekka_ct:stop_slave(N1).
try
ok = rpc:call(N1, ekka_mnesia, start, []),
ok = rpc:call(N1, ekka_mnesia, join_cluster, [N0]),
#{running_nodes := [N0, N1]} = ekka_mnesia:cluster_info(),
[N0, N1] = lists:sort(ekka_mnesia:running_nodes()),
[N0, N1] = lists:sort(ekka_mnesia:cluster_nodes(all)),
[N0, N1] = lists:sort(ekka_mnesia:cluster_nodes(running)),
[] = ekka_mnesia:cluster_nodes(stopped),
ok = ekka_mnesia:remove_from_cluster(N1),
#{running_nodes := [N0]} = ekka_mnesia:cluster_info(),
[N0] = ekka_mnesia:running_nodes(),
[N0] = ekka_mnesia:cluster_nodes(all),
[N0] = ekka_mnesia:cluster_nodes(running),
ok = rpc:call(N1, ekka_mnesia, ensure_stopped, [])
after
ok = ekka_ct:stop_slave(N1)
end.

0 comments on commit a7b10c2

Please sign in to comment.