Skip to content

Commit

Permalink
Change delayed_receive test
Browse files Browse the repository at this point in the history
  • Loading branch information
jacekwegr committed Feb 13, 2023
1 parent 25757b1 commit aa3f667
Showing 1 changed file with 27 additions and 18 deletions.
45 changes: 27 additions & 18 deletions big_tests/tests/pep_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ all() ->
].

groups() ->
[
G = [
{pep_tests, [parallel],
[
disco_test,
Expand All @@ -81,7 +81,8 @@ groups() ->
unsubscribe_after_presence_unsubscription
]
}
].
],
ct_helper:repeat_all_until_any_fail(G, 100).

suite() ->
require_rpc_nodes([mim]) ++ escalus:suite().
Expand All @@ -108,11 +109,8 @@ init_per_group(_GroupName, Config) ->
dynamic_modules:ensure_modules(domain(), required_modules()),
Config.

end_per_group(cache_tests, Config) ->
dynamic_modules:restore_modules(Config);

end_per_group(_GroupName, Config) ->
Config.
dynamic_modules:restore_modules(Config).

init_per_testcase(TestName, Config) ->
escalus:init_per_testcase(TestName, Config).
Expand Down Expand Up @@ -289,7 +287,7 @@ delayed_receive_with_sm_story(Config, Alice, Bob) ->
enable_sm(Alice),
enable_sm(Bob),
publish_with_sm(Alice, <<"item2">>, {pep, NodeNS}, []),
[Message] = make_friends(Bob, Alice),
[Message] = make_friends_sm(Bob, Alice),
Node = {escalus_utils:get_short_jid(Alice), NodeNS},
pubsub_tools:check_item_notification(Message, <<"item2">>, Node, []).

Expand Down Expand Up @@ -508,20 +506,31 @@ send_presence(From, Type, To) ->
escalus_client:send(From, Stanza).

make_friends(Bob, Alice) ->
% makes uni-directional presence subscriptions
% makes uni-directional presence subscriptions while SM is disabled
% returns stanzas received finally by the inviter
send_presence(Bob, <<"subscribe">>, Alice),
escalus:assert_many([is_iq], escalus_client:wait_for_stanzas(Bob, 1)),
escalus:assert_many([is_presence], escalus_client:wait_for_stanzas(Alice, 1)),
send_presence(Alice, <<"subscribed">>, Bob),
escalus:assert_many([is_iq], escalus_client:wait_for_stanzas(Alice, 1)),
escalus:assert_many([is_message, is_iq]
++ lists:duplicate(2, is_presence),
BobStanzas = escalus_client:wait_for_stanzas(Bob, 4)),
lists:filter(fun(S) -> escalus_pred:is_message(S) end, BobStanzas).

make_friends_sm(Bob, Alice) ->
% makes uni-directional presence subscriptions while SM is enabled
% returns stanzas received finally by the inviter
send_presence(Bob, <<"subscribe">>, Alice),
escalus:assert_many([is_iq, is_sm_ack_request], escalus_client:wait_for_stanzas(Bob, 2)),
escalus:assert_many([is_presence, is_sm_ack_request], escalus_client:wait_for_stanzas(Alice, 2)),
send_presence(Alice, <<"subscribed">>, Bob),
escalus:wait_for_stanzas(Alice, 10, 200),
BobStanzas = escalus:wait_for_stanzas(Bob, 10, 200),
lists:filter(fun(S) -> N = S#xmlel.name,
N =/= <<"iq">>
andalso
N =/= <<"presence">>
andalso
N =/= <<"r">>
end,
BobStanzas).
escalus:assert_many([is_iq, is_sm_ack_request], escalus_client:wait_for_stanzas(Alice, 2)),
escalus:assert_many([is_message, is_iq]
++ lists:duplicate(2, is_presence)
++ lists:duplicate(4, is_sm_ack_request),
BobStanzas = escalus_client:wait_for_stanzas(Bob, 8)),
lists:filter(fun(S) -> escalus_pred:is_message(S) end, BobStanzas).

publish_with_sm(User, ItemId, Node, Options) ->
Id = id(User, Node, <<"publish">>),
Expand Down

0 comments on commit aa3f667

Please sign in to comment.