fix: ct failed

This commit is contained in:
Zhongwen Deng 2022-06-07 17:16:38 +08:00
parent dd873147b3
commit 5e92ef54c5
15 changed files with 32 additions and 25 deletions

View File

@ -106,7 +106,7 @@ listener_mqtt_tcp_conf() ->
mountpoint => <<>>, mountpoint => <<>>,
proxy_protocol => false, proxy_protocol => false,
proxy_protocol_timeout => 3000, proxy_protocol_timeout => 3000,
tcp => #{ tcp_options => #{
active_n => 100, active_n => 100,
backlog => 1024, backlog => 1024,
buffer => 4096, buffer => 4096,
@ -128,7 +128,7 @@ listener_mqtt_ws_conf() ->
mountpoint => <<>>, mountpoint => <<>>,
proxy_protocol => false, proxy_protocol => false,
proxy_protocol_timeout => 3000, proxy_protocol_timeout => 3000,
tcp => tcp_options =>
#{ #{
active_n => 100, active_n => 100,
backlog => 1024, backlog => 1024,

View File

@ -78,7 +78,7 @@ groups() ->
init_per_suite(Config) -> init_per_suite(Config) ->
emqx_common_test_helpers:boot_modules(all), emqx_common_test_helpers:boot_modules(all),
emqx_common_test_helpers:start_apps([]), emqx_common_test_helpers:start_apps([]),
emqx_config:put_listener_conf(ssl, default, [ssl, verify], verify_peer), emqx_config:put_listener_conf(ssl, default, [ssl_options, verify], verify_peer),
emqx_listeners:restart_listener('ssl:default'), emqx_listeners:restart_listener('ssl:default'),
Config. Config.

View File

@ -256,9 +256,9 @@ t_handle_msg_deliver(_) ->
t_handle_msg_inet_reply(_) -> t_handle_msg_inet_reply(_) ->
ok = meck:expect(emqx_pd, get_counter, fun(_) -> 10 end), ok = meck:expect(emqx_pd, get_counter, fun(_) -> 10 end),
emqx_config:put_listener_conf(tcp, default, [tcp, active_n], 0), emqx_config:put_listener_conf(tcp, default, [tcp_options, active_n], 0),
?assertMatch({ok, _St}, handle_msg({inet_reply, for_testing, ok}, st())), ?assertMatch({ok, _St}, handle_msg({inet_reply, for_testing, ok}, st())),
emqx_config:put_listener_conf(tcp, default, [tcp, active_n], 100), emqx_config:put_listener_conf(tcp, default, [tcp_options, active_n], 100),
?assertEqual(ok, handle_msg({inet_reply, for_testing, ok}, st())), ?assertEqual(ok, handle_msg({inet_reply, for_testing, ok}, st())),
?assertMatch( ?assertMatch(
{stop, {shutdown, for_testing}, _St}, {stop, {shutdown, for_testing}, _St},

View File

@ -78,7 +78,7 @@ init_per_testcase(t_wss_conn, Config) ->
listener_test => #{ listener_test => #{
bind => {{127, 0, 0, 1}, 9998}, bind => {{127, 0, 0, 1}, 9998},
limiter => #{}, limiter => #{},
ssl => #{ ssl_options => #{
cacertfile => ?CERTS_PATH("cacert.pem"), cacertfile => ?CERTS_PATH("cacert.pem"),
certfile => ?CERTS_PATH("cert.pem"), certfile => ?CERTS_PATH("cert.pem"),
keyfile => ?CERTS_PATH("key.pem") keyfile => ?CERTS_PATH("key.pem")

View File

@ -35,9 +35,9 @@ all() -> emqx_common_test_helpers:all(?MODULE).
init_per_suite(Config) -> init_per_suite(Config) ->
?check_trace( ?check_trace(
?wait_async_action( ?wait_async_action(
emqx_common_test_helpers:start_apps([]), emqx_common_test_helpers:start_apps([emqx_conf]),
#{?snk_kind := listener_started, bind := 1883}, #{?snk_kind := listener_started, bind := 1883},
timer:seconds(5) timer:seconds(10)
), ),
fun(Trace) -> fun(Trace) ->
%% more than one listener %% more than one listener

View File

@ -96,7 +96,7 @@ crud_listeners_by_id(ListenerId, NewListenerId, MinListenerId, BadId, Type) ->
MinConf = MinConf =
case OriginListener of case OriginListener of
#{ #{
<<"ssl">> := <<"ssl_options">> :=
#{ #{
<<"cacertfile">> := CaCertFile, <<"cacertfile">> := CaCertFile,
<<"certfile">> := CertFile, <<"certfile">> := CertFile,
@ -107,7 +107,7 @@ crud_listeners_by_id(ListenerId, NewListenerId, MinListenerId, BadId, Type) ->
<<"id">> => MinListenerId, <<"id">> => MinListenerId,
<<"bind">> => <<"0.0.0.0:3883">>, <<"bind">> => <<"0.0.0.0:3883">>,
<<"type">> => Type, <<"type">> => Type,
<<"ssl">> => #{ <<"ssl_options">> => #{
<<"cacertfile">> => CaCertFile, <<"cacertfile">> => CaCertFile,
<<"certfile">> => CertFile, <<"certfile">> => CertFile,
<<"keyfile">> => KeyFile <<"keyfile">> => KeyFile

View File

@ -30,11 +30,18 @@
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% Setups %% Setups
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
-define(BASE_CONF, #{
<<"dealyed">> => <<"true">>,
<<"max_delayed_messages">> => <<"0">>
}).
all() -> all() ->
emqx_common_test_helpers:all(?MODULE). emqx_common_test_helpers:all(?MODULE).
init_per_suite(Config) -> init_per_suite(Config) ->
ok = emqx_common_test_helpers:load_config(emqx_modules_schema, ?BASE_CONF, #{
raw_with_default => true
}),
emqx_common_test_helpers:start_apps([emqx_conf, emqx_modules]), emqx_common_test_helpers:start_apps([emqx_conf, emqx_modules]),
Config. Config.

View File

@ -32,7 +32,7 @@ all() ->
emqx_common_test_helpers:all(?MODULE). emqx_common_test_helpers:all(?MODULE).
init_per_suite(Config) -> init_per_suite(Config) ->
ok = emqx_common_test_helpers:load_config(emqx_modules_schema, jsx:encode(?BASE_CONF), #{ ok = emqx_common_test_helpers:load_config(emqx_modules_schema, ?BASE_CONF, #{
raw_with_default => true raw_with_default => true
}), }),

View File

@ -160,7 +160,7 @@ t_rewrite_re_error(_Config) ->
ok. ok.
t_list(_Config) -> t_list(_Config) ->
ok = emqx_common_test_helpers:load_config(emqx_modules_schema, jsx:encode(?REWRITE), #{ ok = emqx_common_test_helpers:load_config(emqx_modules_schema, ?REWRITE, #{
raw_with_default => true raw_with_default => true
}), }),
Expect = maps:get(<<"rewrite">>, ?REWRITE), Expect = maps:get(<<"rewrite">>, ?REWRITE),
@ -168,7 +168,7 @@ t_list(_Config) ->
ok. ok.
t_update(_Config) -> t_update(_Config) ->
ok = emqx_common_test_helpers:load_config(emqx_modules_schema, jsx:encode(?REWRITE), #{ ok = emqx_common_test_helpers:load_config(emqx_modules_schema, ?REWRITE, #{
raw_with_default => true raw_with_default => true
}), }),
Init = emqx_rewrite:list(), Init = emqx_rewrite:list(),
@ -186,7 +186,7 @@ t_update(_Config) ->
ok. ok.
t_update_disable(_Config) -> t_update_disable(_Config) ->
ok = emqx_common_test_helpers:load_config(emqx_modules_schema, jsx:encode(?REWRITE), #{ ok = emqx_common_test_helpers:load_config(emqx_modules_schema, ?REWRITE, #{
raw_with_default => true raw_with_default => true
}), }),
?assertEqual(ok, emqx_rewrite:update([])), ?assertEqual(ok, emqx_rewrite:update([])),
@ -203,7 +203,7 @@ t_update_disable(_Config) ->
ok. ok.
t_update_re_failed(_Config) -> t_update_re_failed(_Config) ->
ok = emqx_common_test_helpers:load_config(emqx_modules_schema, jsx:encode(?REWRITE), #{ ok = emqx_common_test_helpers:load_config(emqx_modules_schema, ?REWRITE, #{
raw_with_default => true raw_with_default => true
}), }),
Re = <<"*^test/*">>, Re = <<"*^test/*">>,
@ -260,7 +260,7 @@ receive_publish(Timeout) ->
end. end.
init() -> init() ->
ok = emqx_common_test_helpers:load_config(emqx_modules_schema, jsx:encode(?REWRITE), #{ ok = emqx_common_test_helpers:load_config(emqx_modules_schema, ?REWRITE, #{
raw_with_default => true raw_with_default => true
}), }),
ok = emqx_rewrite:enable(), ok = emqx_rewrite:enable(),

View File

@ -33,7 +33,7 @@ init_per_testcase(_, Config) ->
Config. Config.
init_per_suite(Config) -> init_per_suite(Config) ->
ok = emqx_common_test_helpers:load_config(emqx_modules_schema, jsx:encode(?BASE_CONF), #{ ok = emqx_common_test_helpers:load_config(emqx_modules_schema, ?BASE_CONF, #{
raw_with_default => true raw_with_default => true
}), }),

View File

