|
@@ -94,10 +94,10 @@ t_cm(_) ->
|
|
|
IdleTimeout = emqx_zone:get_env(external, idle_timeout, 30000),
|
|
IdleTimeout = emqx_zone:get_env(external, idle_timeout, 30000),
|
|
|
emqx_zone:set_env(external, idle_timeout, 1000),
|
|
emqx_zone:set_env(external, idle_timeout, 1000),
|
|
|
ClientId = <<"myclient">>,
|
|
ClientId = <<"myclient">>,
|
|
|
- {ok, C} = emqx_client:start_link([{client_id, ClientId}]),
|
|
|
|
|
- {ok, _} = emqx_client:connect(C),
|
|
|
|
|
|
|
+ {ok, C} = emqtt:start_link([{client_id, ClientId}]),
|
|
|
|
|
+ {ok, _} = emqtt:connect(C),
|
|
|
#{client := #{client_id := ClientId}} = emqx_cm:get_chan_attrs(ClientId),
|
|
#{client := #{client_id := ClientId}} = emqx_cm:get_chan_attrs(ClientId),
|
|
|
- emqx_client:subscribe(C, <<"mytopic">>, 0),
|
|
|
|
|
|
|
+ emqtt:subscribe(C, <<"mytopic">>, 0),
|
|
|
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, Stats)),
|
|
?assertEqual(1, proplists:get_value(subscriptions, Stats)),
|
|
@@ -114,55 +114,55 @@ t_cm_registry(_) ->
|
|
|
emqx_ct_helpers:start_apps([]).
|
|
emqx_ct_helpers:start_apps([]).
|
|
|
|
|
|
|
|
t_will_message(_Config) ->
|
|
t_will_message(_Config) ->
|
|
|
- {ok, C1} = emqx_client:start_link([{clean_start, true},
|
|
|
|
|
|
|
+ {ok, C1} = emqtt:start_link([{clean_start, true},
|
|
|
{will_topic, nth(3, ?TOPICS)},
|
|
{will_topic, nth(3, ?TOPICS)},
|
|
|
{will_payload, <<"client disconnected">>},
|
|
{will_payload, <<"client disconnected">>},
|
|
|
{keepalive, 1}]),
|
|
{keepalive, 1}]),
|
|
|
- {ok, _} = emqx_client:connect(C1),
|
|
|
|
|
|
|
+ {ok, _} = emqtt:connect(C1),
|
|
|
|
|
|
|
|
- {ok, C2} = emqx_client:start_link(),
|
|
|
|
|
- {ok, _} = emqx_client:connect(C2),
|
|
|
|
|
|
|
+ {ok, C2} = emqtt:start_link(),
|
|
|
|
|
+ {ok, _} = emqtt:connect(C2),
|
|
|
|
|
|
|
|
- {ok, _, [2]} = emqx_client:subscribe(C2, nth(3, ?TOPICS), 2),
|
|
|
|
|
|
|
+ {ok, _, [2]} = emqtt:subscribe(C2, nth(3, ?TOPICS), 2),
|
|
|
timer:sleep(5),
|
|
timer:sleep(5),
|
|
|
- ok = emqx_client:stop(C1),
|
|
|
|
|
|
|
+ ok = emqtt:stop(C1),
|
|
|
timer:sleep(5),
|
|
timer:sleep(5),
|
|
|
?assertEqual(1, length(recv_msgs(1))),
|
|
?assertEqual(1, length(recv_msgs(1))),
|
|
|
- ok = emqx_client:disconnect(C2),
|
|
|
|
|
|
|
+ ok = emqtt:disconnect(C2),
|
|
|
ct:pal("Will message test succeeded").
|
|
ct:pal("Will message test succeeded").
|
|
|
|
|
|
|
|
t_offline_message_queueing(_) ->
|
|
t_offline_message_queueing(_) ->
|
|
|
- {ok, C1} = emqx_client:start_link([{clean_start, false},
|
|
|
|
|
|
|
+ {ok, C1} = emqtt:start_link([{clean_start, false},
|
|
|
{client_id, <<"c1">>}]),
|
|
{client_id, <<"c1">>}]),
|
|
|
- {ok, _} = emqx_client:connect(C1),
|
|
|
|
|
|
|
+ {ok, _} = emqtt:connect(C1),
|
|
|
|
|
|
|
|
- {ok, _, [2]} = emqx_client:subscribe(C1, nth(6, ?WILD_TOPICS), 2),
|
|
|
|
|
- ok = emqx_client:disconnect(C1),
|
|
|
|
|
- {ok, C2} = emqx_client:start_link([{clean_start, true},
|
|
|
|
|
|
|
+ {ok, _, [2]} = emqtt:subscribe(C1, nth(6, ?WILD_TOPICS), 2),
|
|
|
|
|
+ ok = emqtt:disconnect(C1),
|
|
|
|
|
+ {ok, C2} = emqtt:start_link([{clean_start, true},
|
|
|
{client_id, <<"c2">>}]),
|
|
{client_id, <<"c2">>}]),
|
|
|
- {ok, _} = emqx_client:connect(C2),
|
|
|
|
|
|
|
+ {ok, _} = emqtt:connect(C2),
|
|
|
|
|
|
|
|
- ok = emqx_client:publish(C2, nth(2, ?TOPICS), <<"qos 0">>, 0),
|
|
|
|
|
- {ok, _} = emqx_client:publish(C2, nth(3, ?TOPICS), <<"qos 1">>, 1),
|
|
|
|
|
- {ok, _} = emqx_client:publish(C2, nth(4, ?TOPICS), <<"qos 2">>, 2),
|
|
|
|
|
|
|
+ ok = emqtt:publish(C2, nth(2, ?TOPICS), <<"qos 0">>, 0),
|
|
|
|
|
+ {ok, _} = emqtt:publish(C2, nth(3, ?TOPICS), <<"qos 1">>, 1),
|
|
|
|
|
+ {ok, _} = emqtt:publish(C2, nth(4, ?TOPICS), <<"qos 2">>, 2),
|
|
|
timer:sleep(10),
|
|
timer:sleep(10),
|
|
|
- emqx_client:disconnect(C2),
|
|
|
|
|
- {ok, C3} = emqx_client:start_link([{clean_start, false},
|
|
|
|
|
|
|
+ emqtt:disconnect(C2),
|
|
|
|
|
+ {ok, C3} = emqtt:start_link([{clean_start, false},
|
|
|
{client_id, <<"c1">>}]),
|
|
{client_id, <<"c1">>}]),
|
|
|
- {ok, _} = emqx_client:connect(C3),
|
|
|
|
|
|
|
+ {ok, _} = emqtt:connect(C3),
|
|
|
|
|
|
|
|
timer:sleep(10),
|
|
timer:sleep(10),
|
|
|
- emqx_client:disconnect(C3),
|
|
|
|
|
|
|
+ emqtt:disconnect(C3),
|
|
|
?assertEqual(3, length(recv_msgs(3))).
|
|
?assertEqual(3, length(recv_msgs(3))).
|
|
|
|
|
|
|
|
t_overlapping_subscriptions(_) ->
|
|
t_overlapping_subscriptions(_) ->
|
|
|
- {ok, C} = emqx_client:start_link([]),
|
|
|
|
|
- {ok, _} = emqx_client:connect(C),
|
|
|
|
|
|
|
+ {ok, C} = emqtt:start_link([]),
|
|
|
|
|
+ {ok, _} = emqtt:connect(C),
|
|
|
|
|
|
|
|
- {ok, _, [2, 1]} = emqx_client:subscribe(C, [{nth(7, ?WILD_TOPICS), 2},
|
|
|
|
|
|
|
+ {ok, _, [2, 1]} = emqtt:subscribe(C, [{nth(7, ?WILD_TOPICS), 2},
|
|
|
{nth(1, ?WILD_TOPICS), 1}]),
|
|
{nth(1, ?WILD_TOPICS), 1}]),
|
|
|
timer:sleep(10),
|
|
timer:sleep(10),
|
|
|
- {ok, _} = emqx_client:publish(C, nth(4, ?TOPICS), <<"overlapping topic filters">>, 2),
|
|
|
|
|
|
|
+ {ok, _} = emqtt:publish(C, nth(4, ?TOPICS), <<"overlapping topic filters">>, 2),
|
|
|
timer:sleep(10),
|
|
timer:sleep(10),
|
|
|
|
|
|
|
|
Num = length(recv_msgs(2)),
|
|
Num = length(recv_msgs(2)),
|
|
@@ -176,67 +176,67 @@ t_overlapping_subscriptions(_) ->
|
|
|
matching overlapping subscription.");
|
|
matching overlapping subscription.");
|
|
|
true -> ok
|
|
true -> ok
|
|
|
end,
|
|
end,
|
|
|
- emqx_client:disconnect(C).
|
|
|
|
|
|
|
+ emqtt:disconnect(C).
|
|
|
|
|
|
|
|
%% t_keepalive_test(_) ->
|
|
%% t_keepalive_test(_) ->
|
|
|
%% ct:print("Keepalive test starting"),
|
|
%% ct:print("Keepalive test starting"),
|
|
|
-%% {ok, C1, _} = emqx_client:start_link([{clean_start, true},
|
|
|
|
|
|
|
+%% {ok, C1, _} = emqtt:start_link([{clean_start, true},
|
|
|
%% {keepalive, 5},
|
|
%% {keepalive, 5},
|
|
|
%% {will_flag, true},
|
|
%% {will_flag, true},
|
|
|
%% {will_topic, nth(5, ?TOPICS)},
|
|
%% {will_topic, nth(5, ?TOPICS)},
|
|
|
%% %% {will_qos, 2},
|
|
%% %% {will_qos, 2},
|
|
|
%% {will_payload, <<"keepalive expiry">>}]),
|
|
%% {will_payload, <<"keepalive expiry">>}]),
|
|
|
-%% ok = emqx_client:pause(C1),
|
|
|
|
|
-%% {ok, C2, _} = emqx_client:start_link([{clean_start, true},
|
|
|
|
|
|
|
+%% ok = emqtt:pause(C1),
|
|
|
|
|
+%% {ok, C2, _} = emqtt:start_link([{clean_start, true},
|
|
|
%% {keepalive, 0}]),
|
|
%% {keepalive, 0}]),
|
|
|
-%% {ok, _, [2]} = emqx_client:subscribe(C2, nth(5, ?TOPICS), 2),
|
|
|
|
|
-%% ok = emqx_client:disconnect(C2),
|
|
|
|
|
|
|
+%% {ok, _, [2]} = emqtt:subscribe(C2, nth(5, ?TOPICS), 2),
|
|
|
|
|
+%% ok = emqtt:disconnect(C2),
|
|
|
%% ?assertEqual(1, length(recv_msgs(1))),
|
|
%% ?assertEqual(1, length(recv_msgs(1))),
|
|
|
%% ct:print("Keepalive test succeeded").
|
|
%% ct:print("Keepalive test succeeded").
|
|
|
|
|
|
|
|
t_redelivery_on_reconnect(_) ->
|
|
t_redelivery_on_reconnect(_) ->
|
|
|
ct:pal("Redelivery on reconnect test starting"),
|
|
ct:pal("Redelivery on reconnect test starting"),
|
|
|
- {ok, C1} = emqx_client:start_link([{clean_start, false},
|
|
|
|
|
|
|
+ {ok, C1} = emqtt:start_link([{clean_start, false},
|
|
|
{client_id, <<"c">>}]),
|
|
{client_id, <<"c">>}]),
|
|
|
- {ok, _} = emqx_client:connect(C1),
|
|
|
|
|
|
|
+ {ok, _} = emqtt:connect(C1),
|
|
|
|
|
|
|
|
- {ok, _, [2]} = emqx_client:subscribe(C1, nth(7, ?WILD_TOPICS), 2),
|
|
|
|
|
|
|
+ {ok, _, [2]} = emqtt:subscribe(C1, nth(7, ?WILD_TOPICS), 2),
|
|
|
timer:sleep(10),
|
|
timer:sleep(10),
|
|
|
- ok = emqx_client:pause(C1),
|
|
|
|
|
- {ok, _} = emqx_client:publish(C1, nth(2, ?TOPICS), <<>>,
|
|
|
|
|
|
|
+ ok = emqtt:pause(C1),
|
|
|
|
|
+ {ok, _} = emqtt:publish(C1, nth(2, ?TOPICS), <<>>,
|
|
|
[{qos, 1}, {retain, false}]),
|
|
[{qos, 1}, {retain, false}]),
|
|
|
- {ok, _} = emqx_client:publish(C1, nth(4, ?TOPICS), <<>>,
|
|
|
|
|
|
|
+ {ok, _} = emqtt:publish(C1, nth(4, ?TOPICS), <<>>,
|
|
|
[{qos, 2}, {retain, false}]),
|
|
[{qos, 2}, {retain, false}]),
|
|
|
timer:sleep(10),
|
|
timer:sleep(10),
|
|
|
- ok = emqx_client:disconnect(C1),
|
|
|
|
|
|
|
+ ok = emqtt:disconnect(C1),
|
|
|
?assertEqual(0, length(recv_msgs(2))),
|
|
?assertEqual(0, length(recv_msgs(2))),
|
|
|
- {ok, C2} = emqx_client:start_link([{clean_start, false},
|
|
|
|
|
|
|
+ {ok, C2} = emqtt:start_link([{clean_start, false},
|
|
|
{client_id, <<"c">>}]),
|
|
{client_id, <<"c">>}]),
|
|
|
- {ok, _} = emqx_client:connect(C2),
|
|
|
|
|
|
|
+ {ok, _} = emqtt:connect(C2),
|
|
|
|
|
|
|
|
timer:sleep(10),
|
|
timer:sleep(10),
|
|
|
- ok = emqx_client:disconnect(C2),
|
|
|
|
|
|
|
+ ok = emqtt:disconnect(C2),
|
|
|
?assertEqual(2, length(recv_msgs(2))).
|
|
?assertEqual(2, length(recv_msgs(2))).
|
|
|
|
|
|
|
|
%% t_subscribe_sys_topics(_) ->
|
|
%% t_subscribe_sys_topics(_) ->
|
|
|
%% ct:print("Subscribe failure test starting"),
|
|
%% ct:print("Subscribe failure test starting"),
|
|
|
-%% {ok, C, _} = emqx_client:start_link([]),
|
|
|
|
|
-%% {ok, _, [2]} = emqx_client:subscribe(C, <<"$SYS/#">>, 2),
|
|
|
|
|
|
|
+%% {ok, C, _} = emqtt:start_link([]),
|
|
|
|
|
+%% {ok, _, [2]} = emqtt:subscribe(C, <<"$SYS/#">>, 2),
|
|
|
%% timer:sleep(10),
|
|
%% timer:sleep(10),
|
|
|
%% ct:print("Subscribe failure test succeeded").
|
|
%% ct:print("Subscribe failure test succeeded").
|
|
|
|
|
|
|
|
t_dollar_topics(_) ->
|
|
t_dollar_topics(_) ->
|
|
|
ct:pal("$ topics test starting"),
|
|
ct:pal("$ topics test starting"),
|
|
|
- {ok, C} = emqx_client:start_link([{clean_start, true},
|
|
|
|
|
|
|
+ {ok, C} = emqtt:start_link([{clean_start, true},
|
|
|
{keepalive, 0}]),
|
|
{keepalive, 0}]),
|
|
|
- {ok, _} = emqx_client:connect(C),
|
|
|
|
|
|
|
+ {ok, _} = emqtt:connect(C),
|
|
|
|
|
|
|
|
- {ok, _, [1]} = emqx_client:subscribe(C, nth(6, ?WILD_TOPICS), 1),
|
|
|
|
|
- {ok, _} = emqx_client:publish(C, << <<"$">>/binary, (nth(2, ?TOPICS))/binary>>,
|
|
|
|
|
|
|
+ {ok, _, [1]} = emqtt:subscribe(C, nth(6, ?WILD_TOPICS), 1),
|
|
|
|
|
+ {ok, _} = emqtt:publish(C, << <<"$">>/binary, (nth(2, ?TOPICS))/binary>>,
|
|
|
<<"test">>, [{qos, 1}, {retain, false}]),
|
|
<<"test">>, [{qos, 1}, {retain, false}]),
|
|
|
timer:sleep(10),
|
|
timer:sleep(10),
|
|
|
?assertEqual(0, length(recv_msgs(1))),
|
|
?assertEqual(0, length(recv_msgs(1))),
|
|
|
- ok = emqx_client:disconnect(C),
|
|
|
|
|
|
|
+ ok = emqtt:disconnect(C),
|
|
|
ct:pal("$ topics test succeeded").
|
|
ct:pal("$ topics test succeeded").
|
|
|
|
|
|
|
|
%%--------------------------------------------------------------------
|
|
%%--------------------------------------------------------------------
|
|
@@ -254,15 +254,15 @@ t_basic_with_props_v5(_) ->
|
|
|
|
|
|
|
|
t_basic(Opts) ->
|
|
t_basic(Opts) ->
|
|
|
Topic = nth(1, ?TOPICS),
|
|
Topic = nth(1, ?TOPICS),
|
|
|
- {ok, C} = emqx_client:start_link([{proto_ver, v4}]),
|
|
|
|
|
- {ok, _} = emqx_client:connect(C),
|
|
|
|
|
- {ok, _, [1]} = emqx_client:subscribe(C, Topic, qos1),
|
|
|
|
|
- {ok, _, [2]} = emqx_client:subscribe(C, Topic, qos2),
|
|
|
|
|
- {ok, _} = emqx_client:publish(C, Topic, <<"qos 2">>, 2),
|
|
|
|
|
- {ok, _} = emqx_client:publish(C, Topic, <<"qos 2">>, 2),
|
|
|
|
|
- {ok, _} = emqx_client:publish(C, Topic, <<"qos 2">>, 2),
|
|
|
|
|
|
|
+ {ok, C} = emqtt:start_link([{proto_ver, v4}]),
|
|
|
|
|
+ {ok, _} = emqtt:connect(C),
|
|
|
|
|
+ {ok, _, [1]} = emqtt:subscribe(C, Topic, qos1),
|
|
|
|
|
+ {ok, _, [2]} = emqtt:subscribe(C, Topic, qos2),
|
|
|
|
|
+ {ok, _} = emqtt:publish(C, Topic, <<"qos 2">>, 2),
|
|
|
|
|
+ {ok, _} = emqtt:publish(C, Topic, <<"qos 2">>, 2),
|
|
|
|
|
+ {ok, _} = emqtt:publish(C, Topic, <<"qos 2">>, 2),
|
|
|
?assertEqual(3, length(recv_msgs(3))),
|
|
?assertEqual(3, length(recv_msgs(3))),
|
|
|
- ok = emqx_client:disconnect(C).
|
|
|
|
|
|
|
+ ok = emqtt:disconnect(C).
|
|
|
|
|
|
|
|
%%--------------------------------------------------------------------
|
|
%%--------------------------------------------------------------------
|
|
|
%% Helper functions
|
|
%% Helper functions
|