From 01b3defb8656ec783367096b4248855c1129b226 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Thu, 16 Apr 2015 08:45:17 +0200 Subject: [PATCH] CSI test: Fix race when slave becomes active again Make sure the server processed the slave's active request after the previous test stanzas were received by the slave and before the final Chat State notification is sent by the master. --- test/ejabberd_SUITE.erl | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/test/ejabberd_SUITE.erl b/test/ejabberd_SUITE.erl index 1c247694c..1577513ff 100644 --- a/test/ejabberd_SUITE.erl +++ b/test/ejabberd_SUITE.erl @@ -1575,16 +1575,17 @@ client_state_master(Config) -> Message = #message{to = Peer, thread = <<"1">>, sub_els = [#chatstate{type = active}]}, wait_for_slave(Config), - %% Should be queued (but see below): - send(Config, Presence), - %% Should be sent immediately, together with the previous presence: - send(Config, Message#message{body = [#text{data = <<"body">>}]}), %% Should be dropped: send(Config, Message), %% Should be queued (but see below): - send(Config, Presence), - %% Should replace the previous presence in the queue: send(Config, Presence#presence{type = unavailable}), + %% Should replace the previous presence in the queue: + send(Config, Presence), + %% Should be sent immediately, together with the previous presence: + send(Config, Message#message{body = [#text{data = <<"body">>}]}), + %% Should be queued: + send(Config, Presence#presence{type = unavailable}), + %% Wait for the slave to become active. wait_for_slave(Config), %% Should be sent immediately, as the client is active again. send(Config, Message), @@ -1601,11 +1602,12 @@ client_state_slave(Config) -> ?recv1(#presence{from = Peer, sub_els = [#vcard_xupdate{}|_]}), ?recv1(#message{from = Peer, thread = <<"1">>, sub_els = [#chatstate{type = active}], body = [#text{data = <<"body">>}]}), - wait_for_master(Config), send(Config, #csi{type = active}), - ?recv2(#presence{from = Peer, type = unavailable, - sub_els = [#delay{}, #legacy_delay{}]}, - #message{from = Peer, thread = <<"1">>, + %% The server now flushes the queue, so we receive the following presence. + ?recv1(#presence{from = Peer, type = unavailable, + sub_els = [#delay{}, #legacy_delay{}]}), + wait_for_master(Config), + ?recv1(#message{from = Peer, thread = <<"1">>, sub_els = [#chatstate{type = active}]}), disconnect(Config).