@ -41,7 +41,7 @@ init_per_suite(Config) ->
emqx_common_test_helpers:deps_path(emqx_authz, "etc/acl.conf") emqx_common_test_helpers:deps_path(emqx_authz, "etc/acl.conf")
end end
), ),
ok = emqx_common_test_helpers:load_config(emqx_modules_schema, jsx:encode(?BASE_CONF), #{ ok = emqx_common_test_helpers:load_config(emqx_modules_schema, ?BASE_CONF, #{
raw_with_default => true raw_with_default => true
}), }),
emqx_common_test_helpers:start_apps( emqx_common_test_helpers:start_apps(
@ -176,7 +176,7 @@ init_per_testcase(t_uuid_restored_from_file, Config) ->
%% clear the UUIDs in the DB %% clear the UUIDs in the DB
{atomic, ok} = mria:clear_table(emqx_telemetry), {atomic, ok} = mria:clear_table(emqx_telemetry),
emqx_common_test_helpers:stop_apps([emqx_conf, emqx_authn, emqx_authz, emqx_modules]), emqx_common_test_helpers:stop_apps([emqx_conf, emqx_authn, emqx_authz, emqx_modules]),
ok = emqx_common_test_helpers:load_config(emqx_modules_schema, jsx:encode(?BASE_CONF), #{ ok = emqx_common_test_helpers:load_config(emqx_modules_schema, ?BASE_CONF, #{
raw_with_default => true raw_with_default => true
}), }),
emqx_common_test_helpers:start_apps( emqx_common_test_helpers:start_apps(
@ -332,7 +332,7 @@ t_uuid_saved_to_file(_Config) ->
%% clear the UUIDs in the DB %% clear the UUIDs in the DB
{atomic, ok} = mria:clear_table(emqx_telemetry), {atomic, ok} = mria:clear_table(emqx_telemetry),
emqx_common_test_helpers:stop_apps([emqx_conf, emqx_authn, emqx_authz, emqx_modules]), emqx_common_test_helpers:stop_apps([emqx_conf, emqx_authn, emqx_authz, emqx_modules]),
ok = emqx_common_test_helpers:load_config(emqx_modules_schema, jsx:encode(?BASE_CONF), #{ ok = emqx_common_test_helpers:load_config(emqx_modules_schema, ?BASE_CONF, #{
raw_with_default => true raw_with_default => true
}), }),
emqx_common_test_helpers:start_apps( emqx_common_test_helpers:start_apps(
@ -861,7 +861,7 @@ setup_slave(Node) ->
Node, Node,
emqx_common_test_helpers, emqx_common_test_helpers,
load_config, load_config,
[emqx_modules_schema, jsx:encode(?BASE_CONF), #{raw_with_default => true}] [emqx_modules_schema, ?BASE_CONF, #{raw_with_default => true}]
), ),
ok = rpc:call( ok = rpc:call(
Node, Node,

View File

@ -29,7 +29,7 @@ all() ->
emqx_common_test_helpers:all(?MODULE). emqx_common_test_helpers:all(?MODULE).
init_per_suite(Config) -> init_per_suite(Config) ->
ok = emqx_common_test_helpers:load_config(emqx_modules_schema, jsx:encode(?BASE_CONF), #{ ok = emqx_common_test_helpers:load_config(emqx_modules_schema, ?BASE_CONF, #{
raw_with_default => true raw_with_default => true
}), }),

View File

@ -28,7 +28,7 @@ all() -> emqx_common_test_helpers:all(?MODULE).
init_per_suite(Config) -> init_per_suite(Config) ->
emqx_common_test_helpers:boot_modules(all), emqx_common_test_helpers:boot_modules(all),
ok = emqx_common_test_helpers:load_config(emqx_modules_schema, jsx:encode(?TOPIC), #{ ok = emqx_common_test_helpers:load_config(emqx_modules_schema, ?TOPIC, #{
raw_with_default => true raw_with_default => true
}), }),
emqx_common_test_helpers:start_apps([emqx_conf, emqx_modules]), emqx_common_test_helpers:start_apps([emqx_conf, emqx_modules]),

View File

@ -40,7 +40,7 @@ init_per_testcase(_, Config) ->
Config. Config.
init_per_suite(Config) -> init_per_suite(Config) ->
ok = emqx_common_test_helpers:load_config(emqx_modules_schema, jsx:encode(?BASE_CONF), #{ ok = emqx_common_test_helpers:load_config(emqx_modules_schema, ?BASE_CONF, #{
raw_with_default => true raw_with_default => true
}), }),

View File

@ -84,7 +84,7 @@ t_psk_lookup(_) ->
reuseaddr => true, reuseaddr => true,
user_lookup_fun => {fun emqx_tls_psk:lookup/3, undefined} user_lookup_fun => {fun emqx_tls_psk:lookup/3, undefined}
}, },
emqx_config:put([listeners, ssl, default, ssl], ServerTLSOpts), emqx_config:put([listeners, ssl, default, ssl_options], ServerTLSOpts),
emqx_listeners:restart_listener('ssl:default'), emqx_listeners:restart_listener('ssl:default'),
{ok, Socket} = ssl:connect("127.0.0.1", 8883, maps:to_list(ClientTLSOpts)), {ok, Socket} = ssl:connect("127.0.0.1", 8883, maps:to_list(ClientTLSOpts)),