From 28b0e874f6a08ab1d68744d2797d18db3030fc36 Mon Sep 17 00:00:00 2001 From: Shawn <506895667@qq.com> Date: Mon, 7 Dec 2020 15:53:22 +0800 Subject: [PATCH] fix(tests): test cases for receiving will msgs --- test/mqtt_protocol_v5_SUITE.erl | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/test/mqtt_protocol_v5_SUITE.erl b/test/mqtt_protocol_v5_SUITE.erl index 50fc9c04d..33d7d923d 100644 --- a/test/mqtt_protocol_v5_SUITE.erl +++ b/test/mqtt_protocol_v5_SUITE.erl @@ -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),