Add very basic isolationtester infrastructure including a trivial test.

pull/917/head
Andres Freund 2016-10-26 05:09:12 -07:00
parent ce73ffdf2e
commit 121b868da5
7 changed files with 137 additions and 3 deletions

View File

@ -14,7 +14,7 @@ endif
## Citus regression support ## Citus regression support
## ##
MULTI_INSTALLDIR=$(CURDIR)/tmp_check/install MULTI_INSTALLDIR=$(CURDIR)/tmp_check/install
pg_regress_multi_check = $(PERL) $(citus_abs_srcdir)/pg_regress_multi.pl --pgxsdir="$(pgxsdir)" --bindir="$(bindir)" --libdir="$(libdir)" --majorversion="$(MAJORVERSION)" pg_regress_multi_check = $(PERL) $(citus_abs_srcdir)/pg_regress_multi.pl --pgxsdir="$(pgxsdir)" --bindir="$(bindir)" --libdir="$(libdir)" --majorversion="$(MAJORVERSION)" --postgres-builddir="$(postgres_abs_builddir)" --postgres-srcdir="$(postgres_abs_srcdir)"
MULTI_REGRESS_OPTS = --inputdir=$(citus_abs_srcdir) $(pg_regress_locale_flags) MULTI_REGRESS_OPTS = --inputdir=$(citus_abs_srcdir) $(pg_regress_locale_flags)
# XXX: Can't actually do useful testruns against install - $libdir # XXX: Can't actually do useful testruns against install - $libdir
@ -49,6 +49,10 @@ check-multi: all tempinstall-main
$(pg_regress_multi_check) --load-extension=citus \ $(pg_regress_multi_check) --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-isolation: all tempinstall-main
$(pg_regress_multi_check) --load-extension=citus --isolationtester \
-- $(MULTI_REGRESS_OPTS) --schedule=$(citus_abs_srcdir)/isolation_schedule $(EXTRA_TESTS)
check-multi-task-tracker-extra: all tempinstall-main check-multi-task-tracker-extra: all tempinstall-main
$(pg_regress_multi_check) --load-extension=citus \ $(pg_regress_multi_check) --load-extension=citus \
--server-option=citus.task_executor_type=task-tracker \ --server-option=citus.task_executor_type=task-tracker \

View File

@ -0,0 +1,13 @@
Parsed test spec with 1 sessions
starting permutation: s1a
step s1a:
SELECT master_add_node('localhost', 57637);
SELECT master_add_node('localhost', 57638);
master_add_node
(1,1,localhost,57637,default,f)
master_add_node
(2,2,localhost,57638,default,f)

View File

@ -0,0 +1,30 @@
Parsed test spec with 2 sessions
starting permutation: s1-begin s1-insert s2-update s1-commit
master_create_worker_shards
step s1-begin:
BEGIN;
step s1-insert:
INSERT INTO test_table VALUES(1);
step s2-update:
UPDATE test_table SET data = 'blarg' WHERE test_id = 1;
<waiting ...>
step s1-commit:
COMMIT;
step s2-update: <... completed>
starting permutation: s1-insert s2-update
master_create_worker_shards
step s1-insert:
INSERT INTO test_table VALUES(1);
step s2-update:
UPDATE test_table SET data = 'blarg' WHERE test_id = 1;

View File

@ -0,0 +1,2 @@
test: isolation_cluster_management
test: isolation_concurrent_dml

View File

