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

Draft: Better Sytest logging/debugging for a few Archive tests #1009

Closed
wants to merge 3 commits into from
Closed
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
/var
*.db
\#*
signingkeyserver.db
.vscode
.coverage*
.idea
Expand Down
2 changes: 1 addition & 1 deletion lib/SyTest/Homeserver/Dendrite.pm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ sub _init
my ( $args ) = @_;

$self->{$_} = delete $args->{$_} for qw(
bindir pg_db pg_user pg_pass
bindir print_output pg_db pg_user pg_pass
);

defined $self->{bindir} or croak "Need a bindir";
Expand Down
13 changes: 13 additions & 0 deletions lib/SyTest/Homeserver/ProcessManager.pm
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ sub _on_output_line
push @{ $proc_info->output_lines }, $line;
shift @{ $proc_info->output_lines } while @{ $proc_info->output_lines } > 20;

#print STDERR "\e[1;35m[$name asdf]\e[m: $line\n";

if( $proc_info->print_output ) {
print STDERR "\e[1;35m[$name]\e[m: $line\n";
}
Expand Down Expand Up @@ -321,6 +323,7 @@ sub _await_ready_notification
# byte.
my $random_id = join "", map { chr 65 + rand 25 } 1 .. 20;
my $path = "\0sytest-$random_id.sock";
print STDERR "New unix socket $path\n";

# We replace null byte with '@' to allow us to pass it in via env. (This is
# as per the sd_notify spec).
Expand All @@ -332,6 +335,8 @@ sub _await_ready_notification
# notification.
my $poke_fut = Future->new;

print STDERR "feawfefe\n";

my $socket = IO::Async::Socket->new(
on_recv => sub {
my ( $self, $dgram, $addr ) = @_;
Expand All @@ -350,7 +355,15 @@ sub _await_ready_notification
die "Cannot recv - $errno\n";
},
);
print STDERR "rdtnb\n";
$loop->add( $socket );
print STDERR "kuykuyyyukyukg\n";

print STDERR "Binding unix socket $path\n";
print STDERR "jytjuytyjyjjy\n";

print STDERR "Binding unix socket $path\n";
print STDERR "jytjuytyjyjjy\n";

$socket->bind( {
family => "unix",
Expand Down
2 changes: 2 additions & 0 deletions lib/SyTest/Homeserver/Synapse.pm
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,8 @@ sub _start_synapse
my $bind_host = $self->{bind_host};
my @synapse_command = $self->_generate_base_synapse_command();

print "Starting synapse with command: @synapse_command\n";

$self->_start_process_and_await_notify(
setup => [ env => $env ],
command => \@synapse_command,
Expand Down
2 changes: 2 additions & 0 deletions lib/SyTest/HomeserverFactory/Dendrite.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ sub _init

$self->{args} = {
bindir => "../dendrite/bin",
print_output => 0,
};

$self->SUPER::_init( @_ );
Expand All @@ -42,6 +43,7 @@ sub get_options

return (
'd|dendrite-binary-directory=s' => \$self->{args}{bindir},
'S|server-log+' => \$self->{args}{print_output},
Copy link
Contributor Author

@MadLittleMods MadLittleMods May 28, 2021

Choose a reason for hiding this comment

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

Probably useful to make a separate PR for this useful change

Also include the change from lib/SyTest/Homeserver/Dendrite.pm

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created #1097

$self->SUPER::get_options(),
);
}
Expand Down
6 changes: 5 additions & 1 deletion tests/05homeserver.pl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

use Cwd qw( abs_path );

use Carp;

my $N_HOMESERVERS = 2;

my @servers;
Expand Down Expand Up @@ -123,7 +125,9 @@
return Future->done( $info );
})->on_fail( sub {
my ( $exn, @details ) = @_;
warn( "Error starting server-$idx: $exn" );
warn( "Error starting server-$idx: $exn \@details=@details" );
warn("ServerInfo: $location, $api_host, " . $server->server_name . " " . $server->federation_port);
confess "asdf";

# if we can't start the first homeserver, we really might as well go home.
if( $idx == 0 ) {
Expand Down
5 changes: 4 additions & 1 deletion tests/10apidoc/33room-members.pl
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,10 @@ sub matrix_leave_room_synced
do => sub {
matrix_leave_room( $user, $room_id, %params );
},
check => sub { exists $_[0]->{rooms}{leave}{$room_id} },
check => sub {
log_if_fail "check leave_room_sync for $room_id", $_[0]->{rooms}{leave};
exists $_[0]->{rooms}{leave}{$room_id};
},
);
}

Expand Down
21 changes: 19 additions & 2 deletions tests/31sync/09archived.pl
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@
})->then( sub {
( $room_id ) = @_;

log_if_fail "Try leave room sync";
matrix_leave_room_synced( $user, $room_id );
})->then( sub {
log_if_fail "Try sync again with filter";
matrix_sync( $user, filter => $filter_id );
})->then( sub {
my ( $body ) = @_;

my $room = $body->{rooms}{leave}{$room_id};
log_if_fail "sync result:", $room;
assert_json_keys( $room, qw( timeline state ));

Future->done(1);
Expand All @@ -48,17 +51,24 @@
})->then( sub {
( $room_id ) = @_;

log_if_fail "Try initial sync";
matrix_sync( $user, filter => $filter_id );
})->then( sub {
log_if_fail "Try leave room sync";
matrix_leave_room_synced( $user, $room_id );
})->then( sub {
log_if_fail "Try sync again with filter";
matrix_sync_again( $user, filter => $filter_id );
})->then( sub {
my ( $body ) = @_;

log_if_fail "Leave response:", $body->{rooms}{leave};
my $room = $body->{rooms}{leave}{$room_id};
log_if_fail "Room leave response:", $room;
assert_json_keys( $room, qw( timeline state ));

log_if_fail "Room state events:", $room->{state}{events};

@{ $room->{state}{events} } == 0
or die "Expected no state events";

Expand Down Expand Up @@ -304,11 +314,12 @@
});
};


use Data::Dumper;
test "Archived rooms only contain history from before the user left",
requires => [ local_user_fixtures( 2, with_events => 0 ),
qw( can_sync ) ],


check => sub {
my ( $user_a, $user_b ) = @_;

Expand Down Expand Up @@ -362,12 +373,16 @@
})->then( sub {
my ( $body ) = @_;

print STDERR "\nReturned sync body $body" . Dumper($body) . "\n";
log_if_fail "Returned sync body", $body;

# We should only expect to see events between the join and leave events
my $room = $body->{rooms}{leave}{$room_id};
assert_json_keys( $room, qw( timeline state ));
@{ $room->{state}{events} } == 0
or die "Expected no state events";
@{ $room->{timeline}{events} } == 2
or die "Expected two timeline events";
or die "Expected 2 timeline events but got " . @{ $room->{timeline}{events} };

my $timeline_event = $room->{timeline}{events}[0];
$timeline_event->{content}{body} eq "before"
Expand All @@ -377,6 +392,8 @@
})->then( sub {
my ( $body ) = @_;

log_if_fail "Returned sync body from next batch", $body;

my $room = $body->{rooms}{leave}{$room_id};
assert_json_keys( $room, qw( timeline state ));
@{ $room->{state}{events} } == 0
Expand Down