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

Attempt to deflake uploading signed devices gets propagated over federation #1169

Merged
merged 8 commits into from
Nov 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions run-tests.pl
Original file line number Diff line number Diff line change
Expand Up @@ -454,10 +454,16 @@ (&%)
} until => sub { $iter > $max_iter || !$_[0]->failure };
}

# /!\ You probably DON'T want to use repeat_until true /!\
# It means that genuine test failures get turned into test timeouts.
# Prefer retry_until_success, which limits the number of retries.
#
# Another wrapper which repeats (with delay) until the block returns a true
# value. If the block fails entirely then it aborts, does not retry.
sub repeat_until_true(&)
{
warnings::warnif( "deprecated",
"repeat_until_true is deprecated, use retry_until_success instead" );
my ( $code ) = @_;

my $delay = 0.1;
Expand Down
27 changes: 22 additions & 5 deletions tests/41end-to-end-keys/08-cross-signing.pl
Original file line number Diff line number Diff line change
Expand Up @@ -680,13 +680,30 @@
}
} );
})->then( sub {
sync_until_user_in_device_list( $user1, $user2 );
})->then( sub {
matrix_get_e2e_keys( $user1, $user2_id );
retry_until_success {
# Wait until user1 sees signatures uploaded by user2. It's _not_ sufficient
# to just wait for user2's device to become visible to user1.
#
# On server1 hosting user 2:
#
# user2 joins a room
# user2 uploads signatures
#
# On server0, user1 syncs until they see user2's device. This is racey: the
# sync may complete before the signatures have uploaded, propagated over
# federation to server 1 and then over replication to the sync worker.
matrix_get_e2e_keys( $user1, $user2_id )->then( sub {
my ( $content ) = @_;
log_if_fail "key query content2", $content;
$content->{device_keys}{$user2_id}{$user2_device}{"signatures"}
or die "No 'signatures' key present";
Future->done( $content );
});
};
})->then( sub {
my ( $content ) = @_;

log_if_fail "key query content2", $content;
log_if_fail "key query content3", $content;

# Check that fetching the devices again returns the new signature
assert_json_keys( $content->{device_keys}->{$user2_id}->{$user2_device}, "signatures" );
Expand Down Expand Up @@ -739,7 +756,7 @@ sub matrix_upload_signatures {
do_request_json_for(
$user,
method => "POST",
uri => "/unstable/keys/signatures/upload",
uri => "/unstable/keys/signatures/upload", # available under /v3/ for matrix 1.1
content => $signatures,
);
}