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

Commitd8baade

Browse files
kvapkelvich
authored andcommitted
Use the Cluster perl module in 000_deadlock test.
1 parentcc38c6a commitd8baade

File tree

1 file changed

+8
-87
lines changed

1 file changed

+8
-87
lines changed

‎t/000_deadlock.pl

Lines changed: 8 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use strict;
22
use warnings;
33

4-
usePostgresNode;
4+
useCluster;
55
use TestLib;
66
use Test::Moretests=> 1;
77

@@ -34,98 +34,19 @@ sub query_exec_async
3434
return$rv;
3535
}
3636

37-
my%allocated_ports = ();
38-
suballocate_ports
39-
{
40-
my@allocated_now = ();
41-
my ($host,$ports_to_alloc) =@_;
42-
43-
while ($ports_to_alloc > 0)
44-
{
45-
my$port =int(rand() * 16384) + 49152;
46-
nextif$allocated_ports{$port};
47-
diag("Checking for port$port\n");
48-
if (!TestLib::run_log(['pg_isready','-h',$host,'-p',$port]))
49-
{
50-
$allocated_ports{$port} = 1;
51-
push(@allocated_now,$port);
52-
$ports_to_alloc--;
53-
}
54-
}
55-
56-
return@allocated_now;
57-
}
58-
59-
my$nnodes = 2;
60-
my@nodes = ();
61-
62-
# Create nodes and allocate ports
63-
foreachmy$i (1..$nnodes)
64-
{
65-
my$host ="127.0.0.1";
66-
my ($pgport,$raftport) = allocate_ports($host, 2);
67-
my$node = new PostgresNode("node$i",$host,$pgport);
68-
$node->{id} =$i;
69-
$node->{raftport} =$raftport;
70-
push(@nodes,$node);
71-
}
37+
my$cluster = new Cluster(2);
7238

73-
my$mm_connstr =join(',',map {"${\$_->connstr('postgres') }" }@nodes);
74-
my$raft_peers =join(',',map {join(':',$_->{id},$_->host,$_->{raftport}) }@nodes);
75-
76-
diag("mm_connstr =$mm_connstr\n");
77-
diag("raft_peers =$raft_peers\n");
78-
79-
# Init and Configure
80-
foreachmy$node (@nodes)
81-
{
82-
my$id =$node->{id};
83-
my$host =$node->host;
84-
my$pgport =$node->port;
85-
my$raftport =$node->{raftport};
86-
87-
$node->init(hba_permit_replication=> 0);
88-
$node->append_conf("postgresql.conf",qq(
89-
listen_addresses = '$host'
90-
unix_socket_directories = ''
91-
port =$pgport
92-
max_prepared_transactions = 10
93-
max_worker_processes = 10
94-
wal_level = logical
95-
fsync = off
96-
max_wal_senders = 10
97-
wal_sender_timeout = 0
98-
max_replication_slots = 10
99-
shared_preload_libraries = 'raftable,multimaster'
100-
multimaster.workers = 4
101-
multimaster.queue_size = 10485760 # 10mb
102-
multimaster.node_id =$id
103-
multimaster.conn_strings = '$mm_connstr'
104-
multimaster.use_raftable = true
105-
raftable.id =$id
106-
raftable.peers = '$raft_peers'
107-
));
108-
109-
$node->append_conf("pg_hba.conf",qq(
110-
local replication all trust
111-
host replication all 127.0.0.1/32 trust
112-
host replication all ::1/128 trust
113-
));
114-
}
115-
116-
# Start
117-
foreachmy$node (@nodes)
118-
{
119-
$node->start();
120-
}
39+
$cluster->init();
40+
$cluster->configure();
41+
$cluster->start();
12142

12243
my ($rc,$out,$err);
12344
sleep(10);
12445

125-
$nodes[0]->psql('postgres',"create table t(k int primary key, v text)");
126-
$nodes[0]->psql('postgres',"insert into t values (1, 'hello'), (2, 'world')");
46+
$cluster->psql(0,'postgres',"create table t(k int primary key, v text)");
47+
$cluster->psql(0,'postgres',"insert into t values (1, 'hello'), (2, 'world')");
12748

128-
my@conns =map { DBI->connect('DBI:Pg:' .$_->connstr()) }@nodes;
49+
my@conns =map { DBI->connect('DBI:Pg:' .$_->connstr()) } @{$cluster->{nodes}};
12950

13051
query_exec($conns[0],"begin");
13152
query_exec($conns[1],"begin");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp