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

Commit 7f99d61

Browse files
committed
multidb refactor: run/stop/regress to Makefile
1 parent 08d8da6 commit 7f99d61

File tree

3 files changed

+71
-3
lines changed

3 files changed

+71
-3
lines changed

Cluster.pm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ sub new
6363
{
6464
my $host = "127.0.0.1";
6565
my ($pgport, $arbiter_port) = allocate_ports($host, 2);
66+
67+
if(defined $ENV{MMPORT}) {
68+
$pgport = $ENV{MMPORT};
69+
delete $ENV{MMPORT};
70+
}
71+
6672
my $node = new PostgresNode("node$i", $host, $pgport);
6773
$node->{id} = $i;
6874
$node->{arbiter_port} = $arbiter_port;

Makefile

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
EXTENSION = multimaster
32
DATA = multimaster--1.0.sql
43
OBJS = src/multimaster.o src/dmq.o src/commit.o src/bytebuf.o src/bgwpool.o \
@@ -27,14 +26,43 @@ top_builddir = ../..
2726
include $(top_builddir)/src/Makefile.global
2827
include $(top_srcdir)/contrib/contrib-global.mk
2928
endif
29+
3030
.PHONY: all
3131

3232
EXTRA_INSTALL=contrib/mmts
3333

3434
all: multimaster.so
3535

36-
37-
3836
check: temp-install
3937
$(prove_check)
4038

39+
submake-regress:
40+
$(MAKE) -C $(top_builddir)/src/test/regress all
41+
42+
run: temp-install
43+
rm -rf '$(CURDIR)'/tmp_check
44+
$(MKDIR_P) '$(CURDIR)'/tmp_check
45+
cd $(srcdir) && TESTDIR='$(CURDIR)' \
46+
$(with_temp_install) \
47+
MMPORT='6$(DEF_PGPORT)' \
48+
PG_REGRESS='$(CURDIR)/$(top_builddir)/src/test/regress/pg_regress' \
49+
perl run.pl --start
50+
51+
stop:
52+
cd $(srcdir) && TESTDIR='$(CURDIR)' \
53+
$(with_temp_install) \
54+
PGPORT='6$(DEF_PGPORT)' \
55+
PG_REGRESS='$(CURDIR)/$(top_builddir)/src/test/regress/pg_regress' \
56+
perl run.pl --stop
57+
58+
regress: submake-regress
59+
cd $(CURDIR)/$(top_builddir)/src/test/regress && \
60+
$(with_temp_install) \
61+
PGPORT='6$(DEF_PGPORT)' \
62+
PGHOST='127.0.0.1' \
63+
PGUSER='$(USER)' \
64+
./pg_regress \
65+
--bindir='' \
66+
--use-existing \
67+
--schedule=serial_schedule \
68+
--dbname=postgres

run.pl

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env perl
2+
3+
use File::Basename;
4+
BEGIN { unshift @INC, '.'; unshift @INC, '../../src/test/perl' }
5+
use Cluster;
6+
7+
my $n_nodes = 3;
8+
my $action = $ARGV[0];
9+
10+
if ($action eq "--start")
11+
{
12+
my $cluster = new Cluster($n_nodes);
13+
$cluster->init();
14+
$cluster->configure();
15+
$cluster->start();
16+
$cluster->await_nodes( (0..$n_nodes-1) );
17+
}
18+
elsif ($action eq "--stop")
19+
{
20+
for my $i (1..$n_nodes)
21+
{
22+
TestLib::system_or_bail('pg_ctl',
23+
'-D', "$TestLib::tmp_check/t_run_node${i}_data/pgdata",
24+
'-m', 'fast',
25+
'stop');
26+
}
27+
}
28+
else
29+
{
30+
die("Usage: run.pl --start/--stop\n");
31+
}
32+
33+
34+

0 commit comments

Comments
 (0)