mirror of https://github.com/citusdata/citus.git
Adds a connection string to run tests on that connection
parent
17373d51da
commit
93b97248b2
|
@ -112,7 +112,7 @@ check-empty: all
|
||||||
-- $(MULTI_REGRESS_OPTS) $(EXTRA_TESTS)
|
-- $(MULTI_REGRESS_OPTS) $(EXTRA_TESTS)
|
||||||
|
|
||||||
check-multi: all
|
check-multi: all
|
||||||
$(pg_regress_multi_check) --load-extension=citus \
|
$(pg_regress_multi_check) --constr="$(constr)" --load-extension=citus \
|
||||||
-- $(MULTI_REGRESS_OPTS) --schedule=$(citus_abs_srcdir)/multi_schedule $(EXTRA_TESTS)
|
-- $(MULTI_REGRESS_OPTS) --schedule=$(citus_abs_srcdir)/multi_schedule $(EXTRA_TESTS)
|
||||||
|
|
||||||
check-multi-vg: all
|
check-multi-vg: all
|
||||||
|
|
|
@ -80,6 +80,7 @@ my $pgCtlTimeout = undef;
|
||||||
my $connectionTimeout = 5000;
|
my $connectionTimeout = 5000;
|
||||||
my $useMitmproxy = 0;
|
my $useMitmproxy = 0;
|
||||||
my $mitmFifoPath = catfile($TMP_CHECKDIR, "mitmproxy.fifo");
|
my $mitmFifoPath = catfile($TMP_CHECKDIR, "mitmproxy.fifo");
|
||||||
|
my $conninfo = "";
|
||||||
|
|
||||||
my $serversAreShutdown = "TRUE";
|
my $serversAreShutdown = "TRUE";
|
||||||
my $usingWindows = 0;
|
my $usingWindows = 0;
|
||||||
|
@ -108,6 +109,7 @@ GetOptions(
|
||||||
'pg_ctl-timeout=s' => \$pgCtlTimeout,
|
'pg_ctl-timeout=s' => \$pgCtlTimeout,
|
||||||
'connection-timeout=s' => \$connectionTimeout,
|
'connection-timeout=s' => \$connectionTimeout,
|
||||||
'mitmproxy' => \$useMitmproxy,
|
'mitmproxy' => \$useMitmproxy,
|
||||||
|
'conninfo=s' => \$conninfo,
|
||||||
'help' => sub { Usage() });
|
'help' => sub { Usage() });
|
||||||
|
|
||||||
# Update environment to include [DY]LD_LIBRARY_PATH/LIBDIR/etc -
|
# Update environment to include [DY]LD_LIBRARY_PATH/LIBDIR/etc -
|
||||||
|
@ -261,6 +263,10 @@ sub revert_replace_postgres
|
||||||
# partial run, even if we're now not using valgrind.
|
# partial run, even if we're now not using valgrind.
|
||||||
revert_replace_postgres();
|
revert_replace_postgres();
|
||||||
|
|
||||||
|
my $host = "localhost";
|
||||||
|
my $user = "postgres";
|
||||||
|
my $dbname = "postgres";
|
||||||
|
|
||||||
# n.b. previously this was on port 57640, which caused issues because that's in the
|
# n.b. previously this was on port 57640, which caused issues because that's in the
|
||||||
# ephemeral port range, it was sometimes in the TIME_WAIT state which prevented us from
|
# ephemeral port range, it was sometimes in the TIME_WAIT state which prevented us from
|
||||||
# binding to it. 9060 is now used because it will never be used for client connections,
|
# binding to it. 9060 is now used because it will never be used for client connections,
|
||||||
|
@ -270,13 +276,46 @@ my $mitmPort = 9060;
|
||||||
|
|
||||||
# Set some default configuration options
|
# Set some default configuration options
|
||||||
my $masterPort = 57636;
|
my $masterPort = 57636;
|
||||||
|
|
||||||
my $workerCount = 2;
|
my $workerCount = 2;
|
||||||
my @workerPorts = ();
|
my @workerPorts = ();
|
||||||
|
|
||||||
|
if ( $conninfo )
|
||||||
|
{
|
||||||
|
my %convals = split /=|\s/, $conninfo;
|
||||||
|
if (exists $convals{user})
|
||||||
|
{
|
||||||
|
$user = $convals{user};
|
||||||
|
}
|
||||||
|
if (exists $convals{host})
|
||||||
|
{
|
||||||
|
$host = $convals{host};
|
||||||
|
}
|
||||||
|
if (exists $convals{port})
|
||||||
|
{
|
||||||
|
$masterPort = $convals{port};
|
||||||
|
}
|
||||||
|
if (exists $convals{dbname})
|
||||||
|
{
|
||||||
|
$dbname = $convals{dbname};
|
||||||
|
}
|
||||||
|
|
||||||
|
my $worker1port = `psql "$conninfo" -t -c "SELECT nodeport FROM pg_dist_node ORDER BY nodeid LIMIT 1;"`;
|
||||||
|
my $worker2port = `psql "$conninfo" -t -c "SELECT nodeport FROM pg_dist_node ORDER BY nodeid OFFSET 1 LIMIT 1;"`;
|
||||||
|
|
||||||
|
$worker1port =~ s/^\s+|\s+$//g;
|
||||||
|
$worker2port =~ s/^\s+|\s+$//g;
|
||||||
|
|
||||||
|
push(@workerPorts, $worker1port);
|
||||||
|
push(@workerPorts, $worker2port);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
for (my $workerIndex = 1; $workerIndex <= $workerCount; $workerIndex++) {
|
for (my $workerIndex = 1; $workerIndex <= $workerCount; $workerIndex++) {
|
||||||
my $workerPort = $masterPort + $workerIndex;
|
my $workerPort = $masterPort + $workerIndex;
|
||||||
push(@workerPorts, $workerPort);
|
push(@workerPorts, $workerPort);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
my $followerCoordPort = 9070;
|
my $followerCoordPort = 9070;
|
||||||
my @followerWorkerPorts = ();
|
my @followerWorkerPorts = ();
|
||||||
|
@ -285,8 +324,6 @@ for (my $workerIndex = 1; $workerIndex <= $workerCount; $workerIndex++) {
|
||||||
push(@followerWorkerPorts, $workerPort);
|
push(@followerWorkerPorts, $workerPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
my $host = "localhost";
|
|
||||||
my $user = "postgres";
|
|
||||||
my @pgOptions = ();
|
my @pgOptions = ();
|
||||||
|
|
||||||
# Postgres options set for the tests
|
# Postgres options set for the tests
|
||||||
|
@ -396,7 +433,17 @@ for my $option (@userPgOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
# define functions as signature->definition
|
# define functions as signature->definition
|
||||||
|
%functions = ();
|
||||||
|
if (!$conninfo)
|
||||||
|
{
|
||||||
%functions = ('fake_fdw_handler()', 'fdw_handler AS \'citus\' LANGUAGE C STRICT;');
|
%functions = ('fake_fdw_handler()', 'fdw_handler AS \'citus\' LANGUAGE C STRICT;');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
# when running the tests on a cluster these will be created with run_command_on_workers
|
||||||
|
# so extra single quotes are needed
|
||||||
|
%functions = ('fake_fdw_handler()', 'fdw_handler AS \'\'citus\'\' LANGUAGE C STRICT;');
|
||||||
|
}
|
||||||
|
|
||||||
#define fdws as name->handler name
|
#define fdws as name->handler name
|
||||||
%fdws = ('fake_fdw', 'fake_fdw_handler');
|
%fdws = ('fake_fdw', 'fake_fdw_handler');
|
||||||
|
@ -492,6 +539,9 @@ else
|
||||||
}
|
}
|
||||||
close $fh;
|
close $fh;
|
||||||
|
|
||||||
|
|
||||||
|
if (!$conninfo)
|
||||||
|
{
|
||||||
make_path(catfile($TMP_CHECKDIR, $MASTERDIR, 'log')) or die "Could not create $MASTERDIR directory";
|
make_path(catfile($TMP_CHECKDIR, $MASTERDIR, 'log')) or die "Could not create $MASTERDIR directory";
|
||||||
for my $port (@workerPorts)
|
for my $port (@workerPorts)
|
||||||
{
|
{
|
||||||
|
@ -531,12 +581,13 @@ else
|
||||||
or die "Could not create worker data directory";
|
or die "Could not create worker data directory";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Routine to shutdown servers at failure/exit
|
# Routine to shutdown servers at failure/exit
|
||||||
sub ShutdownServers()
|
sub ShutdownServers()
|
||||||
{
|
{
|
||||||
if ($serversAreShutdown eq "FALSE")
|
if (!$conninfo && $serversAreShutdown eq "FALSE")
|
||||||
{
|
{
|
||||||
system(catfile("$bindir", "pg_ctl"),
|
system(catfile("$bindir", "pg_ctl"),
|
||||||
('stop', '-w', '-D', catfile($TMP_CHECKDIR, $MASTERDIR, 'data'))) == 0
|
('stop', '-w', '-D', catfile($TMP_CHECKDIR, $MASTERDIR, 'data'))) == 0
|
||||||
|
@ -663,6 +714,8 @@ if ($followercluster)
|
||||||
}
|
}
|
||||||
|
|
||||||
# Start servers
|
# Start servers
|
||||||
|
if (!$conninfo)
|
||||||
|
{
|
||||||
if(system(catfile("$bindir", "pg_ctl"),
|
if(system(catfile("$bindir", "pg_ctl"),
|
||||||
('start', '-w',
|
('start', '-w',
|
||||||
'-o', join(" ", @pgOptions)." -c port=$masterPort $synchronousReplication",
|
'-o', join(" ", @pgOptions)." -c port=$masterPort $synchronousReplication",
|
||||||
|
@ -684,6 +737,7 @@ for my $port (@workerPorts)
|
||||||
die "Could not start worker server";
|
die "Could not start worker server";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Setup the follower nodes
|
# Setup the follower nodes
|
||||||
if ($followercluster)
|
if ($followercluster)
|
||||||
|
@ -730,6 +784,8 @@ if ($followercluster)
|
||||||
# Create database, extensions, types, functions and fdws on the workers,
|
# Create database, extensions, types, functions and fdws on the workers,
|
||||||
# pg_regress won't know to create them for us.
|
# pg_regress won't know to create them for us.
|
||||||
###
|
###
|
||||||
|
if (!$conninfo)
|
||||||
|
{
|
||||||
for my $port (@workerPorts)
|
for my $port (@workerPorts)
|
||||||
{
|
{
|
||||||
system(catfile($bindir, "psql"),
|
system(catfile($bindir, "psql"),
|
||||||
|
@ -769,6 +825,40 @@ for my $port (@workerPorts)
|
||||||
or die "Could not create server $fdwServer on worker";
|
or die "Could not create server $fdwServer on worker";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for my $extension (@extensions)
|
||||||
|
{
|
||||||
|
system(catfile($bindir, "psql"),
|
||||||
|
('-X', '-h', $host, '-p', $masterPort, '-U', $user, "-d", $dbname,
|
||||||
|
'-c', "SELECT run_command_on_workers('CREATE EXTENSION IF NOT EXISTS $extension;');")) == 0
|
||||||
|
or die "Could not create extension on worker";
|
||||||
|
}
|
||||||
|
foreach my $function (keys %functions)
|
||||||
|
{
|
||||||
|
system(catfile($bindir, "psql"),
|
||||||
|
('-X', '-h', $host, '-p', $masterPort, '-U', $user, "-d", $dbname,
|
||||||
|
'-c', "SELECT run_command_on_workers('CREATE FUNCTION $function RETURNS $functions{$function};');")) == 0
|
||||||
|
or die "Could not create FUNCTION $function on worker";
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach my $fdw (keys %fdws)
|
||||||
|
{
|
||||||
|
system(catfile($bindir, "psql"),
|
||||||
|
('-X', '-h', $host, '-p', $masterPort, '-U', $user, "-d", $dbname,
|
||||||
|
'-c', "SELECT run_command_on_workers('CREATE FOREIGN DATA WRAPPER $fdw HANDLER $fdws{$fdw};');")) == 0
|
||||||
|
or die "Could not create foreign data wrapper $fdw on worker";
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach my $fdwServer (keys %fdwServers)
|
||||||
|
{
|
||||||
|
system(catfile($bindir, "psql"),
|
||||||
|
('-X', '-h', $host, '-p', $masterPort, '-U', $user, "-d", $dbname,
|
||||||
|
'-c', "SELECT run_command_on_workers('CREATE SERVER $fdwServer FOREIGN DATA WRAPPER $fdwServers{$fdwServer};');")) == 0
|
||||||
|
or die "Could not create server $fdwServer on worker";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Prepare pg_regress arguments
|
# Prepare pg_regress arguments
|
||||||
my @arguments = (
|
my @arguments = (
|
||||||
|
@ -820,6 +910,11 @@ elsif ($isolationtester)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if ($conninfo)
|
||||||
|
{
|
||||||
|
push(@arguments, "--dbname=$dbname");
|
||||||
|
push(@arguments, "--use-existing");
|
||||||
|
}
|
||||||
$exitcode = system("$plainRegress", @arguments);
|
$exitcode = system("$plainRegress", @arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue