Skip to content

Commit d6d317d

Browse files
committed
Use in-place tablespaces in regression test.
Remove the machinery from pg_regress that manages the testtablespace directory. Instead, use "in-place" tablespaces, because they work correctly when there is a streaming replica running on the same host. Reviewed-by: Andres Freund <andres@anarazel.de> Reviewed-by: Michael Paquier <michael@paquier.xyz> Discussion: https://postgr.es/m/CA%2BhUKGKpRWQ9SxdxxDmTBCJoR0YnFpMBe7kyzY8SUQk%2BHeskxg%40mail.gmail.com
1 parent 7170f21 commit d6d317d

File tree

5 files changed

+28
-51
lines changed

5 files changed

+28
-51
lines changed

src/test/regress/GNUmakefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ submake-contrib-spi: | submake-libpgport submake-generated-headers
112112
## Run tests
113113
##
114114

115-
REGRESS_OPTS = --dlpath=. --max-concurrent-tests=20 --make-testtablespace-dir \
115+
REGRESS_OPTS = --dlpath=. --max-concurrent-tests=20 \
116116
$(EXTRA_REGRESS_OPTS)
117117

118118
check: all
@@ -155,5 +155,4 @@ clean distclean maintainer-clean: clean-lib
155155
rm -f $(OBJS) refint$(DLSUFFIX) autoinc$(DLSUFFIX)
156156
rm -f pg_regress_main.o pg_regress.o pg_regress$(X)
157157
# things created by various check targets
158-
rm -rf testtablespace
159158
rm -rf $(pg_regress_clean_files)

src/test/regress/expected/tablespace.out

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1-
-- directory paths are passed to us in environment variables
2-
\getenv abs_builddir PG_ABS_BUILDDIR
3-
\set testtablespace :abs_builddir '/testtablespace'
1+
-- relative tablespace locations are not allowed
2+
CREATE TABLESPACE regress_tblspace LOCATION 'relative'; -- fail
3+
ERROR: tablespace location must be an absolute path
4+
-- empty tablespace locations are not usually allowed
5+
CREATE TABLESPACE regress_tblspace LOCATION ''; -- fail
6+
ERROR: tablespace location must be an absolute path
7+
-- as a special developer-only option to allow us to use tablespaces
8+
-- with streaming replication on the same server, an empty location
9+
-- can be allowed as a way to say that the tablespace should be created
10+
-- as a directory in pg_tblspc, rather than being a symlink
11+
SET allow_in_place_tablespaces = true;
412
-- create a tablespace using WITH clause
5-
CREATE TABLESPACE regress_tblspacewith LOCATION :'testtablespace' WITH (some_nonexistent_parameter = true); -- fail
13+
CREATE TABLESPACE regress_tblspacewith LOCATION '' WITH (some_nonexistent_parameter = true); -- fail
614
ERROR: unrecognized parameter "some_nonexistent_parameter"
7-
CREATE TABLESPACE regress_tblspacewith LOCATION :'testtablespace' WITH (random_page_cost = 3.0); -- ok
15+
CREATE TABLESPACE regress_tblspacewith LOCATION '' WITH (random_page_cost = 3.0); -- ok
816
-- check to see the parameter was used
917
SELECT spcoptions FROM pg_tablespace WHERE spcname = 'regress_tblspacewith';
1018
spcoptions
@@ -15,7 +23,7 @@ SELECT spcoptions FROM pg_tablespace WHERE spcname = 'regress_tblspacewith';
1523
-- drop the tablespace so we can re-use the location
1624
DROP TABLESPACE regress_tblspacewith;
1725
-- create a tablespace we can use
18-
CREATE TABLESPACE regress_tblspace LOCATION :'testtablespace';
26+
CREATE TABLESPACE regress_tblspace LOCATION '';
1927
-- try setting and resetting some properties for the new tablespace
2028
ALTER TABLESPACE regress_tblspace SET (random_page_cost = 1.0, seq_page_cost = 1.1);
2129
ALTER TABLESPACE regress_tblspace SET (some_nonexistent_parameter = true); -- fail

src/test/regress/pg_regress.c

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -438,32 +438,6 @@ string_matches_pattern(const char *str, const char *pattern)
438438
return false;
439439
}
440440

