|
2 | 2 | use warnings;
|
3 | 3 | use Cluster;
|
4 | 4 | use TestLib;
|
5 |
| -use Test::More tests => 2; |
| 5 | +use Test::More tests => 3; |
6 | 6 |
|
7 | 7 | my $cluster = new Cluster(3);
|
8 | 8 | $cluster->init();
|
9 | 9 | $cluster->configure();
|
10 | 10 | $cluster->start();
|
11 | 11 | sleep(10);
|
12 | 12 |
|
13 |
| -$cluster->psql(0, 'postgres', "create extension multimaster"); |
| 13 | +$cluster->psql(0, 'postgres', "create extension multimaster; |
| 14 | + create table if not exists t(k int primary key, v int);"); |
| 15 | + |
| 16 | +$cluster->psql(0, 'postgres', "insert into t values(1, 10);"); |
| 17 | +$cluster->psql(1, 'postgres', "insert into t values(2, 20);"); |
| 18 | +$cluster->psql(2, 'postgres', "insert into t values(3, 30);"); |
| 19 | +sleep(2); |
| 20 | + |
| 21 | + |
| 22 | +my $sum0; |
| 23 | +my $sum1; |
| 24 | +my $sum2; |
| 25 | + |
| 26 | +######################################################## |
| 27 | +# Check start after all nodes were disconnected |
| 28 | +######################################################## |
| 29 | + |
| 30 | +$cluster->{nodes}->[1]->stop('fast'); |
| 31 | +$cluster->{nodes}->[2]->stop('fast'); |
| 32 | + |
| 33 | +sleep(5); |
| 34 | +$cluster->{nodes}->[1]->start; |
| 35 | +# try to start node3 right here? |
| 36 | +sleep(5); |
| 37 | +$cluster->{nodes}->[2]->start; |
| 38 | +sleep(5); |
| 39 | + |
| 40 | +$cluster->psql(0, 'postgres', "select sum(v) from t;", stdout => \$sum0); |
| 41 | +$cluster->psql(1, 'postgres', "select sum(v) from t;", stdout => \$sum1); |
| 42 | +$cluster->psql(1, 'postgres', "select sum(v) from t;", stdout => \$sum2); |
| 43 | +is( (($sum0 == 60) and ($sum1 == $sum0) and ($sum2 == $sum0)) , 1, "Check that nodes are working and sync"); |
| 44 | + |
| 45 | +######################################################## |
| 46 | +# Check recovery during some load |
| 47 | +######################################################## |
| 48 | + |
14 | 49 | $cluster->pgbench(0, ('-i', -s => '10') );
|
| 50 | +$cluster->pgbench(0, ('-N', -T => '1') ); |
| 51 | +$cluster->pgbench(1, ('-N', -T => '1') ); |
| 52 | +$cluster->pgbench(2, ('-N', -T => '1') ); |
15 | 53 |
|
16 | 54 | # kill node while neighbour is under load
|
17 | 55 | my $pgb_handle = $cluster->pgbench_async(1, ('-N', -T => '10') );
|
|
29 | 67 | sleep(10);
|
30 | 68 |
|
31 | 69 | # check data identity
|
32 |
| -my $sum0; |
33 |
| -my $sum1; |
34 |
| -my $sum2; |
35 | 70 | $cluster->psql(0, 'postgres', "select sum(abalance) from pgbench_accounts;", stdout => \$sum0);
|
36 | 71 | $cluster->psql(1, 'postgres', "select sum(abalance) from pgbench_accounts;", stdout => \$sum1);
|
37 | 72 | $cluster->psql(2, 'postgres', "select sum(abalance) from pgbench_accounts;", stdout => \$sum2);
|
|
0 commit comments