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

Commitd0cbe22

Browse files
kvapkelvich
authored andcommitted
Add a tap test with dtmbench.
1 parent33162a6 commitd0cbe22

File tree

3 files changed

+127
-3
lines changed

3 files changed

+127
-3
lines changed

‎Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@ OBJS = multimaster.o raftable.o arbiter.o bytebuf.o bgwpool.o pglogical_output.o
33

44
overrideCPPFLAGS += -I../raftable
55

6+
SCRIPTS_built = tests/dtmbench
67
EXTRA_INSTALL = contrib/raftable contrib/mmts
78

89
EXTENSION = multimaster
910
DATA = multimaster--1.0.sql
1011

1112
.PHONY: all
1213

13-
all: multimaster.so
14+
all: multimaster.so tests/dtmbench
15+
16+
tests/dtmbench:
17+
make -C tests
1418

1519
PG_CPPFLAGS = -I$(libpq_srcdir) -DUSE_PGLOGICAL_OUTPUT
1620
SHLIB_LINK =$(libpq)

‎t/001_basic_recovery.pl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,10 @@ sub PostgresNode::inet_connstr {
9494
# Work after node stop
9595
###############################################################################
9696

97+
diag("stopping node 2");
9798
$nodes[2]->teardown_node;
9899

99-
diag("sleeping");
100+
diag("sleeping 15");
100101
sleep(15);
101102

102103
diag("inserting 2");
@@ -110,8 +111,10 @@ sub PostgresNode::inet_connstr {
110111
# Work after node start
111112
###############################################################################
112113

114+
diag("starting node 2");
113115
$nodes[2]->start;
114-
sleep(15);# XXX: here we can poll
116+
diag("sleeping 30");
117+
sleep(30);# XXX: here we can poll
115118
diag("inserting 3");
116119
$nodes[0]->psql('postgres',"insert into t values(3, 30);");
117120
diag("selecting");

‎t/002_dtmbench.pl

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
use strict;
2+
use warnings;
3+
4+
use PostgresNode;
5+
use TestLib;
6+
use Test::Moretests=> 1;
7+
8+
my%allocated_ports = ();
9+
suballocate_ports
10+
{
11+
my@allocated_now = ();
12+
my ($host,$ports_to_alloc) =@_;
13+
14+
while ($ports_to_alloc > 0)
15+
{
16+
my$port =int(rand() * 16384) + 49152;
17+
nextif$allocated_ports{$port};
18+
diag("checking for port$port\n");
19+
if (!TestLib::run_log(['pg_isready','-h',$host,'-p',$port]))
20+
{
21+
$allocated_ports{$port} = 1;
22+
push(@allocated_now,$port);
23+
$ports_to_alloc--;
24+
}
25+
}
26+
27+
return@allocated_now;
28+
}
29+
30+
my$nnodes = 2;
31+
my@nodes = ();
32+
33+
diag("creating nodes");
34+
foreachmy$i (1..$nnodes)
35+
{
36+
my$host ="127.0.0.1";
37+
my ($pgport,$raftport) = allocate_ports($host, 2);
38+
my$node = new PostgresNode("node$i",$host,$pgport);
39+
$node->{id} =$i;
40+
$node->{raftport} =$raftport;
41+
push(@nodes,$node);
42+
}
43+
44+
my$mm_connstr =join(',',map {"${\$_->connstr('postgres') }" }@nodes);
45+
my$raft_peers =join(',',map {join(':',$_->{id},$_->host,$_->{raftport}) }@nodes);
46+
47+
diag("mm_connstr =$mm_connstr\n");
48+
diag("raft_peers =$raft_peers\n");
49+
50+
diag("initting and configuring nodes");
51+
foreachmy$node (@nodes)
52+
{
53+
my$id =$node->{id};
54+
my$host =$node->host;
55+
my$pgport =$node->port;
56+
my$raftport =$node->{raftport};
57+
58+
$node->init(hba_permit_replication=> 0);
59+
$node->append_conf("postgresql.conf",qq(
60+
listen_addresses = '$host'
61+
unix_socket_directories = ''
62+
port =$pgport
63+
max_prepared_transactions = 10
64+
max_worker_processes = 10
65+
wal_level = logical
66+
fsync = off
67+
max_wal_senders = 10
68+
wal_sender_timeout = 0
69+
max_replication_slots = 10
70+
shared_preload_libraries = 'raftable,multimaster'
71+
multimaster.workers = 4
72+
multimaster.queue_size = 10485760 # 10mb
73+
multimaster.node_id =$id
74+
multimaster.conn_strings = '$mm_connstr'
75+
multimaster.use_raftable = true
76+
raftable.id =$id
77+
raftable.peers = '$raft_peers'
78+
));
79+
80+
$node->append_conf("pg_hba.conf",qq(
81+
local replication all trust
82+
host replication all 127.0.0.1/32 trust
83+
host replication all ::1/128 trust
84+
));
85+
}
86+
87+
diag("starting nodes");
88+
foreachmy$node (@nodes)
89+
{
90+
$node->start();
91+
}
92+
93+
my ($rc,$out,$err);
94+
95+
diag("sleeping");
96+
sleep(10);
97+
98+
my@argv = ('dtmbench');
99+
foreachmy$node (@nodes)
100+
{
101+
push(@argv,'-c',$node->connstr('postgres'));
102+
}
103+
push(@argv,'-n', 10,'-a', 1000,'-w', 10,'-r', 1);
104+
105+
diag("running dtmbench -i");
106+
TestLib::run_log([@argv,'-i']);
107+
108+
diag("running dtmbench");
109+
TestLib::run_log(\@argv,'>', \$out);
110+
if ($out =~/Wrong sum/)
111+
{
112+
fail("inconsistency detected");
113+
}
114+
else
115+
{
116+
pass("all consistent during dtmbench");
117+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp