|
|
@@ -20,7 +20,6 @@
|
|
|
-compile(nowarn_export_all).
|
|
|
|
|
|
-include_lib("eunit/include/eunit.hrl").
|
|
|
--include_lib("emqx/include/emqx_hooks.hrl").
|
|
|
-include_lib("emqx/include/emqx.hrl").
|
|
|
-include_lib("emqx/include/emqx_mqtt.hrl").
|
|
|
-include_lib("snabbkaffe/include/snabbkaffe.hrl").
|
|
|
@@ -44,14 +43,6 @@
|
|
|
-define(TCPOPTS, [binary, {active, false}]).
|
|
|
-define(DTLSOPTS, [binary, {active, false}, {protocol, dtls}]).
|
|
|
|
|
|
--define(PORT, 7993).
|
|
|
-
|
|
|
--define(DEFAULT_CLIENT, #{
|
|
|
- proto_name => <<"demo">>,
|
|
|
- proto_ver => <<"v0.1">>,
|
|
|
- clientid => <<"test_client_1">>
|
|
|
-}).
|
|
|
-
|
|
|
%%--------------------------------------------------------------------
|
|
|
-define(CONF_DEFAULT, <<
|
|
|
"\n"
|
|
|
@@ -126,15 +117,33 @@ init_per_group(_, Cfg) ->
|
|
|
|
|
|
init_per_group(LisType, ServiceName, Scheme, Cfg) ->
|
|
|
Svrs = emqx_exproto_echo_svr:start(Scheme),
|
|
|
- application:load(emqx_gateway_exproto),
|
|
|
- emqx_common_test_helpers:start_apps(
|
|
|
- [emqx_conf, emqx_auth, emqx_gateway],
|
|
|
- fun(App) ->
|
|
|
- set_special_cfg(App, LisType, ServiceName, Scheme)
|
|
|
- end
|
|
|
+ Addrs = lists:flatten(io_lib:format("~s://127.0.0.1:9001", [Scheme])),
|
|
|
+ GWConfig = #{
|
|
|
+ server => #{bind => 9100},
|
|
|
+ idle_timeout => 5000,
|
|
|
+ mountpoint => <<"ct/">>,
|
|
|
+ handler => #{
|
|
|
+ address => Addrs,
|
|
|
+ service_name => ServiceName,
|
|
|
+ ssl_options => #{enable => Scheme == https}
|
|
|
+ },
|
|
|
+ listeners => listener_confs(LisType)
|
|
|
+ },
|
|
|
+ Apps = emqx_cth_suite:start(
|
|
|
+ [
|
|
|
+ emqx_conf,
|
|
|
+ emqx_auth,
|
|
|
+ {emqx_gateway, #{
|
|
|
+ config =>
|
|
|
+ #{gateway => #{exproto => GWConfig}}
|
|
|
+ }},
|
|
|
+ emqx_gateway_exproto
|
|
|
+ ],
|
|
|
+ #{work_dir => emqx_cth_suite:work_dir(Cfg)}
|
|
|
),
|
|
|
[
|
|
|
{servers, Svrs},
|
|
|
+ {apps, Apps},
|
|
|
{listener_type, LisType},
|
|
|
{service_name, ServiceName},
|
|
|
{grpc_client_scheme, Scheme}
|
|
|
@@ -142,8 +151,7 @@ init_per_group(LisType, ServiceName, Scheme, Cfg) ->
|
|
|
].
|
|
|
|
|
|
end_per_group(_, Cfg) ->
|
|
|
- emqx_config:erase(gateway),
|
|
|
- emqx_common_test_helpers:stop_apps([emqx_gateway, emqx_auth, emqx_conf]),
|
|
|
+ ok = emqx_cth_suite:stop(proplists:get_value(apps, Cfg)),
|
|
|
emqx_exproto_echo_svr:stop(proplists:get_value(servers, Cfg)).
|
|
|
|
|
|
init_per_testcase(TestCase, Cfg) when
|
|
|
@@ -159,27 +167,12 @@ init_per_testcase(_TestCase, Cfg) ->
|
|
|
end_per_testcase(_TestCase, _Cfg) ->
|
|
|
ok.
|
|
|
|
|
|
-set_special_cfg(emqx_gateway, LisType, ServiceName, Scheme) ->
|
|
|
- Addrs = lists:flatten(io_lib:format("~s://127.0.0.1:9001", [Scheme])),
|
|
|
- emqx_config:put(
|
|
|
- [gateway, exproto],
|
|
|
- #{
|
|
|
- server => #{bind => 9100},
|
|
|
- idle_timeout => 5000,
|
|
|
- mountpoint => <<"ct/">>,
|
|
|
- handler => #{
|
|
|
- address => Addrs,
|
|
|
- service_name => ServiceName,
|
|
|
- ssl_options => #{enable => Scheme == https}
|
|
|
- },
|
|
|
- listeners => listener_confs(LisType)
|
|
|
- }
|
|
|
- );
|
|
|
-set_special_cfg(_, _, _, _) ->
|
|
|
- ok.
|
|
|
-
|
|
|
listener_confs(Type) ->
|
|
|
- Default = #{bind => 7993, acceptors => 8},
|
|
|
+ Default = #{
|
|
|
+ bind => 7993,
|
|
|
+ max_connections => 64,
|
|
|
+ access_rules => ["allow all"]
|
|
|
+ },
|
|
|
#{Type => #{'default' => maps:merge(Default, socketopts(Type))}}.
|
|
|
|
|
|
default_config() ->
|
|
|
@@ -636,9 +629,13 @@ close({dtls, Sock}) ->
|
|
|
%% Server-Opts
|
|
|
|
|
|
socketopts(tcp) ->
|
|
|
- #{tcp_options => tcp_opts()};
|
|
|
+ #{
|
|
|
+ acceptors => 8,
|
|
|
+ tcp_options => tcp_opts()
|
|
|
+ };
|
|
|
socketopts(ssl) ->
|
|
|
#{
|
|
|
+ acceptors => 8,
|
|
|
tcp_options => tcp_opts(),
|
|
|
ssl_options => ssl_opts()
|
|
|
};
|
|
|
@@ -646,6 +643,7 @@ socketopts(udp) ->
|
|
|
#{udp_options => udp_opts()};
|
|
|
socketopts(dtls) ->
|
|
|
#{
|
|
|
+ acceptors => 8,
|
|
|
udp_options => udp_opts(),
|
|
|
dtls_options => dtls_opts()
|
|
|
}.
|