From 250260e3b038f8183d56f35915b6784fa7969dbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chrz=C4=85szcz?= Date: Wed, 19 Jun 2024 16:14:29 +0200 Subject: [PATCH] Fix a race condition tr_util tests 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. --- big_tests/tests/tr_util_SUITE.erl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/big_tests/tests/tr_util_SUITE.erl b/big_tests/tests/tr_util_SUITE.erl index 6d71878f1c..516f2ccd2d 100644 --- a/big_tests/tests/tr_util_SUITE.erl +++ b/big_tests/tests/tr_util_SUITE.erl @@ -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, []),