postgres.git / summary / log / commit / refs

commit    36c1c91604cee164c6487afb99508f7ff8737b96
Author:   Fujii Masao <fujii@postgresql.org>
Date:     Fri Apr 15 04:58:14 2016 +0000
First released in: 9.6.0

    Make regression test for multiple synchronous standbys more stable.
    
    The regression test checks whether the output of pg_stat_replication is
    expected or not after changing synchronous_standby_names and reloading
    the configuration file. Regarding this test logic, previously there was
    a timing issue which made the test result unstable. That is,
    pg_stat_replication could return unexpected result during small window
    after the configuration file was reloaded before new setting value
    took effect, and which made the test fail.
    
    This commit changes the test logic so that it uses a loop with a timeout
    to give some room for the test to pass. Now the test fails only when
    pg_stat_replication keeps returning unexpected result for 30 seconds.
    
    Michael Paquier


src/test/recovery/t/007_sync_rep.pl | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/test/recovery/t/007_sync_rep.pl b/src/test/recovery/t/007_sync_rep.pl index c257b6ea166..d551954bcbb 100644 --- a/src/test/recovery/t/007_sync_rep.pl +++ b/src/test/recovery/t/007_sync_rep.pl @@ -22,7 +22,23 @@ sub test_sync_state $self->reload; } - my $result = $self->safe_psql('postgres', $check_sql); + my $timeout_max = 30; + my $timeout = 0; + my $result; + + # A reload may take some time to take effect on busy machines, + # hence use a loop with a timeout to give some room for the test + # to pass. + while ($timeout < $timeout_max) + { + $result = $self->safe_psql('postgres', $check_sql); + + last if ($result eq $expected); + + $timeout++; + sleep 1; + } + is($result, $expected, $msg); } [parent: f0e766bd7f77]