Content-Length: 678776 | pFad | https://github.com/postgrespro/postgres_cluster/commit/ca129e58c01f29ef24a734313ff315933b3d5b67

D6 Fix regression tests to use only global names beginning with "regress_". · postgrespro/postgres_cluster@ca129e5 · GitHub
Skip to content

Commit ca129e5

Browse files
committed
Fix regression tests to use only global names beginning with "regress_".
In commit 18555b1 we tentatively established a rule that regression tests should use names containing "regression" for databases, and names starting with "regress_" for all other globally-visible object names, so as to circumscribe the side-effects that "make installcheck" could have on an existing installation. However, no enforcement mechanism was created, so it's unsurprising that some new violations have crept in since then. In fact, a whole new *category* of violations has crept in, to wit we now also have globally-visible subscription and replication origen names, and "make installcheck" could very easily clobber user-created objects of those types. So it's past time to do something about this. This commit sanitizes the tests enough that they will pass (i.e. not generate any visible warnings) with the enforcement mechanism I'll add in the next commit. There are some TAP tests that still trigger the warnings, but the warnings do not cause test failure. Since these tests do not actually run against a pre-existing installation, there's no need to worry whether they could conflict with user-created objects. The problem with rolenames.sql testing special role names like "user" is still there, and is dealt with only very cosmetically in this patch (by hiding the warnings :-(). What we actually need to do to be safe is to take that test script out of "make installcheck" altogether, but that seems like material for a separate patch. Discussion: https://postgr.es/m/16638.1468620817@sss.pgh.pa.us
1 parent a1e61ba commit ca129e5

File tree

12 files changed

+254
-205
lines changed

12 files changed

+254
-205
lines changed

contrib/test_decoding/expected/replorigen.out

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,38 @@
22
SET synchronous_commit = on;
33
CREATE TABLE origen_tbl(id serial primary key, data text);
44
CREATE TABLE target_tbl(id serial primary key, data text);
5-
SELECT pg_replication_origen_create('test_decoding: regression_slot');
5+
SELECT pg_replication_origen_create('regress_test_decoding: regression_slot');
66
pg_replication_origen_create
77
------------------------------
88
1
99
(1 row)
1010

1111
-- ensure duplicate creations fail
12-
SELECT pg_replication_origen_create('test_decoding: regression_slot');
12+
SELECT pg_replication_origen_create('regress_test_decoding: regression_slot');
1313
ERROR: duplicate key value violates unique constraint "pg_replication_origen_roname_index"
14-
DETAIL: Key (roname)=(test_decoding: regression_slot) already exists.
14+
DETAIL: Key (roname)=(regress_test_decoding: regression_slot) already exists.
1515
--ensure deletions work (once)
16-
SELECT pg_replication_origen_create('test_decoding: temp');
16+
SELECT pg_replication_origen_create('regress_test_decoding: temp');
1717
pg_replication_origen_create
1818
------------------------------
1919
2
2020
(1 row)
2121

22-
SELECT pg_replication_origen_drop('test_decoding: temp');
22+
SELECT pg_replication_origen_drop('regress_test_decoding: temp');
2323
pg_replication_origen_drop
2424
----------------------------
2525

2626
(1 row)
2727

28-
SELECT pg_replication_origen_drop('test_decoding: temp');
29-
ERROR: replication origen "test_decoding: temp" does not exist
28+
SELECT pg_replication_origen_drop('regress_test_decoding: temp');
29+
ERROR: replication origen "regress_test_decoding: temp" does not exist
3030
-- various failure checks for undefined slots
31-
select pg_replication_origen_advance('test_decoding: temp', '0/1');
32-
ERROR: replication origen "test_decoding: temp" does not exist
33-
select pg_replication_origen_session_setup('test_decoding: temp');
34-
ERROR: replication origen "test_decoding: temp" does not exist
35-
select pg_replication_origen_progress('test_decoding: temp', true);
36-
ERROR: replication origen "test_decoding: temp" does not exist
31+
select pg_replication_origen_advance('regress_test_decoding: temp', '0/1');
32+
ERROR: replication origen "regress_test_decoding: temp" does not exist
33+
select pg_replication_origen_session_setup('regress_test_decoding: temp');
34+
ERROR: replication origen "regress_test_decoding: temp" does not exist
35+
select pg_replication_origen_progress('regress_test_decoding: temp', true);
36+
ERROR: replication origen "regress_test_decoding: temp" does not exist
3737
SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding');
3838
?column?
3939
----------
@@ -57,14 +57,14 @@ SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'inc
5757

5858
INSERT INTO origen_tbl(data) VALUES ('will be replicated, but not decoded again');
5959
-- mark session as replaying
60-
SELECT pg_replication_origen_session_setup('test_decoding: regression_slot');
60+
SELECT pg_replication_origen_session_setup('regress_test_decoding: regression_slot');
6161
pg_replication_origen_session_setup
6262
-------------------------------------
6363

6464
(1 row)
6565

6666
-- ensure we prevent duplicate setup
67-
SELECT pg_replication_origen_session_setup('test_decoding: regression_slot');
67+
SELECT pg_replication_origen_session_setup('regress_test_decoding: regression_slot');
6868
ERROR: cannot setup replication origen when one is already setup
6969
SELECT '' FROM pg_logical_emit_message(false, 'test', 'this message will not be decoded');
7070
?column?
@@ -103,19 +103,19 @@ SELECT pg_replication_origen_session_reset();
103103
(1 row)
104104

105105
SELECT local_id, external_id, remote_lsn, local_lsn <> '0/0' FROM pg_replication_origen_status;
106-
local_id | external_id | remote_lsn | ?column?
107-
----------+--------------------------------+------------+----------
108-
1 | test_decoding: regression_slot | 0/AABBCCDD | t
106+
local_id | external_id | remote_lsn | ?column?
107+
----------+----------------------------------------+------------+----------
108+
1 | regress_test_decoding: regression_slot | 0/AABBCCDD | t
109109
(1 row)
110110

111111
-- check replication progress identified by name is correct
112-
SELECT pg_replication_origen_progress('test_decoding: regression_slot', false);
112+
SELECT pg_replication_origen_progress('regress_test_decoding: regression_slot', false);
113113
pg_replication_origen_progress
114114
--------------------------------
115115
0/AABBCCDD
116116
(1 row)
117117

118-
SELECT pg_replication_origen_progress('test_decoding: regression_slot', true);
118+
SELECT pg_replication_origen_progress('regress_test_decoding: regression_slot', true);
119119
pg_replication_origen_progress
120120
--------------------------------
121121
0/AABBCCDD
@@ -146,7 +146,7 @@ SELECT pg_drop_replication_slot('regression_slot');
146146

147147
(1 row)
148148

149-
SELECT pg_replication_origen_drop('test_decoding: regression_slot');
149+
SELECT pg_replication_origen_drop('regress_test_decoding: regression_slot');
150150
pg_replication_origen_drop
151151
----------------------------
152152

contrib/test_decoding/expected/rewrite.out

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ CREATE FUNCTION exec(text) returns void language plpgsql volatile
1111
EXECUTE $1;
1212
END;
1313
$f$;
14-
CREATE ROLE justforcomments NOLOGIN;
14+
CREATE ROLE regress_justforcomments NOLOGIN;
1515
SELECT exec(
1616
format($outer$CREATE FUNCTION iamalongfunction() RETURNS TEXT IMMUTABLE LANGUAGE SQL AS $f$SELECT text %L$f$$outer$,
1717
(SELECT repeat(string_agg(to_char(g.i, 'FM0000'), ''), 50) FROM generate_series(1, 500) g(i))));
@@ -29,7 +29,7 @@ SELECT exec(
2929
(1 row)
3030

3131
SELECT exec(
32-
format($outer$COMMENT ON ROLE JUSTFORCOMMENTS IS %L$outer$,
32+
format($outer$COMMENT ON ROLE REGRESS_JUSTFORCOMMENTS IS %L$outer$,
3333
iamalongfunction()));
3434
exec
3535
------
@@ -161,4 +161,4 @@ SELECT pg_drop_replication_slot('regression_slot');
161161
DROP TABLE IF EXISTS replication_example;
162162
DROP FUNCTION iamalongfunction();
163163
DROP FUNCTION exec(text);
164-
DROP ROLE justforcomments;
164+
DROP ROLE regress_justforcomments;

contrib/test_decoding/sql/replorigen.sql

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ SET synchronous_commit = on;
44
CREATE TABLE origen_tbl(id serial primary key, data text);
55
CREATE TABLE target_tbl(id serial primary key, data text);
66

7-
SELECT pg_replication_origen_create('test_decoding: regression_slot');
7+
SELECT pg_replication_origen_create('regress_test_decoding: regression_slot');
88
-- ensure duplicate creations fail
9-
SELECT pg_replication_origen_create('test_decoding: regression_slot');
9+
SELECT pg_replication_origen_create('regress_test_decoding: regression_slot');
1010

1111
--ensure deletions work (once)
12-
SELECT pg_replication_origen_create('test_decoding: temp');
13-
SELECT pg_replication_origen_drop('test_decoding: temp');
14-
SELECT pg_replication_origen_drop('test_decoding: temp');
12+
SELECT pg_replication_origen_create('regress_test_decoding: temp');
13+
SELECT pg_replication_origen_drop('regress_test_decoding: temp');
14+
SELECT pg_replication_origen_drop('regress_test_decoding: temp');
1515

1616
-- various failure checks for undefined slots
17-
select pg_replication_origen_advance('test_decoding: temp', '0/1');
18-
select pg_replication_origen_session_setup('test_decoding: temp');
19-
select pg_replication_origen_progress('test_decoding: temp', true);
17+
select pg_replication_origen_advance('regress_test_decoding: temp', '0/1');
18+
select pg_replication_origen_session_setup('regress_test_decoding: temp');
19+
select pg_replication_origen_progress('regress_test_decoding: temp', true);
2020

2121
SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding');
2222

@@ -31,10 +31,10 @@ SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'inc
3131
INSERT INTO origen_tbl(data) VALUES ('will be replicated, but not decoded again');
3232

3333
-- mark session as replaying
34-
SELECT pg_replication_origen_session_setup('test_decoding: regression_slot');
34+
SELECT pg_replication_origen_session_setup('regress_test_decoding: regression_slot');
3535

3636
-- ensure we prevent duplicate setup
37-
SELECT pg_replication_origen_session_setup('test_decoding: regression_slot');
37+
SELECT pg_replication_origen_session_setup('regress_test_decoding: regression_slot');
3838

3939
SELECT '' FROM pg_logical_emit_message(false, 'test', 'this message will not be decoded');
4040

@@ -54,8 +54,8 @@ SELECT pg_replication_origen_session_reset();
5454
SELECT local_id, external_id, remote_lsn, local_lsn <> '0/0' FROM pg_replication_origen_status;
5555

5656
-- check replication progress identified by name is correct
57-
SELECT pg_replication_origen_progress('test_decoding: regression_slot', false);
58-
SELECT pg_replication_origen_progress('test_decoding: regression_slot', true);
57+
SELECT pg_replication_origen_progress('regress_test_decoding: regression_slot', false);
58+
SELECT pg_replication_origen_progress('regress_test_decoding: regression_slot', true);
5959

6060
-- ensure reset requires previously setup state
6161
SELECT pg_replication_origen_session_reset();
@@ -68,4 +68,4 @@ INSERT INTO origen_tbl(data) VALUES ('will be replicated');
6868
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'only-local', '1');
6969

7070
SELECT pg_drop_replication_slot('regression_slot');
71-
SELECT pg_replication_origen_drop('test_decoding: regression_slot');
71+
SELECT pg_replication_origen_drop('regress_test_decoding: regression_slot');

contrib/test_decoding/sql/rewrite.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ CREATE FUNCTION exec(text) returns void language plpgsql volatile
1313
EXECUTE $1;
1414
END;
1515
$f$;
16-
CREATE ROLE justforcomments NOLOGIN;
16+
CREATE ROLE regress_justforcomments NOLOGIN;
1717

1818
SELECT exec(
1919
format($outer$CREATE FUNCTION iamalongfunction() RETURNS TEXT IMMUTABLE LANGUAGE SQL AS $f$SELECT text %L$f$$outer$,
@@ -22,7 +22,7 @@ SELECT exec(
2222
format($outer$COMMENT ON FUNCTION iamalongfunction() IS %L$outer$,
2323
iamalongfunction()));
2424
SELECT exec(
25-
format($outer$COMMENT ON ROLE JUSTFORCOMMENTS IS %L$outer$,
25+
format($outer$COMMENT ON ROLE REGRESS_JUSTFORCOMMENTS IS %L$outer$,
2626
iamalongfunction()));
2727
CREATE TABLE iamalargetable AS SELECT iamalongfunction() longfunctionoutput;
2828

@@ -104,4 +104,4 @@ SELECT pg_drop_replication_slot('regression_slot');
104104
DROP TABLE IF EXISTS replication_example;
105105
DROP FUNCTION iamalongfunction();
106106
DROP FUNCTION exec(text);
107-
DROP ROLE justforcomments;
107+
DROP ROLE regress_justforcomments;

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/postgrespro/postgres_cluster/commit/ca129e58c01f29ef24a734313ff315933b3d5b67

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy