fix(test): update test cases for emqx_client_SUITE
This commit is contained in:
parent
042ff2e0d7
commit
ea68beeef6
|
@ -78,17 +78,14 @@ groups() ->
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
emqx_ct_helpers:boot_modules(all),
|
emqx_ct_helpers:boot_modules(all),
|
||||||
emqx_ct_helpers:start_apps([], fun set_special_confs/1),
|
emqx_ct_helpers:start_apps([]),
|
||||||
|
emqx_config:put_listener_conf(default, mqtt_ssl, [ssl, verify], verify_peer),
|
||||||
|
emqx_listeners:restart_listener('default:mqtt_ssl'),
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
end_per_suite(_Config) ->
|
end_per_suite(_Config) ->
|
||||||
emqx_ct_helpers:stop_apps([]).
|
emqx_ct_helpers:stop_apps([]).
|
||||||
|
|
||||||
set_special_confs(emqx) ->
|
|
||||||
emqx_ct_helpers:change_emqx_opts(ssl_twoway, [{peer_cert_as_username, cn}]);
|
|
||||||
set_special_confs(_) ->
|
|
||||||
ok.
|
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Test cases for MQTT v3
|
%% Test cases for MQTT v3
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
@ -104,8 +101,7 @@ t_basic_v4(_Config) ->
|
||||||
t_basic([{proto_ver, v4}]).
|
t_basic([{proto_ver, v4}]).
|
||||||
|
|
||||||
t_cm(_) ->
|
t_cm(_) ->
|
||||||
IdleTimeout = emqx_zone:get_env(external, idle_timeout, 30000),
|
emqx_config:put_listener_conf(default, mqtt_tcp, [mqtt, idle_timeout], 1000),
|
||||||
emqx_zone:set_env(external, idle_timeout, 1000),
|
|
||||||
ClientId = <<"myclient">>,
|
ClientId = <<"myclient">>,
|
||||||
{ok, C} = emqtt:start_link([{clientid, ClientId}]),
|
{ok, C} = emqtt:start_link([{clientid, ClientId}]),
|
||||||
{ok, _} = emqtt:connect(C),
|
{ok, _} = emqtt:connect(C),
|
||||||
|
@ -115,7 +111,7 @@ t_cm(_) ->
|
||||||
ct:sleep(1200),
|
ct:sleep(1200),
|
||||||
Stats = emqx_cm:get_chan_stats(ClientId),
|
Stats = emqx_cm:get_chan_stats(ClientId),
|
||||||
?assertEqual(1, proplists:get_value(subscriptions_cnt, Stats)),
|
?assertEqual(1, proplists:get_value(subscriptions_cnt, Stats)),
|
||||||
emqx_zone:set_env(external, idle_timeout, IdleTimeout).
|
emqx_config:put_listener_conf(default, mqtt_tcp, [mqtt, idle_timeout], 15000).
|
||||||
|
|
||||||
t_cm_registry(_) ->
|
t_cm_registry(_) ->
|
||||||
Info = supervisor:which_children(emqx_cm_sup),
|
Info = supervisor:which_children(emqx_cm_sup),
|
||||||
|
@ -273,15 +269,13 @@ t_basic(_Opts) ->
|
||||||
ok = emqtt:disconnect(C).
|
ok = emqtt:disconnect(C).
|
||||||
|
|
||||||
t_username_as_clientid(_) ->
|
t_username_as_clientid(_) ->
|
||||||
emqx_zone:set_env(external, use_username_as_clientid, true),
|
emqx_config:put_listener_conf(default, mqtt_tcp, [mqtt, use_username_as_clientid], true),
|
||||||
Username = <<"usera">>,
|
Username = <<"usera">>,
|
||||||
{ok, C} = emqtt:start_link([{username, Username}]),
|
{ok, C} = emqtt:start_link([{username, Username}]),
|
||||||
{ok, _} = emqtt:connect(C),
|
{ok, _} = emqtt:connect(C),
|
||||||
#{clientinfo := #{clientid := Username}} = emqx_cm:get_chan_info(Username),
|
#{clientinfo := #{clientid := Username}} = emqx_cm:get_chan_info(Username),
|
||||||
emqtt:disconnect(C).
|
emqtt:disconnect(C).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
t_certcn_as_clientid_default_config_tls(_) ->
|
t_certcn_as_clientid_default_config_tls(_) ->
|
||||||
tls_certcn_as_clientid(default).
|
tls_certcn_as_clientid(default).
|
||||||
|
|
||||||
|
@ -329,7 +323,7 @@ tls_certcn_as_clientid(TLSVsn) ->
|
||||||
|
|
||||||
tls_certcn_as_clientid(TLSVsn, RequiredTLSVsn) ->
|
tls_certcn_as_clientid(TLSVsn, RequiredTLSVsn) ->
|
||||||
CN = <<"Client">>,
|
CN = <<"Client">>,
|
||||||
emqx_zone:set_env(external, use_username_as_clientid, true),
|
emqx_config:put_listener_conf(default, mqtt_ssl, [mqtt, peer_cert_as_clientid], cn),
|
||||||
SslConf = emqx_ct_helpers:client_ssl_twoway(TLSVsn),
|
SslConf = emqx_ct_helpers:client_ssl_twoway(TLSVsn),
|
||||||
{ok, Client} = emqtt:start_link([{port, 8883}, {ssl, true}, {ssl_opts, SslConf}]),
|
{ok, Client} = emqtt:start_link([{port, 8883}, {ssl, true}, {ssl_opts, SslConf}]),
|
||||||
{ok, _} = emqtt:connect(Client),
|
{ok, _} = emqtt:connect(Client),
|
||||||
|
|
|
@ -89,7 +89,7 @@ t_open_session(_) ->
|
||||||
ok = meck:expect(emqx_connection, call, fun(_, _) -> ok end),
|
ok = meck:expect(emqx_connection, call, fun(_, _) -> ok end),
|
||||||
ok = meck:expect(emqx_connection, call, fun(_, _, _) -> ok end),
|
ok = meck:expect(emqx_connection, call, fun(_, _, _) -> ok end),
|
||||||
|
|
||||||
ClientInfo = #{zone => external,
|
ClientInfo = #{zone => default, listener => mqtt_tcp,
|
||||||
clientid => <<"clientid">>,
|
clientid => <<"clientid">>,
|
||||||
username => <<"username">>,
|
username => <<"username">>,
|
||||||
peerhost => {127,0,0,1}},
|
peerhost => {127,0,0,1}},
|
||||||
|
@ -114,7 +114,7 @@ rand_client_id() ->
|
||||||
|
|
||||||
t_open_session_race_condition(_) ->
|
t_open_session_race_condition(_) ->
|
||||||
ClientId = rand_client_id(),
|
ClientId = rand_client_id(),
|
||||||
ClientInfo = #{zone => external,
|
ClientInfo = #{zone => default, listener => mqtt_tcp,
|
||||||
clientid => ClientId,
|
clientid => ClientId,
|
||||||
username => <<"username">>,
|
username => <<"username">>,
|
||||||
peerhost => {127,0,0,1}},
|
peerhost => {127,0,0,1}},
|
||||||
|
|
|
@ -119,8 +119,9 @@ t_index_of(_) ->
|
||||||
?assertEqual(3, emqx_misc:index_of(a, [b, c, a, e, f])).
|
?assertEqual(3, emqx_misc:index_of(a, [b, c, a, e, f])).
|
||||||
|
|
||||||
t_check(_) ->
|
t_check(_) ->
|
||||||
Policy = #{message_queue_len => 10,
|
Policy = #{max_message_queue_len => 10,
|
||||||
max_heap_size => 1024 * 1024 * 8},
|
max_heap_size => 1024 * 1024 * 8,
|
||||||
|
enable => true},
|
||||||
[self() ! {msg, I} || I <- lists:seq(1, 5)],
|
[self() ! {msg, I} || I <- lists:seq(1, 5)],
|
||||||
?assertEqual(ok, emqx_misc:check_oom(Policy)),
|
?assertEqual(ok, emqx_misc:check_oom(Policy)),
|
||||||
[self() ! {msg, I} || I <- lists:seq(1, 6)],
|
[self() ! {msg, I} || I <- lists:seq(1, 6)],
|
||||||
|
|
Loading…
Reference in New Issue