Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbc37ba2

Browse files
committed
more tests
1 parentf484245 commitbc37ba2

File tree

2 files changed

+60
-17
lines changed

2 files changed

+60
-17
lines changed

‎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
}

‎t/004_recovery._pl

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

77

88
my $cluster = new Cluster(3);
@@ -11,6 +11,50 @@ $cluster->configure();
1111
$cluster->start();
1212
sleep(10);
1313

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

@@ -19,14 +63,7 @@ $cluster->psql(1, 'postgres', "insert into t values(2, 20);");
1963
$cluster->psql(2, 'postgres', "insert into t values(3, 30);");
2064
sleep(2);
2165

22-
23-
my $sum0;
24-
my $sum1;
25-
my $sum2;
26-
27-
########################################################
28-
# Check start after all nodes were disconnected
29-
########################################################
66+
my $sum0; my $sum1; my $sum2;
3067

3168
$cluster->{nodes}->[1]->stop('fast');
3269
$cluster->{nodes}->[2]->stop('fast');
@@ -68,13 +105,19 @@ $cluster->pgbench_await($pgb_handle);
68105
sleep(10);
69106

70107
# check data identity
71-
$cluster->psql(0, 'postgres', "select sum(abalance) from pgbench_accounts;", stdout => \$sum0);
72-
$cluster->psql(1, 'postgres', "select sum(abalance) from pgbench_accounts;", stdout => \$sum1);
73-
$cluster->psql(2, 'postgres', "select sum(abalance) from pgbench_accounts;", stdout => \$sum2);
74-
75-
diag("Sums: $sum0, $sum1, $sum2");
76-
is($sum2, $sum0, "Check that sum_2 == sum_0");
77-
is($sum2, $sum1, "Check that sum_2 == sum_1");
108+
$cluster->psql(0, 'postgres', $hash_query, stdout => \$hash0);
109+
$cluster->psql(1, 'postgres', $hash_query, stdout => \$hash1);
110+
$cluster->psql(2, 'postgres', $hash_query, stdout => \$hash2);
111+
diag("$hash0, $hash1, $hash2");
112+
is( (($hash0 == $hash1) and ($hash1 == $hash2)) , 1, "Check that hash is the same");
113+
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+
# diag("Sums: $sum0, $sum1, $sum2");
119+
# is($sum2, $sum0, "Check that sum_2 == sum_0");
120+
# is($sum2, $sum1, "Check that sum_2 == sum_1");
78121

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp