test(emqx_cluster_rpc): fix test cases
This commit is contained in:
parent
196ca43fbb
commit
5925ff07c2
|
@ -278,6 +278,8 @@ init([Node, RetryMs]) ->
|
||||||
|
|
||||||
%% @private
|
%% @private
|
||||||
handle_continue(?CATCH_UP, State) ->
|
handle_continue(?CATCH_UP, State) ->
|
||||||
|
%% emqx app must be started before
|
||||||
|
%% trying to catch up the rpc commit logs
|
||||||
ok = wait_for_emqx_ready(),
|
ok = wait_for_emqx_ready(),
|
||||||
{noreply, State, catch_up(State)}.
|
{noreply, State, catch_up(State)}.
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ groups() -> [].
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
application:load(emqx_conf),
|
application:load(emqx_conf),
|
||||||
ok = ekka:start(),
|
ok = ekka:start(),
|
||||||
|
ok = emqx_common_test_helpers:start_apps([]),
|
||||||
ok = mria_rlog:wait_for_shards([?CLUSTER_RPC_SHARD], infinity),
|
ok = mria_rlog:wait_for_shards([?CLUSTER_RPC_SHARD], infinity),
|
||||||
ok = emqx_config:put([node, cluster_call, retry_interval], 1000),
|
ok = emqx_config:put([node, cluster_call, retry_interval], 1000),
|
||||||
meck:new(emqx_alarm, [non_strict, passthrough, no_link]),
|
meck:new(emqx_alarm, [non_strict, passthrough, no_link]),
|
||||||
|
@ -53,6 +54,7 @@ init_per_suite(Config) ->
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
end_per_suite(_Config) ->
|
end_per_suite(_Config) ->
|
||||||
|
ok = emqx_common_test_helpers:stop_apps([]),
|
||||||
ekka:stop(),
|
ekka:stop(),
|
||||||
mria:stop(),
|
mria:stop(),
|
||||||
meck:unload(mria),
|
meck:unload(mria),
|
||||||
|
@ -255,13 +257,13 @@ t_fast_forward_commit(_Config) ->
|
||||||
),
|
),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
t_handler_unexpected_msg(_Config) ->
|
t_cleaner_unexpected_msg(_Config) ->
|
||||||
Handler = emqx_cluster_rpc_handler,
|
Cleaner = emqx_cluster_cleaner,
|
||||||
OldPid = erlang:whereis(Handler),
|
OldPid = erlang:whereis(Cleaner),
|
||||||
ok = gen_server:cast(Handler, unexpected_cast_msg),
|
ok = gen_server:cast(Cleaner, unexpected_cast_msg),
|
||||||
ignore = gen_server:call(Handler, unexpected_cast_msg),
|
ignore = gen_server:call(Cleaner, unexpected_cast_msg),
|
||||||
erlang:send(Handler, unexpected_info_msg),
|
erlang:send(Cleaner, unexpected_info_msg),
|
||||||
NewPid = erlang:whereis(Handler),
|
NewPid = erlang:whereis(Cleaner),
|
||||||
?assertEqual(OldPid, NewPid),
|
?assertEqual(OldPid, NewPid),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
@ -279,8 +281,8 @@ start() ->
|
||||||
{ok, Pid1} = emqx_cluster_rpc:start_link(),
|
{ok, Pid1} = emqx_cluster_rpc:start_link(),
|
||||||
{ok, Pid2} = emqx_cluster_rpc:start_link({node(), ?NODE2}, ?NODE2, 500),
|
{ok, Pid2} = emqx_cluster_rpc:start_link({node(), ?NODE2}, ?NODE2, 500),
|
||||||
{ok, Pid3} = emqx_cluster_rpc:start_link({node(), ?NODE3}, ?NODE3, 500),
|
{ok, Pid3} = emqx_cluster_rpc:start_link({node(), ?NODE3}, ?NODE3, 500),
|
||||||
{ok, Pid4} = emqx_cluster_rpc_handler:start_link(100, 500),
|
{ok, Pid4} = emqx_cluster_rpc_cleaner:start_link(100, 500),
|
||||||
true = erlang:register(emqx_cluster_rpc_handler, Pid4),
|
true = erlang:register(emqx_cluster_rpc_cleaner, Pid4),
|
||||||
{ok, [Pid1, Pid2, Pid3, Pid4]}.
|
{ok, [Pid1, Pid2, Pid3, Pid4]}.
|
||||||
|
|
||||||
stop() ->
|
stop() ->
|
||||||
|
@ -296,7 +298,7 @@ stop() ->
|
||||||
end
|
end
|
||||||
|| N <- [?NODE1, ?NODE2, ?NODE3]
|
|| N <- [?NODE1, ?NODE2, ?NODE3]
|
||||||
],
|
],
|
||||||
gen_server:stop(emqx_cluster_rpc_handler, normal, 5000).
|
gen_server:stop(emqx_cluster_rpc_cleaner, normal, 5000).
|
||||||
|
|
||||||
receive_msg(0, _Msg) ->
|
receive_msg(0, _Msg) ->
|
||||||
ok;
|
ok;
|
||||||
|
|
Loading…
Reference in New Issue