Fix testcases warns (#3906)

This commit is contained in:
Shawn 2020-12-11 18:54:48 +08:00 committed by GitHub
parent c8d949bc0d
commit 10dbb5bc96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 31 additions and 57 deletions

View File

@ -19,9 +19,8 @@ ensure-rebar3:
$(REBAR): ensure-rebar3 $(REBAR): ensure-rebar3
.PHONY: distclean ct: $(REBAR)
distclean: $(REBAR) ct
@rm -rf _build
.PHONY: $(PROFILES) .PHONY: $(PROFILES)
$(PROFILES:%=%): $(REBAR) $(PROFILES:%=%): $(REBAR)

View File

@ -16,8 +16,8 @@
-module(emqx_auth_ldap_bind_as_user_SUITE). -module(emqx_auth_ldap_bind_as_user_SUITE).
-compile(nowarn_export_all).
-compile(export_all). -compile(export_all).
-compile(no_warning_export).
-include_lib("emqx/include/emqx.hrl"). -include_lib("emqx/include/emqx.hrl").
-include_lib("eunit/include/eunit.hrl"). -include_lib("eunit/include/eunit.hrl").

View File

@ -16,6 +16,7 @@
-module(emqx_acl_mnesia_SUITE). -module(emqx_acl_mnesia_SUITE).
-compile(nowarn_export_all).
-compile(export_all). -compile(export_all).
-include("emqx_auth_mnesia.hrl"). -include("emqx_auth_mnesia.hrl").

View File

@ -13,6 +13,7 @@
-module(emqx_auth_mnesia_SUITE). -module(emqx_auth_mnesia_SUITE).
-compile(nowarn_export_all).
-compile(export_all). -compile(export_all).
-include("emqx_auth_mnesia.hrl"). -include("emqx_auth_mnesia.hrl").

View File

@ -16,6 +16,7 @@
-module(emqx_auth_pgsql_SUITE). -module(emqx_auth_pgsql_SUITE).
-compile(nowarn_export_all).
-compile(export_all). -compile(export_all).
-define(POOL, emqx_auth_pgsql). -define(POOL, emqx_auth_pgsql).

View File

@ -16,6 +16,7 @@
-module(emqx_auth_redis_SUITE). -module(emqx_auth_redis_SUITE).
-compile(nowarn_export_all).
-compile(export_all). -compile(export_all).
-include_lib("emqx/include/emqx.hrl"). -include_lib("emqx/include/emqx.hrl").

View File

@ -124,39 +124,6 @@ manual_start_stop_test() ->
emqx_bridge_worker:ensure_stopped(?BRIDGE_REG_NAME), emqx_bridge_worker:ensure_stopped(?BRIDGE_REG_NAME),
emqx_metrics:stop(). emqx_metrics:stop().
%% Feed messages to bridge
sender_loop(_Pid, [], _) -> exit(normal);
sender_loop(Pid, [Num | Rest], Interval) ->
random_sleep(Interval),
Pid ! {deliver, dummy, make_msg(Num)},
sender_loop(Pid, Rest, Interval).
%% Feed acknowledgments to bridge
receiver_loop(_Pid, [], _) -> ok;
receiver_loop(Pid, Nums, Interval) ->
receive
{batch, BatchRef, Batch} ->
Rest = match_nums(Batch, Nums),
random_sleep(Interval),
emqx_bridge_worker:handle_ack(Pid, BatchRef),
receiver_loop(Pid, Rest, Interval)
end.
random_sleep(MaxInterval) ->
case rand:uniform(MaxInterval) - 1 of
0 -> ok;
T -> timer:sleep(T)
end.
match_nums([], Rest) -> Rest;
match_nums([#message{payload = P} | Rest], Nums) ->
I = binary_to_integer(P),
case Nums of
[I | NumsLeft] -> match_nums(Rest, NumsLeft);
[J | _] when J > I -> match_nums(Rest, Nums); %% allow retry
_ -> error([{received, I}, {expecting, Nums}])
end.
make_config(Ref, TestPid, Result) -> make_config(Ref, TestPid, Result) ->
#{test_pid => TestPid, #{test_pid => TestPid,
test_ref => Ref, test_ref => Ref,
@ -165,8 +132,3 @@ make_config(Ref, TestPid, Result) ->
connect_result => Result, connect_result => Result,
start_type => auto start_type => auto
}. }.
make_msg(I) ->
Payload = integer_to_binary(I),
emqx_message:make(<<"test/topic">>, Payload).

View File

@ -84,7 +84,7 @@ t_observe(_Config) ->
Notif = receive_notification(), Notif = receive_notification(),
?LOGT("observer get Notif=~p", [Notif]), ?LOGT("observer get Notif=~p", [Notif]),
{coap_notify, _, _, {ok,content}, #coap_content{payload = PayloadRecv}} = Notif, {coap_notify, _, _, {ok,content}, #coap_content{payload = PayloadRecv}} = Notif,
?_assertEqual(Payload, PayloadRecv), ?assertEqual(Payload, PayloadRecv),
er_coap_observer:stop(Pid), er_coap_observer:stop(Pid),
timer:sleep(100), timer:sleep(100),
@ -107,7 +107,7 @@ t_observe_wildcard(_Config) ->
Notif = receive_notification(), Notif = receive_notification(),
?LOGT("observer get Notif=~p", [Notif]), ?LOGT("observer get Notif=~p", [Notif]),
{coap_notify, _, _, {ok,content}, #coap_content{payload = PayloadRecv}} = Notif, {coap_notify, _, _, {ok,content}, #coap_content{payload = PayloadRecv}} = Notif,
?_assertEqual(Payload, PayloadRecv), ?assertEqual(Payload, PayloadRecv),
er_coap_observer:stop(Pid), er_coap_observer:stop(Pid),
timer:sleep(100), timer:sleep(100),
@ -133,7 +133,7 @@ t_observe_pub(_Config) ->
Notif2 = receive_notification(), Notif2 = receive_notification(),
?LOGT("observer get Notif2=~p", [Notif2]), ?LOGT("observer get Notif2=~p", [Notif2]),
{coap_notify, _, _, {ok,content}, #coap_content{payload = PayloadRecv2}} = Notif2, {coap_notify, _, _, {ok,content}, #coap_content{payload = PayloadRecv2}} = Notif2,
?_assertEqual(Payload2, PayloadRecv2), ?assertEqual(Payload2, PayloadRecv2),
Topic3 = <<"j/b">>, Payload3 = <<"ET629">>, Topic3 = <<"j/b">>, Payload3 = <<"ET629">>,
TopicStr3 = http_uri:encode(binary_to_list(Topic3)), TopicStr3 = http_uri:encode(binary_to_list(Topic3)),
@ -144,7 +144,7 @@ t_observe_pub(_Config) ->
Notif3 = receive_notification(), Notif3 = receive_notification(),
?LOGT("observer get Notif3=~p", [Notif3]), ?LOGT("observer get Notif3=~p", [Notif3]),
{coap_notify, _, _, {ok,content}, #coap_content{payload = PayloadRecv3}} = Notif3, {coap_notify, _, _, {ok,content}, #coap_content{payload = PayloadRecv3}} = Notif3,
?_assertEqual(Payload3, PayloadRecv3), ?assertEqual(Payload3, PayloadRecv3),
er_coap_observer:stop(Pid). er_coap_observer:stop(Pid).
@ -172,14 +172,14 @@ t_one_clientid_sub_2_topics(_Config) ->
Notif1 = receive_notification(), Notif1 = receive_notification(),
?LOGT("observer 1 get Notif=~p", [Notif1]), ?LOGT("observer 1 get Notif=~p", [Notif1]),
{coap_notify, _, _, {ok,content}, #coap_content{payload = PayloadRecv1}} = Notif1, {coap_notify, _, _, {ok,content}, #coap_content{payload = PayloadRecv1}} = Notif1,
?_assertEqual(Payload1, PayloadRecv1), ?assertEqual(Payload1, PayloadRecv1),
emqx:publish(emqx_message:make(Topic2, Payload2)), emqx:publish(emqx_message:make(Topic2, Payload2)),
Notif2 = receive_notification(), Notif2 = receive_notification(),
?LOGT("observer 2 get Notif=~p", [Notif2]), ?LOGT("observer 2 get Notif=~p", [Notif2]),
{coap_notify, _, _, {ok,content}, #coap_content{payload = PayloadRecv2}} = Notif2, {coap_notify, _, _, {ok,content}, #coap_content{payload = PayloadRecv2}} = Notif2,
?_assertEqual(Payload2, PayloadRecv2), ?assertEqual(Payload2, PayloadRecv2),
er_coap_observer:stop(Pid1), er_coap_observer:stop(Pid1),
er_coap_observer:stop(Pid2). er_coap_observer:stop(Pid2).

View File

@ -417,13 +417,13 @@ t_case01_subscribe(_Config) ->
?LOGT("observer get Notif=~p", [Notif]), ?LOGT("observer get Notif=~p", [Notif]),
{coap_notify, _, _, {ok,content}, #coap_content{payload = PayloadRecv}} = Notif, {coap_notify, _, _, {ok,content}, #coap_content{payload = PayloadRecv}} = Notif,
?_assertEqual(Payload, PayloadRecv), ?assertEqual(Payload, PayloadRecv),
%% GET to read the publish message of the topic %% GET to read the publish message of the topic
Reply1 = er_coap_client:request(get, Uri1), Reply1 = er_coap_client:request(get, Uri1),
?LOGT("Reply=~p", [Reply1]), ?LOGT("Reply=~p", [Reply1]),
{ok,content, #coap_content{max_age = MaxAgeLeft,payload = <<"123">>}} = Reply1, {ok,content, #coap_content{max_age = MaxAgeLeft,payload = <<"123">>}} = Reply1,
?_assertEqual(true, MaxAgeLeft<60), ?assertEqual(true, MaxAgeLeft<60),
er_coap_observer:stop(Pid), er_coap_observer:stop(Pid),
{ok, deleted, #coap_content{}} = er_coap_client:request(delete, Uri1). {ok, deleted, #coap_content{}} = er_coap_client:request(delete, Uri1).
@ -515,7 +515,7 @@ t_case01_read(_Config) ->
Reply1 = er_coap_client:request(get, Uri), Reply1 = er_coap_client:request(get, Uri),
?LOGT("Reply=~p", [Reply1]), ?LOGT("Reply=~p", [Reply1]),
{ok,content, #coap_content{max_age = MaxAgeLeft,payload = Payload}} = Reply1, {ok,content, #coap_content{max_age = MaxAgeLeft,payload = Payload}} = Reply1,
?_assertEqual(true, MaxAgeLeft<60), ?assertEqual(true, MaxAgeLeft<60),
{ok, deleted, #coap_content{}} = er_coap_client:request(delete, Uri). {ok, deleted, #coap_content{}} = er_coap_client:request(delete, Uri).

View File

@ -16,6 +16,7 @@
-module(emqx_dashboard_SUITE). -module(emqx_dashboard_SUITE).
-compile(nowarn_export_all).
-compile(export_all). -compile(export_all).
-import(emqx_ct_http, -import(emqx_ct_http,

View File

@ -16,6 +16,7 @@
-module(test_mqtt_broker). -module(test_mqtt_broker).
-compile(nowarn_export_all).
-compile(export_all). -compile(export_all).
-define(LOGT(Format, Args), logger:debug("TEST_BROKER: " ++ Format, Args)). -define(LOGT(Format, Args), logger:debug("TEST_BROKER: " ++ Format, Args)).
@ -28,8 +29,6 @@
-include_lib("eunit/include/eunit.hrl"). -include_lib("eunit/include/eunit.hrl").
-import(proplists, [get_value/2, get_value/3]).
start(_, <<"attacker">>, _, _, _) -> start(_, <<"attacker">>, _, _, _) ->
{stop, auth_failure}; {stop, auth_failure};
start(ClientId, Username, Password, _Channel, KeepaliveInterval) -> start(ClientId, Username, Password, _Channel, KeepaliveInterval) ->
@ -51,7 +50,7 @@ unsubscribe(Topic) ->
gen_server:call(?MODULE, {unsubscribe, Topic}). gen_server:call(?MODULE, {unsubscribe, Topic}).
get_subscrbied_topics() -> get_subscrbied_topics() ->
[Topic || {Client, Topic} <- ets:tab2list(emqx_subscription)]. [Topic || {_Client, Topic} <- ets:tab2list(emqx_subscription)].
start_link() -> start_link() ->
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []). gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).

View File

@ -16,6 +16,7 @@
-module(emqx_plugin_template_SUITE). -module(emqx_plugin_template_SUITE).
-compile(nowarn_export_all).
-compile(export_all). -compile(export_all).
all() -> []. all() -> [].

View File

@ -16,6 +16,7 @@
-module(emqx_prometheus_SUITE). -module(emqx_prometheus_SUITE).
-compile(nowarn_export_all).
-compile(export_all). -compile(export_all).
all() -> all() ->

View File

@ -15,6 +15,7 @@
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
-module(emqx_psk_file_SUITE). -module(emqx_psk_file_SUITE).
-compile(nowarn_export_all).
-compile(export_all). -compile(export_all).
all() -> []. all() -> [].

View File

@ -16,6 +16,7 @@
-module(emqx_recon_SUITE). -module(emqx_recon_SUITE).
-compile(nowarn_export_all).
-compile(export_all). -compile(export_all).
-include_lib("eunit/include/eunit.hrl"). -include_lib("eunit/include/eunit.hrl").

View File

@ -177,7 +177,7 @@ handle_info(Info, State) ->
?LOG(error, "Unexpected info: ~p", [Info]), ?LOG(error, "Unexpected info: ~p", [Info]),
{noreply, State}. {noreply, State}.
terminate(_Reason, #state{stats_timer = TRef1, expiry_timer = TRef2} = State) -> terminate(_Reason, #state{stats_timer = TRef1, expiry_timer = TRef2}) ->
_ = timer:cancel(TRef1), _ = timer:cancel(TRef1),
_ = timer:cancel(TRef2), _ = timer:cancel(TRef2),
ok. ok.

View File

@ -2103,7 +2103,7 @@ failure_action(_Id, _Params) ->
crash_action(_Id, _Params) -> crash_action(_Id, _Params) ->
fun(Data, _Envs) -> fun(Data, _Envs) ->
ct:pal("applying crash action, Data: ~p", [Data]), ct:pal("applying crash action, Data: ~p", [Data]),
1/0 error(crash)
end. end.
init_plus_by_one_action() -> init_plus_by_one_action() ->

View File

@ -25,6 +25,7 @@
{cover_enabled, true}. {cover_enabled, true}.
{cover_opts, [verbose]}. {cover_opts, [verbose]}.
{cover_export_enabled, true}. {cover_export_enabled, true}.
{cover_excl_mods, [emqx_exproto_pb, emqx_exhook_pb]}.
{provider_hooks,[{pre,[{release,{relup_helper,gen_appups}}]}, {provider_hooks,[{pre,[{release,{relup_helper,gen_appups}}]},
{post,[{release,{relup_helper,otp_vsn}}, {post,[{release,{relup_helper,otp_vsn}},

View File

@ -48,7 +48,7 @@ profiles() ->
, {check, [ {erl_opts, [debug_info]} , {check, [ {erl_opts, [debug_info]}
]} ]}
, {test, [ {deps, test_deps()} , {test, [ {deps, test_deps()}
, {erl_opts, [debug_info]} , {erl_opts, [debug_info] ++ erl_opts_i()}
]} ]}
]. ].
@ -212,3 +212,6 @@ path(Dir, Path) -> str(filename:join([Dir, Path])).
str(L) when is_list(L) -> L; str(L) when is_list(L) -> L;
str(B) when is_binary(B) -> unicode:characters_to_list(B, utf8). str(B) when is_binary(B) -> unicode:characters_to_list(B, utf8).
erl_opts_i() ->
[{i, Dir} || Dir <- filelib:wildcard("apps/**/include")].

View File

@ -16,6 +16,7 @@
-module(emqx_passwd_SUITE). -module(emqx_passwd_SUITE).
-compile(nowarn_export_all).
-compile(export_all). -compile(export_all).
all() -> [t_hash]. all() -> [t_hash].