Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 93e5e41

Browse files
committed
and some even less obvious races in tests
1 parent 047ef98 commit 93e5e41

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

Cluster.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ sub new
7373
my $self = {
7474
nodenum => $nodenum,
7575
nodes => $nodes,
76+
recv_timeout => 5,
7677
};
7778

7879
bless $self, $class;

t/001_basic_recovery.pl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636

3737
note("stopping node 2");
3838
$cluster->{nodes}->[2]->stop;
39+
40+
sleep($cluster->{recv_timeout});
3941
$cluster->await_nodes( (0,1) );
4042

4143
note("inserting 2 on node 0");
@@ -66,7 +68,8 @@
6668
note("starting node 2");
6769
$cluster->{nodes}->[2]->start;
6870

69-
$cluster->await_nodes( (0,1,2) );
71+
# intentionaly start from 2
72+
$cluster->await_nodes( (2,0,1) );
7073

7174
note("inserting 6 on node 0 (can fail)");
7275
$cluster->psql(0, 'postgres', "insert into t values(6, 60);");

t/004_recovery.pl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
(select * from pgbench_accounts order by aid) t;";
3030

3131
$cluster->{nodes}->[2]->stop('fast');
32+
sleep($cluster->{recv_timeout});
3233
$cluster->await_nodes( (0,1) );
3334

3435
$cluster->pgbench(0, ('-n','-N', -T => '4') );
@@ -42,7 +43,7 @@
4243
$oldhash = $hash0;
4344

4445
$cluster->{nodes}->[2]->start;
45-
$cluster->await_nodes( (0,1,2) );
46+
$cluster->await_nodes( (2,0,1) );
4647

4748
$cluster->psql(0, 'postgres', $hash_query, stdout => \$hash0);
4849
$cluster->psql(1, 'postgres', $hash_query, stdout => \$hash1);
@@ -70,7 +71,7 @@
7071
$cluster->{nodes}->[1]->start;
7172
$cluster->{nodes}->[2]->start;
7273

73-
$cluster->await_nodes( (0,1,2) );
74+
$cluster->await_nodes( (1,2,0) );
7475

7576
$cluster->psql(0, 'postgres', "select sum(v) from t;", stdout => \$sum0);
7677
$cluster->psql(1, 'postgres', "select sum(v) from t;", stdout => \$sum1);
@@ -99,7 +100,7 @@
99100
$cluster->pgbench_await($pgb_handle);
100101

101102
# await recovery
102-
$cluster->await_nodes( (0,1,2) );
103+
$cluster->await_nodes( (2,0,1) );
103104

104105
# check data identity
105106
$cluster->psql(0, 'postgres', $hash_query, stdout => \$hash0);

t/005_add_stop_node.pl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212

1313
# XXXX: delete all '-n' ?
1414

15-
# await online status
16-
$cluster->{nodes}->[0]->poll_query_until('postgres', "select 't'");
15+
$cluster->await_nodes( (0,1,2) );
1716

1817
# init
1918
$cluster->pgbench(0, ('-i', -s => '10') );
@@ -29,7 +28,8 @@
2928
$cluster->{nodes}->[2]->stop('fast');
3029
$cluster->pgbench(0, ('-N', '-n', -T => '1') );
3130
$cluster->{nodes}->[2]->start;
32-
$cluster->{nodes}->[2]->poll_query_until('postgres', "select 't'");
31+
32+
$cluster->await_nodes( (2,0,1) );
3333
is($cluster->is_data_identic( (0,1,2) ), 1, "check auto recovery");
3434

3535
# ################################################################################
@@ -51,7 +51,8 @@
5151
$cluster->psql(0, 'postgres', "SELECT mtm.add_node('$new_connstr')");
5252
# await for comletion?
5353
$cluster->{nodes}->[3]->start;
54-
$cluster->{nodes}->[3]->poll_query_until('postgres', "select 't'");
54+
55+
$cluster->await_nodes( (3,0,1,2) );
5556
$cluster->pgbench(0, ('-N', '-n', -T => '1') );
5657
$cluster->pgbench(3, ('-N', '-n', -T => '1') );
5758
is($cluster->is_data_identic( (0,1,2,3) ), 1, "basebackup and add node");
@@ -88,6 +89,8 @@
8889
note('Stopping node with slot drop');
8990
# $cluster->psql(0, 'postgres', "select mtm.stop_node(3,'t')");
9091
$cluster->{nodes}->[2]->stop('fast');
92+
93+
sleep($cluster->{recv_timeout});
9194
$cluster->await_nodes( (0,1,3) );
9295

9396
$cluster->pgbench(0, ('-N', '-n', -T => '1') );
@@ -108,7 +111,7 @@
108111
note("preparing to start $dd");
109112

110113
$cluster->{nodes}->[4]->start;
111-
$cluster->{nodes}->[4]->poll_query_until('postgres', "select 't'");
114+
$cluster->await_nodes( (4,0,1,3) );
112115
$cluster->pgbench(0, ('-N', '-n', -T => '1') );
113116
$cluster->pgbench(1, ('-N', '-n', -T => '1') );
114117
$cluster->pgbench(3, ('-N', '-n', -T => '1') );

0 commit comments

Comments
 (0)