Create regress_tblspc in test_setup
authorAndres Freund
Sat, 11 Feb 2023 17:52:36 +0000 (09:52 -0800)
committerAndres Freund
Sat, 11 Feb 2023 18:03:04 +0000 (10:03 -0800)
An upcoming test needs to use a tablespace as part of its test. Historically,
we wanted tablespace creation be done in a dedicated file, so it's easy to
disable when testing replication. But that is not necessary anymore, due to
allow_in_place_tablespaces.

Create regress_tblspace tablespace in test_setup. Move the tablespace test to
the end of the parallel schedule, so other tests can use it.

Author: Melanie Plageman 
Reviewed-by: Andres Freund
Discussion: https://postgr.es/m/20200124195226[email protected]

src/test/regress/expected/tablespace.out
src/test/regress/expected/test_setup.out
src/test/regress/parallel_schedule
src/test/regress/sql/tablespace.sql
src/test/regress/sql/test_setup.sql

index c52cf1cfcf91969224ce5fc97ac6b5a3d9504dc9..9aabb8534974151b4a40e79170245667036340ab 100644 (file)
@@ -22,8 +22,6 @@ SELECT spcoptions FROM pg_tablespace WHERE spcname = 'regress_tblspacewith';
 
 -- drop the tablespace so we can re-use the location
 DROP TABLESPACE regress_tblspacewith;
--- create a tablespace we can use
-CREATE TABLESPACE regress_tblspace LOCATION '';
 -- This returns a relative path as of an effect of allow_in_place_tablespaces,
 -- masking the tablespace OID used in the path name.
 SELECT regexp_replace(pg_tablespace_location(oid), '(pg_tblspc)/(\d+)', '\1/NNN')
@@ -331,7 +329,7 @@ CREATE TABLE testschema.part1 PARTITION OF testschema.part FOR VALUES IN (1);
 CREATE INDEX part_a_idx ON testschema.part (a) TABLESPACE regress_tblspace;
 CREATE TABLE testschema.part2 PARTITION OF testschema.part FOR VALUES IN (2);
 SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c
-    where c.reltablespace = t.oid AND c.relname LIKE 'part%_idx';
+    where c.reltablespace = t.oid AND c.relname LIKE 'part%_idx' ORDER BY relname;
    relname   |     spcname      
 -------------+------------------
  part1_a_idx | regress_tblspace
index 391b36d1318fa7d2e7c3ed02641bd1da19bd4a36..4f54fe20ec7a3f723270c75bfaab770997c6291a 100644 (file)
@@ -18,6 +18,9 @@ SET synchronous_commit = on;
 -- and most of the core regression tests still expect that.
 --
 GRANT ALL ON SCHEMA public TO public;
+-- Create a tablespace we can use in tests.
+SET allow_in_place_tablespaces = true;
+CREATE TABLESPACE regress_tblspace LOCATION '';
 --
 -- These tables have traditionally been referenced by many tests,
 -- so create and populate them.  Insert only non-error values here.
index a930dfe48cb6462a685cc38566bb22136159b16b..15e015b3d64bd40d0a359b6e9235702d3685394d 100644 (file)
 # required setup steps
 test: test_setup
 
-# run tablespace by itself, and early, because it forces a checkpoint;
-# we'd prefer not to have checkpoints later in the tests because that
-# interferes with crash-recovery testing.
-test: tablespace
-
 # ----------
 # The first group of parallel tests
 # ----------
@@ -132,3 +127,7 @@ test: event_trigger oidjoins
 
 # this test also uses event triggers, so likewise run it by itself
 test: fast_default
+
+# run tablespace test at the end because it drops the tablespace created during
+# setup that other tests may use.
+test: tablespace
index 21db433f2a8ef1335e56df431c2dbdddf2e2fcac..d274d9615efa7df88d5ec8e863d5102d1358909a 100644 (file)
@@ -20,8 +20,6 @@ SELECT spcoptions FROM pg_tablespace WHERE spcname = 'regress_tblspacewith';
 -- drop the tablespace so we can re-use the location
 DROP TABLESPACE regress_tblspacewith;
 
--- create a tablespace we can use
-CREATE TABLESPACE regress_tblspace LOCATION '';
 -- This returns a relative path as of an effect of allow_in_place_tablespaces,
 -- masking the tablespace OID used in the path name.
 SELECT regexp_replace(pg_tablespace_location(oid), '(pg_tblspc)/(\d+)', '\1/NNN')
@@ -225,7 +223,7 @@ CREATE TABLE testschema.part1 PARTITION OF testschema.part FOR VALUES IN (1);
 CREATE INDEX part_a_idx ON testschema.part (a) TABLESPACE regress_tblspace;
 CREATE TABLE testschema.part2 PARTITION OF testschema.part FOR VALUES IN (2);
 SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c
-    where c.reltablespace = t.oid AND c.relname LIKE 'part%_idx';
+    where c.reltablespace = t.oid AND c.relname LIKE 'part%_idx' ORDER BY relname;
 \d testschema.part
 \d+ testschema.part
 \d testschema.part1
index 02c0c84c3ad831d62a2cfb16870d35ddf7aa9a99..8439b38d21bb8c54eefbd4d98861864c382ec2a1 100644 (file)
@@ -23,6 +23,10 @@ SET synchronous_commit = on;
 --
 GRANT ALL ON SCHEMA public TO public;
 
+-- Create a tablespace we can use in tests.
+SET allow_in_place_tablespaces = true;
+CREATE TABLESPACE regress_tblspace LOCATION '';
+
 --
 -- These tables have traditionally been referenced by many tests,
 -- so create and populate them.  Insert only non-error values here.