Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flakey sytest 80jira/syn606 #421

Merged
merged 4 commits into from
Nov 20, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/10apidoc/03events-initial.pl
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ sub GET_new_events_for

return $user->pending_get_events //=
matrix_get_events( $user,
%params,
from => $user->eventstream_token,
timeout => 500,
%params,
)->on_ready( sub {
undef $user->pending_get_events;
})->then( sub {
Expand Down
3 changes: 2 additions & 1 deletion tests/30rooms/30history-visibility.pl
Original file line number Diff line number Diff line change
Expand Up @@ -576,8 +576,9 @@ sub ignore_presence_for

sub await_event_not_history_visibility_or_presence_for
{
my ( $user, $room_id, $allowed_users ) = @_;
my ( $user, $room_id, $allowed_users, %params ) = @_;
await_event_for( $user,
%params,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you've moved %params from the start of the arg list to the end in GET_new_events_for: let's be consistent and put it at the end.

room_id => $room_id,
filter => sub {
my ( $event ) = @_;
Expand Down
25 changes: 16 additions & 9 deletions tests/90jira/SYN-606.pl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

test(
"$name user can call /events on another world_readable room (SYN-606)",
requires => [ $fixture->( with_events => 0 ),
local_user_fixture( with_events => 0 ) ],
requires => [ $fixture->(), local_user_fixture() ],

do => sub {
my ( $nonjoined_user, $user ) = @_;
Expand All @@ -27,20 +26,28 @@
})->then( sub {
matrix_initialsync_room( $nonjoined_user, $room_id1 )
})->then( sub {
my ( $body ) = @_;

my $from_token = $body->{messages}{end};

Future->needs_all(
matrix_send_room_text_message( $user, $room_id1, body => "moose" ),
await_event_not_history_visibility_or_presence_for( $nonjoined_user, $room_id1, [] ),
await_event_not_history_visibility_or_presence_for( $nonjoined_user, $room_id1, [],
from => $from_token,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's no explanation anywhere (PR, commit comment, a comment in code) as to what is going on here or why it is a good thing. Am I supposed to read your mind?

generally passing an explicit from token seems a bit odd here. I thought the whole point of the await_event functions was that they took this stuff away from you (and if you wanted to manage it yourself, you ought to be using lower-level methods).

If this is the right thing to e doing for some reason, please could you add a comment explaining why.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I've updated with a comment.

),
);
})->then( sub {
matrix_initialsync_room( $nonjoined_user, $room_id2 )
})->then( sub {
Future->needs_all(
delay( 0.1 )->then( sub {
matrix_send_room_text_message( $user, $room_id2, body => "mice" );
}),
my ( $body ) = @_;

my $from_token = $body->{messages}{end};

await_event_not_history_visibility_or_presence_for( $nonjoined_user, $room_id2, [] )
->then( sub {
Future->needs_all(
matrix_send_room_text_message( $user, $room_id2, body => "mice" ),
await_event_not_history_visibility_or_presence_for( $nonjoined_user, $room_id2, [],
from => $from_token,
)->then( sub {
my ( $event ) = @_;

assert_json_keys( $event, qw( content ) );
Expand Down