mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
Improve stream management tests
This commit is contained in:
parent
adbd174959
commit
e11bcf9c43
@ -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).
|
||||
|
Loading…
Reference in New Issue
Block a user