Skip to content

Commit

Permalink
Make SM reconnect test more robust
Browse files Browse the repository at this point in the history
The initial presence response and delayed message/presence can come in any
order.
  • Loading branch information
gustawlippa committed Dec 6, 2024
1 parent 3072292 commit 16f4aa3
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions big_tests/tests/sm_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -684,15 +684,18 @@ resend_unacked_to_different_res_after_resume_timeout(Config) ->
sm_helper:wait_until_resume_session(C2SPid),

%% user comes back with different resource
NewUser = connect_spec([{resource, <<"2nd_resource">>} | UserSpec], sr_presence),
NewUser = connect_spec([{resource, <<"2nd_resource">>} | UserSpec], session),
send_initial_presence(NewUser),

%% resume timeout passes
timer:sleep(timer:seconds(?SHORT_TIMEOUT + 1)),

%% user receives unacked message and presence
UnackedStanzas = escalus:wait_for_stanzas(NewUser, 2),
escalus_new_assert:mix_match([is_presence, is_chat(<<"msg-1">>)], UnackedStanzas),
[sm_helper:assert_delayed(S) || S <- UnackedStanzas],
%% user receives unacked message and presence, as well as initial presence response
%% the order of the messages may change, especially on CI, so we test all of them
UnackedStanzas = escalus:wait_for_stanzas(NewUser, 3),
escalus_new_assert:mix_match([is_presence, is_chat(<<"msg-1">>), is_presence], UnackedStanzas),
[UnackedMsg] = lists:filter(fun escalus_pred:is_message/1, UnackedStanzas),
sm_helper:assert_delayed(UnackedMsg),

escalus_assert:has_no_stanzas(NewUser),

Expand Down

0 comments on commit 16f4aa3

Please sign in to comment.