@ -26,8 +26,11 @@ sub Usage()
print " pg_regress_multi [MULTI OPTIONS] -- [PG REGRESS OPTS]\n"; print " pg_regress_multi [MULTI OPTIONS] -- [PG REGRESS OPTS]\n";
print "\n"; print "\n";
print "Multi Options:\n"; print "Multi Options:\n";
print " --isolationtester Run isolationtester tests instead of plain tests\n";
print " --bindir Path to postgres binary directory\n"; print " --bindir Path to postgres binary directory\n";
print " --libdir Path to postgres library directory\n"; print " --libdir Path to postgres library directory\n";
print " --postgres-builddir Path to postgres build directory\n";
print " --postgres-srcdir Path to postgres build directory\n";
print " --pgxsdir Path to the PGXS directory\n"; print " --pgxsdir Path to the PGXS directory\n";
print " --load-extension Extensions to install in all nodes\n"; print " --load-extension Extensions to install in all nodes\n";
print " --server-option Config option to pass to the server\n"; print " --server-option Config option to pass to the server\n";
@ -35,9 +38,12 @@ sub Usage()
} }
# Option parsing # Option parsing
my $isolationtester = 0;
my $bindir = ""; my $bindir = "";
my $libdir = undef; my $libdir = undef;
my $pgxsdir = ""; my $pgxsdir = "";
my $postgresBuilddir = "";
my $postgresSrcdir = "";
my $majorversion = ""; my $majorversion = "";
my @extensions = (); my @extensions = ();
my @userPgOptions = (); my @userPgOptions = ();
@ -50,9 +56,12 @@ my %operators = ();
my $serversAreShutdown = "TRUE"; my $serversAreShutdown = "TRUE";
GetOptions( GetOptions(
'isolationtester' => \$isolationtester,
'bindir=s' => \$bindir, 'bindir=s' => \$bindir,
'libdir=s' => \$libdir, 'libdir=s' => \$libdir,
'pgxsdir=s' => \$pgxsdir, 'pgxsdir=s' => \$pgxsdir,
'postgres-builddir=s' => \$postgresBuilddir,
'postgres-srcdir=s' => \$postgresSrcdir,
'majorversion=s' => \$majorversion, 'majorversion=s' => \$majorversion,
'load-extension=s' => \@extensions, 'load-extension=s' => \@extensions,
'server-option=s' => \@userPgOptions, 'server-option=s' => \@userPgOptions,
@ -73,6 +82,25 @@ if (defined $libdir)
$ENV{PATH} = "$libdir:".($ENV{PATH} || ''); $ENV{PATH} = "$libdir:".($ENV{PATH} || '');
} }
my $plainRegress = "$pgxsdir/src/test/regress/pg_regress";
my $isolationRegress = "${postgresBuilddir}/src/test/isolation/pg_isolation_regress";
if ($isolationtester && ! -f "$isolationRegress")
{
die <<"MESSAGE";
isolationtester not found at $isolationRegress.
isolationtester tests can only be run when source (detected as ${postgresSrcdir})
and build (detected as ${postgresBuilddir}) directory corresponding to $bindir
are present.
Additionally isolationtester in src/test/isolation needs to be built,
which it is not by default if tests have not been run. If the build
directory is present locally
"make -C ${postgresBuilddir} all" should do the trick.
MESSAGE
}
# Set some default configuration options # Set some default configuration options
my $masterPort = 57636; my $masterPort = 57636;
my $workerCount = 2; my $workerCount = 2;
@ -313,8 +341,17 @@ push(@arguments, @ARGV);
my $startTime = time(); my $startTime = time();
# Finally run the tests # Finally run the tests
system("$pgxsdir/src/test/regress/pg_regress", @arguments) == 0 if (!$isolationtester)
or die "Could not run regression tests"; {
system("$plainRegress", @arguments) == 0
or die "Could not run regression tests";
}
else
{
push(@arguments, "--dbname=regression");
system("$isolationRegress", @arguments) == 0
or die "Could not run isolation tests";
}
my $endTime = time(); my $endTime = time();

View File

@ -0,0 +1,8 @@
session "s1"
step "s1a"
{
SELECT master_add_node('localhost', 57637);
SELECT master_add_node('localhost', 57638);
}
permutation "s1a"

View File

@ -0,0 +1,40 @@
setup
{
CREATE TABLE test_table (test_id integer NOT NULL, data text);
SELECT master_create_distributed_table('test_table', 'test_id', 'hash');
SELECT master_create_worker_shards('test_table', 4, 2);
}
teardown
{
DROP TABLE IF EXISTS test_table CASCADE;
}
session "s1"
step "s1-begin"
{
BEGIN;
}
step "s1-insert"
{
INSERT INTO test_table VALUES(1);
}
step "s1-commit"
{
COMMIT;
}
session "s2"
step "s2-update"
{
UPDATE test_table SET data = 'blarg' WHERE test_id = 1;
}
# verify that an in-progress insert blocks concurrent updates
permutation "s1-begin" "s1-insert" "s2-update" "s1-commit"
# but an insert without xact will not block
permutation "s1-insert" "s2-update"