|
2 | 2 | use warnings;
|
3 | 3 | use Cluster;
|
4 | 4 | use TestLib;
|
5 |
| -use Test::More tests => 4; |
| 5 | +use Test::More tests => 6; |
6 | 6 |
|
7 | 7 |
|
8 | 8 | my $cluster = new Cluster(3);
|
9 | 9 | $cluster->init();
|
10 | 10 | $cluster->configure();
|
11 | 11 | $cluster->start();
|
12 |
| -sleep(10); |
| 12 | +$cluster->await_nodes( (0,1,2) ); |
13 | 13 |
|
14 | 14 | ########################################################
|
15 | 15 | # Check data integrity before and after recovery
|
|
29 | 29 | (select * from pgbench_accounts order by aid) t;";
|
30 | 30 |
|
31 | 31 | $cluster->{nodes}->[2]->stop('fast');
|
32 |
| -sleep(3); |
33 | 32 |
|
34 | 33 | $cluster->pgbench(0, ('-n','-N', -T => '4') );
|
35 | 34 | $cluster->pgbench(1, ('-n','-N', -T => '4') );
|
|
42 | 41 | $oldhash = $hash0;
|
43 | 42 |
|
44 | 43 | $cluster->{nodes}->[2]->start;
|
45 |
| -sleep(10); |
| 44 | +$cluster->await_nodes( (2) ); |
46 | 45 |
|
47 | 46 | $cluster->psql(0, 'postgres', $hash_query, stdout => \$hash0);
|
48 | 47 | $cluster->psql(1, 'postgres', $hash_query, stdout => \$hash1);
|
|
61 | 60 | $cluster->psql(0, 'postgres', "insert into t values(1, 10);");
|
62 | 61 | $cluster->psql(1, 'postgres', "insert into t values(2, 20);");
|
63 | 62 | $cluster->psql(2, 'postgres', "insert into t values(3, 30);");
|
64 |
| -sleep(2); |
65 | 63 |
|
66 | 64 | my $sum0; my $sum1; my $sum2;
|
67 | 65 |
|
68 | 66 | $cluster->{nodes}->[1]->stop('fast');
|
69 | 67 | $cluster->{nodes}->[2]->stop('fast');
|
70 | 68 |
|
71 |
| -sleep(5); |
72 | 69 | $cluster->{nodes}->[1]->start;
|
73 |
| -# try to start node3 right here? |
74 |
| -sleep(5); |
75 | 70 | $cluster->{nodes}->[2]->start;
|
76 |
| -sleep(5); |
| 71 | + |
| 72 | +$cluster->await_nodes( (0,1,2) ); |
77 | 73 |
|
78 | 74 | $cluster->psql(0, 'postgres', "select sum(v) from t;", stdout => \$sum0);
|
79 | 75 | $cluster->psql(1, 'postgres', "select sum(v) from t;", stdout => \$sum1);
|
|
90 | 86 | $cluster->pgbench(2, ('-N', -T => '1') );
|
91 | 87 |
|
92 | 88 | # kill node while neighbour is under load
|
93 |
| -my $pgb_handle = $cluster->pgbench_async(1, ('-N', -T => '10') ); |
| 89 | +my $pgb_handle = $cluster->pgbench_async(1, ('-N', -T => '20') ); |
94 | 90 | sleep(5);
|
95 | 91 | $cluster->{nodes}->[2]->stop('fast');
|
96 | 92 | $cluster->pgbench_await($pgb_handle);
|
97 | 93 |
|
98 | 94 | # start node while neighbour is under load
|
99 |
| -$pgb_handle = $cluster->pgbench_async(0, ('-N', -T => '50') ); |
100 |
| -sleep(10); |
| 95 | +$pgb_handle = $cluster->pgbench_async(0, ('-N', -T => '20') ); |
| 96 | +sleep(5); |
101 | 97 | $cluster->{nodes}->[2]->start;
|
102 | 98 | $cluster->pgbench_await($pgb_handle);
|
103 | 99 |
|
104 |
| -# give it extra 10s to recover |
105 |
| -sleep(10); |
| 100 | +# await recovery |
| 101 | +$cluster->await_nodes( (2) ); |
106 | 102 |
|
107 | 103 | # check data identity
|
108 | 104 | $cluster->psql(0, 'postgres', $hash_query, stdout => \$hash0);
|
|
111 | 107 | note("$hash0, $hash1, $hash2");
|
112 | 108 | is( (($hash0 == $hash1) and ($hash1 == $hash2)) , 1, "Check that hash is the same");
|
113 | 109 |
|
114 |
| -# $cluster->psql(0, 'postgres', "select sum(abalance) from pgbench_accounts;", stdout => \$sum0); |
115 |
| -# $cluster->psql(1, 'postgres', "select sum(abalance) from pgbench_accounts;", stdout => \$sum1); |
116 |
| -# $cluster->psql(2, 'postgres', "select sum(abalance) from pgbench_accounts;", stdout => \$sum2); |
117 |
| - |
118 |
| -# note("Sums: $sum0, $sum1, $sum2"); |
119 |
| -# is($sum2, $sum0, "Check that sum_2 == sum_0"); |
120 |
| -# is($sum2, $sum1, "Check that sum_2 == sum_1"); |
| 110 | +$cluster->psql(0, 'postgres', "select sum(abalance) from pgbench_accounts;", stdout => \$sum0); |
| 111 | +$cluster->psql(1, 'postgres', "select sum(abalance) from pgbench_accounts;", stdout => \$sum1); |
| 112 | +$cluster->psql(2, 'postgres', "select sum(abalance) from pgbench_accounts;", stdout => \$sum2); |
121 | 113 |
|
122 |
| -if ($sum2 == '') { |
123 |
| - sleep(3600); |
124 |
| -} |
| 114 | +note("Sums: $sum0, $sum1, $sum2"); |
| 115 | +is($sum2, $sum0, "Check that sum_2 == sum_0"); |
| 116 | +is($sum2, $sum1, "Check that sum_2 == sum_1"); |
125 | 117 |
|
126 | 118 | $cluster->{nodes}->[0]->stop('fast');
|
127 | 119 | $cluster->{nodes}->[1]->stop('fast');
|
|
0 commit comments