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

Commit e681d3f

Browse files
committed
more tests
1 parent 66e58b0 commit e681d3f

File tree

2 files changed

+60
-17
lines changed

2 files changed

+60
-17
lines changed

contrib/mmts/Cluster.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ sub pgbench_async()
296296
-p => $self->{nodes}->[$node]->port(),
297297
'postgres',
298298
);
299-
# diag("running pgbench init");
299+
diag("running pgbench: " . join(" ", @pgbench_command));
300300
my $handle = IPC::Run::start(\@pgbench_command, $in, $out);
301301
return $handle;
302302
}

contrib/mmts/t/004_recovery.pl

Lines changed: 59 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,58 @@
22
use warnings;
33
use Cluster;
44
use TestLib;
5-
use Test::More tests => 3;
5+
use Test::More tests => 4;
66

77
my $cluster = new Cluster(3);
88
$cluster->init();
99
$cluster->configure();
1010
$cluster->start();
1111
sleep(10);
1212

13+
########################################################
14+
# Check data integrity before and after recovery
15+
########################################################
16+
17+
$cluster->pgbench(1, ('-i', -s => '10') );
18+
$cluster->pgbench(0, ('-n','-N', -T => '4') );
19+
$cluster->pgbench(1, ('-n','-N', -T => '4') );
20+
$cluster->pgbench(2, ('-n','-N', -T => '4') );
21+
22+
23+
my $hash0; my $hash1; my $hash2; my $oldhash;
24+
my $hash_query = "
25+
select
26+
md5('(' || string_agg(aid::text || ', ' || abalance::text , '),(') || ')')
27+
from
28+
(select * from pgbench_accounts order by aid) t;";
29+
30+
$cluster->{nodes}->[2]->stop('fast');
31+
sleep(3);
32+
33+
$cluster->pgbench(0, ('-n','-N', -T => '4') );
34+
$cluster->pgbench(1, ('-n','-N', -T => '4') );
35+
36+
$cluster->psql(0, 'postgres', $hash_query, stdout => \$hash0);
37+
$cluster->psql(1, 'postgres', $hash_query, stdout => \$hash1);
38+
# $cluster->psql(2, 'postgres', $hash_query, stdout => \$hash2);
39+
40+
is( ($hash0 == $hash1) , 1, "Check that hash is the same before recovery");
41+
$oldhash = $hash0;
42+
43+
$cluster->{nodes}->[2]->start;
44+
sleep(10);
45+
46+
$cluster->psql(0, 'postgres', $hash_query, stdout => \$hash0);
47+
$cluster->psql(1, 'postgres', $hash_query, stdout => \$hash1);
48+
$cluster->psql(2, 'postgres', $hash_query, stdout => \$hash2);
49+
50+
diag("$oldhash, $hash0, $hash1, $hash2");
51+
is( (($hash0 == $hash1) and ($hash1 == $hash2) and ($oldhash == $hash0)) , 1, "Check that hash is the same after recovery");
52+
53+
########################################################
54+
# Check start after all nodes were disconnected
55+
########################################################
56+
1357
$cluster->psql(0, 'postgres', "create extension multimaster;
1458
create table if not exists t(k int primary key, v int);");
1559

@@ -18,14 +62,7 @@
1862
$cluster->psql(2, 'postgres', "insert into t values(3, 30);");
1963
sleep(2);
2064

21-
22-
my $sum0;
23-
my $sum1;
24-
my $sum2;
25-
26-
########################################################
27-
# Check start after all nodes were disconnected
28-
########################################################
65+
my $sum0; my $sum1; my $sum2;
2966

3067
$cluster->{nodes}->[1]->stop('fast');
3168
$cluster->{nodes}->[2]->stop('fast');
@@ -67,13 +104,19 @@
67104
sleep(10);
68105

69106
# check data identity
70-
$cluster->psql(0, 'postgres', "select sum(abalance) from pgbench_accounts;", stdout => \$sum0);
71-
$cluster->psql(1, 'postgres', "select sum(abalance) from pgbench_accounts;", stdout => \$sum1);
72-
$cluster->psql(2, 'postgres', "select sum(abalance) from pgbench_accounts;", stdout => \$sum2);
73-
74-
diag("Sums: $sum0, $sum1, $sum2");
75-
is($sum2, $sum0, "Check that sum_2 == sum_0");
76-
is($sum2, $sum1, "Check that sum_2 == sum_1");
107+
$cluster->psql(0, 'postgres', $hash_query, stdout => \$hash0);
108+
$cluster->psql(1, 'postgres', $hash_query, stdout => \$hash1);
109+
$cluster->psql(2, 'postgres', $hash_query, stdout => \$hash2);
110+
diag("$hash0, $hash1, $hash2");
111+
is( (($hash0 == $hash1) and ($hash1 == $hash2)) , 1, "Check that hash is the same");
112+
113+
# $cluster->psql(0, 'postgres', "select sum(abalance) from pgbench_accounts;", stdout => \$sum0);
114+
# $cluster->psql(1, 'postgres', "select sum(abalance) from pgbench_accounts;", stdout => \$sum1);
115+
# $cluster->psql(2, 'postgres', "select sum(abalance) from pgbench_accounts;", stdout => \$sum2);
116+
117+
# diag("Sums: $sum0, $sum1, $sum2");
118+
# is($sum2, $sum0, "Check that sum_2 == sum_0");
119+
# is($sum2, $sum1, "Check that sum_2 == sum_1");
77120

78121
$cluster->{nodes}->[0]->stop('fast');
79122
$cluster->{nodes}->[1]->stop('fast');

0 commit comments

Comments
 (0)