Skip to content

Commit cd123da

Browse files
committed
Add failure detection and retries to the raftable test.
1 parent 4716439 commit cd123da

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

contrib/raftable/t/000_basic.pl

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,33 @@ sub start_nodes
6868
world => genstr(3000),
6969
);
7070

71+
my $retries = 100;
7172
my $timeout_ms = 1000;
7273

73-
$able->psql('postgres', "select raftable('hello', '$tests{hello}', $timeout_ms);");
74-
$baker->psql('postgres', "select raftable('and', '$tests{and}', $timeout_ms);");
75-
$charlie->psql('postgres', "select raftable('goodbye', '$tests{goodbye}', $timeout_ms);");
74+
sub trysql {
75+
my ($noderef, $sql) = @_;
76+
while ($retries > 0) {
77+
diag("try sql: ". substr($sql, 0, 60));
78+
my ($rc, $stdout, $stderr) = $noderef->psql('postgres', $sql);
79+
if (index($stderr, "after") == -1) {
80+
return;
81+
} else {
82+
$retries--;
83+
diag($stderr);
84+
diag("psql failed, $retries retries left");
85+
}
86+
}
87+
BAIL_OUT('no psql retries left');
88+
}
89+
90+
trysql($able, "select raftable('hello', '$tests{hello}', $timeout_ms);");
91+
trysql($baker, "select raftable('and', '$tests{and}', $timeout_ms);");
92+
trysql($charlie, "select raftable('goodbye', '$tests{goodbye}', $timeout_ms);");
7693
$baker->stop;
77-
$able->psql('postgres', "select raftable('world', '$tests{world}', $timeout_ms);");
94+
trysql($able, "select raftable('world', '$tests{world}', $timeout_ms);");
7895

7996
$baker->start;
80-
$baker->psql('postgres', "select raftable_sync($timeout_ms);");
97+
trysql($baker, "select raftable_sync($timeout_ms);");
8198
while (my ($key, $value) = each(%tests))
8299
{
83100
my ($rc, $stdout, $stderr) = $baker->psql('postgres', "select raftable('$key');");

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy