Skip to content

Commit c175963

Browse files
committed
Fix flaky bosh_SUITE
The instrumentation event 'xmpp_element_in' checked in 'create_and_terminate_session' was actually NOT emitted in this test, but in another ones. This is why the test was flaky. Solution: - Simplify event assertions - check them once in 'interleave_requests'. - Make sure the events are emitted in the same test by using timestamps.
1 parent 13c50ae commit c175963

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

big_tests/tests/bosh_SUITE.erl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,6 @@ create_and_terminate_session(Config) ->
191191
Terminate = escalus_bosh:session_termination_body(get_bosh_rid(Conn), Sid),
192192
ok = bosh_send_raw(Conn, Terminate),
193193

194-
% Assert that correct events have been executed
195-
[instrument_helper:assert(Event, Label, fun(#{byte_size := BS}) -> BS > 0 end)
196-
|| {Event, Label} <- instrumentation_events(), Event =/= c2s_message_processed],
197-
198194
%% Assert the session was terminated.
199195
wait_for_zero_bosh_sessions().
200196

@@ -353,6 +349,8 @@ interleave_requests(Config) ->
353349
Msg3 = <<"3rd!">>,
354350
Msg4 = <<"4th!">>,
355351

352+
TS = instrument_helper:timestamp(),
353+
356354
send_message_with_rid(Carol, Geralt, Rid + 1, Sid, Msg2),
357355
send_message_with_rid(Carol, Geralt, Rid, Sid, Msg1),
358356

@@ -368,8 +366,10 @@ interleave_requests(Config) ->
368366
escalus:assert(is_chat_message, [Msg4],
369367
escalus_client:wait_for_stanza(Geralt)),
370368

371-
[instrument_helper:assert(Event, Label, fun(#{byte_size := BS}) -> BS > 0;
372-
(#{time := Time}) -> Time > 0 end)
369+
Pred = fun(#{byte_size := BS}) -> BS > 0;
370+
(#{time := Time}) -> Time > 0
371+
end,
372+
[instrument_helper:assert(Event, Label, Pred, #{min_timestamp => TS})
373373
|| {Event, Label} <- instrumentation_events()],
374374

375375
true = is_bosh_connected(Carol)

0 commit comments

Comments
 (0)