diff --git a/src/test/regress/Makefile b/src/test/regress/Makefile index 4d72f20ac..7ad661a36 100644 --- a/src/test/regress/Makefile +++ b/src/test/regress/Makefile @@ -14,7 +14,7 @@ endif ## Citus regression support ## 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) # 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 \ -- $(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 $(pg_regress_multi_check) --load-extension=citus \ --server-option=citus.task_executor_type=task-tracker \ diff --git a/src/test/regress/expected/isolation_cluster_management.out b/src/test/regress/expected/isolation_cluster_management.out new file mode 100644 index 000000000..8ee09c894 --- /dev/null +++ b/src/test/regress/expected/isolation_cluster_management.out @@ -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) diff --git a/src/test/regress/expected/isolation_concurrent_dml.out b/src/test/regress/expected/isolation_concurrent_dml.out new file mode 100644 index 000000000..a5e6a1737 --- /dev/null +++ b/src/test/regress/expected/isolation_concurrent_dml.out @@ -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; + +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; + diff --git a/src/test/regress/isolation_schedule b/src/test/regress/isolation_schedule new file mode 100644 index 000000000..d702c065f --- /dev/null +++ b/src/test/regress/isolation_schedule @@ -0,0 +1,2 @@ +test: isolation_cluster_management +test: isolation_concurrent_dml diff --git a/src/test/regress/pg_regress_multi.pl b/src/test/regress/pg_regress_multi.pl index a38e810b6..99407ac51 100755 --- a/src/test/regress/pg_regress_multi.pl +++ b/src/test/regress/pg_regress_multi.pl @@ -26,8 +26,11 @@ sub Usage() print " pg_regress_multi [MULTI OPTIONS] -- [PG REGRESS OPTS]\n"; print "\n"; print "Multi Options:\n"; + print " --isolationtester Run isolationtester tests instead of plain tests\n"; print " --bindir Path to postgres binary 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 " --load-extension Extensions to install in all nodes\n"; print " --server-option Config option to pass to the server\n"; @@ -35,9 +38,12 @@ sub Usage() } # Option parsing +my $isolationtester = 0; my $bindir = ""; my $libdir = undef; my $pgxsdir = ""; +my $postgresBuilddir = ""; +my $postgresSrcdir = ""; my $majorversion = ""; my @extensions = (); my @userPgOptions = (); @@ -50,9 +56,12 @@ my %operators = (); my $serversAreShutdown = "TRUE"; GetOptions( + 'isolationtester' => \$isolationtester, 'bindir=s' => \$bindir, 'libdir=s' => \$libdir, 'pgxsdir=s' => \$pgxsdir, + 'postgres-builddir=s' => \$postgresBuilddir, + 'postgres-srcdir=s' => \$postgresSrcdir, 'majorversion=s' => \$majorversion, 'load-extension=s' => \@extensions, 'server-option=s' => \@userPgOptions, @@ -73,6 +82,25 @@ if (defined $libdir) $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 my $masterPort = 57636; my $workerCount = 2; @@ -313,8 +341,17 @@ push(@arguments, @ARGV); my $startTime = time(); # Finally run the tests -system("$pgxsdir/src/test/regress/pg_regress", @arguments) == 0 - or die "Could not run regression tests"; +if (!$isolationtester) +{ + 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(); diff --git a/src/test/regress/specs/isolation_cluster_management.spec b/src/test/regress/specs/isolation_cluster_management.spec new file mode 100644 index 000000000..19c9d8001 --- /dev/null +++ b/src/test/regress/specs/isolation_cluster_management.spec @@ -0,0 +1,8 @@ +session "s1" +step "s1a" +{ + SELECT master_add_node('localhost', 57637); + SELECT master_add_node('localhost', 57638); +} + +permutation "s1a" diff --git a/src/test/regress/specs/isolation_concurrent_dml.spec b/src/test/regress/specs/isolation_concurrent_dml.spec new file mode 100644 index 000000000..3288d7521 --- /dev/null +++ b/src/test/regress/specs/isolation_concurrent_dml.spec @@ -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"