Skip to content

Commit

Permalink
Fix a race condition tr_util tests
Browse files Browse the repository at this point in the history
The expected traces are from 2 different processes, so sometimes the
hook events become interleaved, and they are not aggregated.
This is expected, and the tests are now less strict, allowing such
condition to occur.
  • Loading branch information
chrzaszcz committed Jun 19, 2024
1 parent ab579c3 commit 250260e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions big_tests/tests/tr_util_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,17 @@ c2s_elements_story(Alice, Bob) ->
BobJid = escalus_utils:get_jid(Bob),

%% Get elements exchanged between bare JIDs
[Sent, Recv] = rpc(mim(), tr_util, c2s_elements_between_jids, [[AliceBareJid, BobBareJid]]),
%% There can be more than 2 elements if the hook traces are interleaved
%% between the sender and the receiver
[Sent, Recv | _] = Events =
rpc(mim(), tr_util, c2s_elements_between_jids, [[AliceBareJid, BobBareJid]]),
?assertMatch(#{name := <<"message">>, type := <<"chat">>,
jid := AliceJid, from_jid := AliceJid, to_jid := BobJid}, Sent),
?assertMatch(#{name := <<"message">>, type := <<"chat">>,
jid := BobJid, from_jid := AliceJid, to_jid := BobJid}, Recv),

%% Get elements exchanged between full JIDs
?assertEqual([Sent, Recv],
rpc(mim(), tr_util, c2s_elements_between_jids, [[AliceJid, BobJid]])),
?assertEqual(Events, rpc(mim(), tr_util, c2s_elements_between_jids, [[AliceJid, BobJid]])),

%% Get all elements
AllElements = rpc(mim(), tr_util, c2s_elements, []),
Expand Down

0 comments on commit 250260e

Please sign in to comment.