Fix emqx_rpc badargs bug

This commit is contained in:
YoukiLin 2019-03-16 21:27:41 +08:00 committed by Gilbert
parent 763115e149
commit 88c32b2c41
3 changed files with 39 additions and 15 deletions

View File

@ -38,7 +38,7 @@ CT_SUITES = emqx emqx_client emqx_zone emqx_banned emqx_session \
emqx_listeners emqx_protocol emqx_pool emqx_shared_sub emqx_bridge \
emqx_hooks emqx_batch emqx_sequence emqx_pmon emqx_pd emqx_gc emqx_ws_connection \
emqx_packet emqx_connection emqx_tracer emqx_sys_mon emqx_message emqx_os_mon \
emqx_vm_mon emqx_alarm_handler
emqx_vm_mon emqx_alarm_handler emqx_rpc
CT_NODE_NAME = emqxct@127.0.0.1
CT_OPTS = -cover test/ct.cover.spec -erl_args -name $(CT_NODE_NAME)

View File

@ -24,7 +24,7 @@ call(Node, Mod, Fun, Args) ->
filter_result(?RPC:call(Node, Mod, Fun, Args)).
multicall(Nodes, Mod, Fun, Args) ->
filter_results(?RPC:multicall(Nodes, Mod, Fun, Args)).
filter_result(?RPC:multicall(Nodes, Mod, Fun, Args)).
cast(Node, Mod, Fun, Args) ->
filter_result(?RPC:cast(Node, Mod, Fun, Args)).
@ -33,18 +33,6 @@ filter_result(Delivery) ->
case Delivery of
{badrpc, Reason} -> {badrpc, Reason};
{badtcp, Reason} -> {badrpc, Reason};
Delivery1 -> Delivery1
end.
filter_results(Deliverys) ->
filter_results(Deliverys, []).
filter_results([], Acc) ->
Acc;
filter_results([Delivery | WaitDelivery], Acc) ->
case Delivery of
{badrpc, Reason} -> [{badrpc, Reason} | Acc], filter_results(WaitDelivery, Acc);
{badtcp, Reason} -> [{badrpc, Reason} | Acc], filter_results(WaitDelivery, Acc);
Delivery1 -> [Delivery1 | Acc], filter_results(WaitDelivery, Acc)
Delivery1 -> Delivery1
end.

36
test/emqx_rpc_SUITE.erl Normal file
View File

@ -0,0 +1,36 @@
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing, software
%% distributed under the License is distributed on an "AS IS" BASIS,
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%% See the License for the specific language governing permissions and
%% limitations under the License.
-module(emqx_rpc_SUITE).
-include("emqx.hrl").
-include_lib("eunit/include/eunit.hrl").
-compile(export_all).
-compile(nowarn_export_all).
-define(MASTER, 'emqxct@127.0.0.1').
all() -> [t_rpc].
init_per_suite(Config) ->
emqx_ct_broker_helpers:run_setup_steps(),
Config.
end_per_suite(_Config) ->
emqx_ct_broker_helpers:run_teardown_steps().
t_rpc(_) ->
60000 = emqx_rpc:call(?MASTER, timer, seconds, [60]),
{badrpc, _} = emqx_rpc:call(?MASTER, os, test, []),
{_, []} = emqx_rpc:multicall([?MASTER, ?MASTER], os, timestamp, []).