441-
/*
442-
* Clean out the test tablespace dir, or create it if it doesn't exist.
443-
*
444-
* On Windows, doing this cleanup here makes it possible to run the
445-
* regression tests under a Windows administrative user account with the
446-
* restricted token obtained when starting pg_regress.
447-
*/
448-
static void
449-
prepare_testtablespace_dir(void)
450-
{
451-
char testtablespace[MAXPGPATH];
452-
453-
snprintf(testtablespace, MAXPGPATH, "%s/testtablespace", outputdir);
454-
455-
if (directory_exists(testtablespace))
456-
{
457-
if (!rmtree(testtablespace, true))
458-
{
459-
fprintf(stderr, _("\n%s: could not remove test tablespace \"%s\"\n"),
460-
progname, testtablespace);
461-
exit(2);
462-
}
463-
}
464-
make_directory(testtablespace);
465-
}
466-
467441
/*
468442
* Scan resultmap file to find which platform-specific expected files to use.
469443
*
@@ -2014,7 +1988,6 @@ help(void)
20141988
printf(_(" --launcher=CMD use CMD as launcher of psql\n"));
20151989
printf(_(" --load-extension=EXT load the named extension before running the\n"));
20161990
printf(_(" tests; can appear multiple times\n"));
2017-
printf(_(" --make-testtablespace-dir create testtablespace directory\n"));
20181991
printf(_(" --max-connections=N maximum number of concurrent connections\n"));
20191992
printf(_(" (default is 0, meaning unlimited)\n"));
20201993
printf(_(" --max-concurrent-tests=N maximum number of concurrent tests in schedule\n"));
@@ -2073,12 +2046,10 @@ regression_main(int argc, char *argv[],
20732046
{"load-extension", required_argument, NULL, 22},
20742047
{"config-auth", required_argument, NULL, 24},
20752048
{"max-concurrent-tests", required_argument, NULL, 25},
2076-
{"make-testtablespace-dir", no_argument, NULL, 26},
20772049
{NULL, 0, NULL, 0}
20782050
};
20792051

20802052
bool use_unix_sockets;
2081-
bool make_testtablespace_dir = false;
20822053
_stringlist *sl;
20832054
int c;
20842055
int i;
@@ -2204,9 +2175,6 @@ regression_main(int argc, char *argv[],
22042175
case 25:
22052176
max_concurrent_tests = atoi(optarg);
22062177
break;
2207-
case 26:
2208-
make_testtablespace_dir = true;
2209-
break;
22102178
default:
22112179
/* getopt_long already emitted a complaint */
22122180
fprintf(stderr, _("\nTry \"%s -h\" for more information.\n"),
@@ -2259,9 +2227,6 @@ regression_main(int argc, char *argv[],
22592227
unlimit_core_size();
22602228
#endif
22612229

2262-
if (make_testtablespace_dir)
2263-
prepare_testtablespace_dir();
2264-
22652230
if (temp_instance)
22662231
{
22672232
FILE *pg_conf;

src/test/regress/sql/tablespace.sql

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1-
-- directory paths are passed to us in environment variables
2-
\getenv abs_builddir PG_ABS_BUILDDIR
1+
-- relative tablespace locations are not allowed
2+
CREATE TABLESPACE regress_tblspace LOCATION 'relative'; -- fail
33

4-
\set testtablespace :abs_builddir '/testtablespace'
4+
-- empty tablespace locations are not usually allowed
5+
CREATE TABLESPACE regress_tblspace LOCATION ''; -- fail
6+
7+
-- as a special developer-only option to allow us to use tablespaces
8+
-- with streaming replication on the same server, an empty location
9+
-- can be allowed as a way to say that the tablespace should be created
10+
-- as a directory in pg_tblspc, rather than being a symlink
11+
SET allow_in_place_tablespaces = true;
512

613
-- create a tablespace using WITH clause
7-
CREATE TABLESPACE regress_tblspacewith LOCATION :'testtablespace' WITH (some_nonexistent_parameter = true); -- fail
8-
CREATE TABLESPACE regress_tblspacewith LOCATION :'testtablespace' WITH (random_page_cost = 3.0); -- ok
14+
CREATE TABLESPACE regress_tblspacewith LOCATION '' WITH (some_nonexistent_parameter = true); -- fail
15+
CREATE TABLESPACE regress_tblspacewith LOCATION '' WITH (random_page_cost = 3.0); -- ok
916

1017
-- check to see the parameter was used
1118
SELECT spcoptions FROM pg_tablespace WHERE spcname = 'regress_tblspacewith';
@@ -14,7 +21,7 @@ SELECT spcoptions FROM pg_tablespace WHERE spcname = 'regress_tblspacewith';
1421
DROP TABLESPACE regress_tblspacewith;
1522

1623
-- create a tablespace we can use
17-
CREATE TABLESPACE regress_tblspace LOCATION :'testtablespace';
24+
CREATE TABLESPACE regress_tblspace LOCATION '';
1825

1926
-- try setting and resetting some properties for the new tablespace
2027
ALTER TABLESPACE regress_tblspace SET (random_page_cost = 1.0, seq_page_cost = 1.1);

src/tools/msvc/vcregress.pl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ sub installcheck_internal
133133
"--bindir=../../../$Config/psql",
134134
"--schedule=${schedule}_schedule",
135135
"--max-concurrent-tests=20",
136-
"--make-testtablespace-dir",
137136
"--encoding=SQL_ASCII",
138137
"--no-locale");
139138
push(@args, $maxconn) if $maxconn;
@@ -168,7 +167,6 @@ sub check
168167
"--bindir=",
169168
"--schedule=${schedule}_schedule",
170169
"--max-concurrent-tests=20",
171-
"--make-testtablespace-dir",
172170
"--encoding=SQL_ASCII",
173171
"--no-locale",
174172
"--temp-instance=./tmp_check");

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy