1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

Establish conventions about global object names used in regression tests.

To ensure that "make installcheck" can be used safely against an existing
installation, we need to be careful about what global object names
(database, role, and tablespace names) we use; otherwise we might
accidentally clobber important objects.  There's been a weak consensus that
test databases should have names including "regression", and that test role
names should start with "regress_", but we didn't have any particular rule
about tablespace names; and neither of the other rules was followed with
any consistency either.

This commit moves us a long way towards having a hard-and-fast rule that
regression test databases must have names including "regression", and that
test role and tablespace names must start with "regress_".  It's not
completely there because I did not touch some test cases in rolenames.sql
that test creation of special role names like "session_user".  That will
require some rethinking of exactly what we want to test, whereas the intent
of this patch is just to hit all the cases in which the needed renamings
are cosmetic.

There is no enforcement mechanism in this patch either, but if we don't
add one we can expect that the tests will soon be violating the convention
again.  Again, that's not such a cosmetic change and it will require
discussion.  (But I did use a quick-hack enforcement patch to find these
cases.)

Discussion: <16638.1468620817@sss.pgh.pa.us>
This commit is contained in:
Tom Lane
2016-07-17 18:42:31 -04:00
parent 7482fc4600
commit 18555b1323
173 changed files with 3334 additions and 3284 deletions

View File

@ -143,13 +143,13 @@ SELECT dblink_connect('myconn', 'dbname=postgres');
CREATE SERVER fdtest FOREIGN DATA WRAPPER dblink_fdw OPTIONS (hostaddr '127.0.0.1', dbname 'contrib_regression');
CREATE USER dblink_regression_test WITH PASSWORD 'secret';
CREATE USER MAPPING FOR dblink_regression_test SERVER fdtest OPTIONS (user 'dblink_regression_test', password 'secret');
GRANT USAGE ON FOREIGN SERVER fdtest TO dblink_regression_test;
GRANT SELECT ON TABLE foo TO dblink_regression_test;
CREATE USER regress_dblink_user WITH PASSWORD 'secret';
CREATE USER MAPPING FOR regress_dblink_user SERVER fdtest OPTIONS (user 'regress_dblink_user', password 'secret');
GRANT USAGE ON FOREIGN SERVER fdtest TO regress_dblink_user;
GRANT SELECT ON TABLE foo TO regress_dblink_user;
\set ORIGINAL_USER :USER
\c - dblink_regression_test
\c - regress_dblink_user
SELECT dblink_connect('myconn', 'fdtest');
dblink_connect
----------------
@ -173,10 +173,10 @@ SELECT * FROM dblink('myconn','SELECT * FROM foo') AS t(a int, b text, c text[])
(11 rows)
\c - :ORIGINAL_USER
REVOKE USAGE ON FOREIGN SERVER fdtest FROM dblink_regression_test;
REVOKE SELECT ON TABLE foo FROM dblink_regression_test;
DROP USER MAPPING FOR dblink_regression_test SERVER fdtest;
DROP USER dblink_regression_test;
REVOKE USAGE ON FOREIGN SERVER fdtest FROM regress_dblink_user;
REVOKE SELECT ON TABLE foo FROM regress_dblink_user;
DROP USER MAPPING FOR regress_dblink_user SERVER fdtest;
DROP USER regress_dblink_user;
DROP SERVER fdtest;
</screen>
</refsect1>

View File

@ -112,8 +112,14 @@ make installcheck-parallel
<envar>PGPORT</envar> environment variables. The tests will be run in a
database named <literal>regression</>; any existing database by this name
will be dropped.
</para>
<para>
The tests will also transiently create some cluster-wide objects, such as
user identities named <literal>regressuser<replaceable>N</></literal>.
roles and tablespaces. These objects will have names beginning with
<literal>regress_</literal>. Beware of using <literal>installcheck</>
mode in installations that have any actual users or tablespaces named
that way.
</para>
</sect2>
@ -195,8 +201,8 @@ make installcheck-world
<para>
When using <literal>installcheck</> mode, these tests will destroy any
existing databases named <literal>pl_regression</>,
<literal>contrib_regression</>, <literal>isolationtest</>,
<literal>regress1</>, or <literal>connectdb</>, as well as
<literal>contrib_regression</>, <literal>isolation_regression</>,
<literal>ecpg1_regression</>, or <literal>ecpg2_regression</>, as well as
<literal>regression</>.
</para>
</sect2>