matrix-org / sytest

Black-box integration testing for Matrix homeservers
Apache License 2.0
71 stars 55 forks source link

Fix "... non-joined user can call /events on world_readable room" flakes #1346

Closed squahtx closed 1 year ago

squahtx commented 1 year ago

The test was flaking because it was sometimes waiting for events to come down /events after they had already appeared in the stream.

Fixes #1113.

Signed-off-by: Sean Quah seanq@matrix.org

squahtx commented 1 year ago

Thanks for the review!

squahtx commented 1 year ago

I forgot to mention that the flake could be reproduced reliably by inserting a delay into await_event_not_history_visibility_or_presence_for.

diff --git a/tests/30rooms/30history-visibility.pl b/tests/30rooms/30history-visibility.pl
index 24d9bea2..ed234b1f 100644
--- a/tests/30rooms/30history-visibility.pl
+++ b/tests/30rooms/30history-visibility.pl
@@ -573,6 +573,7 @@ push our @EXPORT, qw( await_event_not_history_visibility_or_presence_for );
 sub await_event_not_history_visibility_or_presence_for
 {
    my ( $user, $room_id, $allowed_users, %params ) = @_;
+   delay( 1 )->then( sub {
    await_event_for( $user,
       room_id => $room_id,
       filter  => sub {
@@ -590,5 +591,6 @@ sub await_event_not_history_visibility_or_presence_for
    )->on_done( sub {
       my ( $event ) = @_;
       log_if_fail "event", $event
-   });
+   })
+   })
 }