From e11bcf9c4341067343a77843d878a4538e45b4cd Mon Sep 17 00:00:00 2001 From: Evgeniy Khramtsov Date: Tue, 21 Feb 2017 09:19:51 +0300 Subject: [PATCH] Improve stream management tests --- test/sm_tests.erl | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/test/sm_tests.erl b/test/sm_tests.erl index fac22ca2f..37cecf5b7 100644 --- a/test/sm_tests.erl +++ b/test/sm_tests.erl @@ -50,21 +50,22 @@ feature_enabled(Config) -> enable(Config) -> Server = ?config(server, Config), ServerJID = jid:make(<<"">>, Server, <<"">>), - %% Send messages of type 'headline' so the server discards them silently + ct:comment("Send messages of type 'headline' so the server discards them silently"), Msg = #message{to = ServerJID, type = headline, body = [#text{data = <<"body">>}]}, - %% Enable the session management with resumption enabled + ct:comment("Enable the session management with resumption enabled"), send(Config, #sm_enable{resume = true, xmlns = ?NS_STREAM_MGMT_3}), #sm_enabled{id = ID, resume = true} = recv(Config), - %% Initial request; 'h' should be 0. + ct:comment("Initial request; 'h' should be 0"), send(Config, #sm_r{xmlns = ?NS_STREAM_MGMT_3}), #sm_a{h = 0} = recv(Config), - %% sending two messages and requesting again; 'h' should be 3. + ct:comment("Sending two messages and requesting again; 'h' should be 3"), send(Config, Msg), send(Config, Msg), send(Config, Msg), send(Config, #sm_r{xmlns = ?NS_STREAM_MGMT_3}), #sm_a{h = 3} = recv(Config), + ct:comment("Closing socket"), close_socket(Config), {save_config, set_opt(sm_previd, ID, Config)}. @@ -76,22 +77,30 @@ resume(Config) -> MyJID = my_jid(Config), Txt = #text{data = <<"body">>}, Msg = #message{from = ServerJID, to = MyJID, body = [Txt]}, - %% Route message. The message should be queued by the C2S process. + ct:comment("Route message. The message should be queued by the C2S process"), ejabberd_router:route(Msg), + ct:comment("Resuming the session"), send(Config, #sm_resume{previd = ID, h = 0, xmlns = ?NS_STREAM_MGMT_3}), #sm_resumed{previd = ID, h = 3} = recv(Config), + ct:comment("Receiving unacknowledged stanza"), #message{from = ServerJID, to = MyJID, body = [Txt]} = recv_message(Config), #sm_r{} = recv(Config), send(Config, #sm_a{h = 1, xmlns = ?NS_STREAM_MGMT_3}), - %% Send another stanza to increment the server's 'h' for sm_resume_failed. + ct:comment("Checking if the server counts stanzas correctly"), + send(Config, #sm_r{xmlns = ?NS_STREAM_MGMT_3}), + #sm_a{h = 3} = recv(Config), + ct:comment("Send another stanza to increment the server's 'h' for sm_resume_failed"), send(Config, #presence{to = ServerJID}), + ct:comment("Closing socket"), close_socket(Config), {save_config, set_opt(sm_previd, ID, Config)}. resume_failed(Config) -> {_, SMConfig} = ?config(saved_config, Config), ID = ?config(sm_previd, SMConfig), - ct:sleep(5000), % Wait for session to time out. + ct:comment("Waiting for the session to time out"), + ct:sleep(5000), + ct:comment("Trying to resume timed out session"), send(Config, #sm_resume{previd = ID, h = 1, xmlns = ?NS_STREAM_MGMT_3}), #sm_failed{reason = 'item-not-found', h = 4} = recv(Config), disconnect(Config).