chore: ensure emqx_gateway_ocpp tests pass

This commit is contained in:
JianBo He 2023-11-06 12:26:58 +08:00
parent bea0acd929
commit 8871738756
8 changed files with 14 additions and 36 deletions

View File

@ -160,10 +160,10 @@ cluster_gateway_status(GwName) ->
max_connections_count(Config) ->
Listeners = emqx_gateway_utils:normalize_config(Config),
lists:foldl(
fun({_, _, _, SocketOpts, _}, Acc) ->
fun({_, _, _, Conf0}, Acc) ->
emqx_gateway_utils:plus_max_connections(
Acc,
proplists:get_value(max_connections, SocketOpts, 0)
maps:get(max_connections, Conf0, 0)
)
end,
0,
@ -184,7 +184,7 @@ current_connections_count(GwName) ->
get_listeners_status(GwName, Config) ->
Listeners = emqx_gateway_utils:normalize_config(Config),
lists:map(
fun({Type, LisName, ListenOn, _, _}) ->
fun({Type, LisName, ListenOn, _}) ->
Name0 = listener_id(GwName, Type, LisName),
Name = {Name0, ListenOn},
LisO = #{id => Name0, type => Type, name => LisName},

View File

@ -309,8 +309,8 @@ stop_listeners(GwName, Listeners) ->
lists:foreach(fun(L) -> stop_listener(GwName, L) end, Listeners).
-spec stop_listener(GwName :: atom(), Listener :: tuple()) -> ok.
stop_listener(GwName, {Type, LisName, ListenOn, SocketOpts, Cfg}) ->
StopRet = stop_listener(GwName, Type, LisName, ListenOn, SocketOpts, Cfg),
stop_listener(GwName, {Type, LisName, ListenOn, Cfg}) ->
StopRet = stop_listener(GwName, Type, LisName, ListenOn, Cfg),
ListenOnStr = emqx_listeners:format_bind(ListenOn),
case StopRet of
ok ->
@ -326,7 +326,7 @@ stop_listener(GwName, {Type, LisName, ListenOn, SocketOpts, Cfg}) ->
end,
StopRet.
stop_listener(GwName, Type, LisName, ListenOn, _SocketOpts, _Cfg) ->
stop_listener(GwName, Type, LisName, ListenOn, _Cfg) ->
Name = emqx_gateway_utils:listener_id(GwName, Type, LisName),
esockd:close(Name, ListenOn).
@ -443,8 +443,7 @@ stringfy(T) ->
Type :: udp | tcp | ssl | dtls,
Name :: atom(),
ListenOn :: esockd:listen_on(),
RawCfg :: map(),
ConnCfg :: map()
RawCfg :: map()
}).
normalize_config(RawConf) ->
LisMap = maps:get(listeners, RawConf, #{}),

View File

@ -1,19 +0,0 @@
%% -*- mode: erlang -*-
{VSN,
[{"4.4.1",[
{load_module,emqx_ocpp_connection,brutal_purge,soft_purge,[]}
]},
{"4.4.0",[
{load_module,emqx_ocpp_connection,brutal_purge,soft_purge,[]}
]},
{<<".*">>, []}
],
[{"4.4.1",[
{load_module,emqx_ocpp_connection,brutal_purge,soft_purge,[]}
]},
{"4.4.0",[
{load_module,emqx_ocpp_connection,brutal_purge,soft_purge,[]}
]},
{<<".*">>, []}
]
}.

View File

@ -19,21 +19,20 @@
-compile(export_all).
-compile(nowarn_export_all).
-include_lib("emqx_tcp.hrl").
-include_lib("emqx/include/emqx.hrl").
-include_lib("eunit/include/eunit.hrl").
-include_lib("common_test/include/ct.hrl").
all() ->
emqx_ct:all(?MODULE).
emqx_common_test_helpers:all(?MODULE).
init_per_suite(Conf) ->
emqx_ct_helpers:start_apps([emqx_ocpp], fun set_special_cfg/1),
emqx_ct_helpers:start_apps([emqx_gateway_ocpp], fun set_special_cfg/1),
Conf.
end_per_suite(_Config) ->
emqx_ct_helpers:stop_apps([emqx_ocpp]).
emqx_ct_helpers:stop_apps([emqx_gateway_ocpp]).
set_special_cfg(emqx) ->
application:set_env(emqx, allow_anonymous, true),

View File

@ -19,7 +19,7 @@
-compile(export_all).
-compile(nowarn_export_all).
all() -> emqx_ct:all(?MODULE).
all() -> emqx_common_test_helpers:all(?MODULE).
init_per_suite(Conf) ->
Conf.

View File

@ -19,14 +19,13 @@
-compile(export_all).
-compile(nowarn_export_all).
-include_lib("emqx_tcp.hrl").
-include_lib("emqx/include/emqx.hrl").
-include_lib("eunit/include/eunit.hrl").
-include_lib("common_test/include/ct.hrl").
all() ->
emqx_ct:all(?MODULE).
emqx_common_test_helpers:all(?MODULE).
init_per_suite(Conf) ->
Conf.

View File

@ -21,7 +21,7 @@
-include_lib("eunit/include/eunit.hrl").
all() -> emqx_ct:all(?MODULE).
all() -> emqx_common_test_helpers:all(?MODULE).
t_check(_) ->
Keepalive = emqx_ocpp_keepalive:init(60),

View File

@ -59,6 +59,6 @@ gateway.ocpp {
listeners.ws.default {
bind = "0.0.0.0:33033"
path = "/ocpp"
websocket.path = "/ocpp"
}
}