fix(tests): test cases for receiving will msgs

This commit is contained in:
Shawn 2020-12-07 15:53:22 +08:00
parent 0ee489a9be
commit 28b0e874f6
1 changed files with 15 additions and 10 deletions

View File

@ -348,16 +348,19 @@ t_connect_will_delay_interval(_) ->
{will_topic, Topic},
{will_payload, Payload},
{will_props, #{'Will-Delay-Interval' => 3}},
{properties, #{'Session-Expiry-Interval' => 7200}},
{keepalive, 2}
{properties, #{'Session-Expiry-Interval' => 7200}}
]),
{ok, _} = emqtt:connect(Client2),
timer:sleep(5000),
%% terminate the client without sending the DISCONNECT
emqtt:stop(Client2),
%% should not get the will msg in 2.5s
timer:sleep(1500),
?assertEqual(0, length(receive_messages(1))),
timer:sleep(7000),
%% should get the will msg in 4.5s
timer:sleep(1000),
?assertEqual(1, length(receive_messages(1))),
%% try again, but let the session expire quickly
{ok, Client3} = emqtt:start_link([
{clientid, <<"t_connect_will_delay_interval">>},
{proto_ver, v5},
@ -367,14 +370,16 @@ t_connect_will_delay_interval(_) ->
{will_topic, Topic},
{will_payload, Payload},
{will_props, #{'Will-Delay-Interval' => 7200}},
{properties, #{'Session-Expiry-Interval' => 3}},
{keepalive, 2}
{properties, #{'Session-Expiry-Interval' => 3}}
]),
{ok, _} = emqtt:connect(Client3),
timer:sleep(5000),
%% terminate the client without sending the DISCONNECT
emqtt:stop(Client3),
%% should not get the will msg in 2.5s
timer:sleep(1500),
?assertEqual(0, length(receive_messages(1))),
timer:sleep(7000),
%% should get the will msg in 4.5s
timer:sleep(1000),
?assertEqual(1, length(receive_messages(1))),
ok = emqtt:disconnect(Client1),