Skip to content

Commit b99a02f

Browse files
Adding preseed tests
1 parent 5b47c54 commit b99a02f

File tree

5 files changed

+222
-1
lines changed

5 files changed

+222
-1
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ SCRIPTS_built = pglogical_create_subscriber
1818
PG_CPPFLAGS = -I$(libpq_srcdir)
1919
SHLIB_LINK = $(libpq)
2020

21-
REGRESS = init_fail init basic extended toasted replication_set add_table matview bidirectional foreign_key functions drop
21+
REGRESS = preseed init_fail init preseed_check basic extended toasted replication_set add_table matview bidirectional foreign_key functions drop
2222

2323
ifdef USE_PGXS
2424

expected/preseed.out

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Tests to ensure that objects/data that exists pre-clone is successfully
3+
* cloned. The results are checked, after the clone, in preseed_check.sql.
4+
*/
5+
-- Unfortunately the cloned DB currently isn't the same between bdr and udr
6+
CREATE SEQUENCE some_local_seq;
7+
CREATE TABLE some_local_tbl(id serial primary key, key text unique not null, data text);
8+
INSERT INTO some_local_tbl(key, data) VALUES('key1', 'data1');
9+
INSERT INTO some_local_tbl(key, data) VALUES('key2', NULL);
10+
INSERT INTO some_local_tbl(key, data) VALUES('key3', 'data3');
11+
CREATE TABLE some_local_tbl1(id serial, key text unique not null, data text);
12+
INSERT INTO some_local_tbl1(key, data) VALUES('key1', 'data1');
13+
INSERT INTO some_local_tbl1(key, data) VALUES('key2', NULL);
14+
INSERT INTO some_local_tbl1(key, data) VALUES('key3', 'data3');
15+
CREATE TABLE some_local_tbl2(id serial, key text, data text);
16+
INSERT INTO some_local_tbl2(key, data) VALUES('key1', 'data1');
17+
INSERT INTO some_local_tbl2(key, data) VALUES('key2', NULL);
18+
INSERT INTO some_local_tbl2(key, data) VALUES('key3', 'data3');
19+
CREATE TABLE some_local_tbl3(id integer, key text, data text);
20+
INSERT INTO some_local_tbl3(key, data) VALUES('key1', 'data1');
21+
INSERT INTO some_local_tbl3(key, data) VALUES('key2', NULL);
22+
INSERT INTO some_local_tbl3(key, data) VALUES('key3', 'data3');

expected/preseed_check.out

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
-- Verify data from preseed.sql has correctly been cloned
2+
\c regression
3+
\d some_local_tbl
4+
Table "public.some_local_tbl"
5+
Column | Type | Modifiers
6+
--------+---------+-------------------------------------------------------------
7+
id | integer | not null default nextval('some_local_tbl_id_seq'::regclass)
8+
key | text | not null
9+
data | text |
10+
Indexes:
11+
"some_local_tbl_pkey" PRIMARY KEY, btree (id)
12+
"some_local_tbl_key_key" UNIQUE CONSTRAINT, btree (key)
13+
14+
SELECT * FROM some_local_tbl ORDER BY id;
15+
id | key | data
16+
----+------+-------
17+
1 | key1 | data1
18+
2 | key2 |
19+
3 | key3 | data3
20+
(3 rows)
21+
22+
\d some_local_tbl1
23+
Table "public.some_local_tbl1"
24+
Column | Type | Modifiers
25+
--------+---------+--------------------------------------------------------------
26+
id | integer | not null default nextval('some_local_tbl1_id_seq'::regclass)
27+
key | text | not null
28+
data | text |
29+
Indexes:
30+
"some_local_tbl1_key_key" UNIQUE CONSTRAINT, btree (key)
31+
32+
SELECT * FROM some_local_tbl1 ORDER BY id;
33+
id | key | data
34+
----+------+-------
35+
1 | key1 | data1
36+
2 | key2 |
37+
3 | key3 | data3
38+
(3 rows)
39+
40+
\d some_local_tbl2
41+
Table "public.some_local_tbl2"
42+
Column | Type | Modifiers
43+
--------+---------+--------------------------------------------------------------
44+
id | integer | not null default nextval('some_local_tbl2_id_seq'::regclass)
45+
key | text |
46+
data | text |
47+
48+
SELECT * FROM some_local_tbl2 ORDER BY id;
49+
id | key | data
50+
----+------+-------
51+
1 | key1 | data1
52+
2 | key2 |
53+
3 | key3 | data3
54+
(3 rows)
55+
56+
\d some_local_tbl3
57+
Table "public.some_local_tbl3"
58+
Column | Type | Modifiers
59+
--------+---------+-----------
60+
id | integer |
61+
key | text |
62+
data | text |
63+
64+
SELECT * FROM some_local_tbl3 ORDER BY id;
65+
id | key | data
66+
----+------+-------
67+
| key1 | data1
68+
| key2 |
69+
| key3 | data3
70+
(3 rows)
71+
72+
\c postgres
73+
\d some_local_tbl
74+
Table "public.some_local_tbl"
75+
Column | Type | Modifiers
76+
--------+---------+-------------------------------------------------------------
77+
id | integer | not null default nextval('some_local_tbl_id_seq'::regclass)
78+
key | text | not null
79+
data | text |
80+
Indexes:
81+
"some_local_tbl_pkey" PRIMARY KEY, btree (id)
82+
"some_local_tbl_key_key" UNIQUE CONSTRAINT, btree (key)
83+
84+
SELECT * FROM some_local_tbl ORDER BY id;
85+
id | key | data
86+
----+-----+------
87+
(0 rows)
88+
89+
\d some_local_tbl1
90+
Table "public.some_local_tbl1"
91+
Column | Type | Modifiers
92+
--------+---------+--------------------------------------------------------------
93+
id | integer | not null default nextval('some_local_tbl1_id_seq'::regclass)
94+
key | text | not null
95+
data | text |
96+
Indexes:
97+
"some_local_tbl1_key_key" UNIQUE CONSTRAINT, btree (key)
98+
99+
SELECT * FROM some_local_tbl1 ORDER BY id;
100+
id | key | data
101+
----+-----+------
102+
(0 rows)
103+
104+
\d some_local_tbl2
105+
Table "public.some_local_tbl2"
106+
Column | Type | Modifiers
107+
--------+---------+--------------------------------------------------------------
108+
id | integer | not null default nextval('some_local_tbl2_id_seq'::regclass)
109+
key | text |
110+
data | text |
111+
112+
SELECT * FROM some_local_tbl2 ORDER BY id;
113+
id | key | data
114+
----+-----+------
115+
(0 rows)
116+
117+
\d some_local_tbl3
118+
Table "public.some_local_tbl3"
119+
Column | Type | Modifiers
120+
--------+---------+-----------
121+
id | integer |
122+
key | text |
123+
data | text |
124+
125+
SELECT * FROM some_local_tbl3 ORDER BY id;
126+
id | key | data
127+
----+-----+------
128+
(0 rows)
129+
130+
\c regression
131+
SELECT pglogical.replicate_ddl_command($$
132+
DROP TABLE public.some_local_tbl;
133+
DROP TABLE public.some_local_tbl1;
134+
DROP TABLE public.some_local_tbl2;
135+
DROP TABLE public.some_local_tbl3;
136+
$$);
137+
replicate_ddl_command
138+
-----------------------
139+
t
140+
(1 row)
141+

sql/preseed.sql

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Tests to ensure that objects/data that exists pre-clone is successfully
3+
* cloned. The results are checked, after the clone, in preseed_check.sql.
4+
*/
5+
6+
-- Unfortunately the cloned DB currently isn't the same between bdr and udr
7+
CREATE SEQUENCE some_local_seq;
8+
CREATE TABLE some_local_tbl(id serial primary key, key text unique not null, data text);
9+
INSERT INTO some_local_tbl(key, data) VALUES('key1', 'data1');
10+
INSERT INTO some_local_tbl(key, data) VALUES('key2', NULL);
11+
INSERT INTO some_local_tbl(key, data) VALUES('key3', 'data3');
12+
CREATE TABLE some_local_tbl1(id serial, key text unique not null, data text);
13+
INSERT INTO some_local_tbl1(key, data) VALUES('key1', 'data1');
14+
INSERT INTO some_local_tbl1(key, data) VALUES('key2', NULL);
15+
INSERT INTO some_local_tbl1(key, data) VALUES('key3', 'data3');
16+
CREATE TABLE some_local_tbl2(id serial, key text, data text);
17+
INSERT INTO some_local_tbl2(key, data) VALUES('key1', 'data1');
18+
INSERT INTO some_local_tbl2(key, data) VALUES('key2', NULL);
19+
INSERT INTO some_local_tbl2(key, data) VALUES('key3', 'data3');
20+
CREATE TABLE some_local_tbl3(id integer, key text, data text);
21+
INSERT INTO some_local_tbl3(key, data) VALUES('key1', 'data1');
22+
INSERT INTO some_local_tbl3(key, data) VALUES('key2', NULL);
23+
INSERT INTO some_local_tbl3(key, data) VALUES('key3', 'data3');

sql/preseed_check.sql

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
-- Verify data from preseed.sql has correctly been cloned
2+
\c regression
3+
\d some_local_tbl
4+
SELECT * FROM some_local_tbl ORDER BY id;
5+
6+
\d some_local_tbl1
7+
SELECT * FROM some_local_tbl1 ORDER BY id;
8+
9+
\d some_local_tbl2
10+
SELECT * FROM some_local_tbl2 ORDER BY id;
11+
12+
\d some_local_tbl3
13+
SELECT * FROM some_local_tbl3 ORDER BY id;
14+
15+
\c postgres
16+
17+
\d some_local_tbl
18+
SELECT * FROM some_local_tbl ORDER BY id;
19+
20+
\d some_local_tbl1
21+
SELECT * FROM some_local_tbl1 ORDER BY id;
22+
23+
\d some_local_tbl2
24+
SELECT * FROM some_local_tbl2 ORDER BY id;
25+
26+
\d some_local_tbl3
27+
SELECT * FROM some_local_tbl3 ORDER BY id;
28+
29+
\c regression
30+
SELECT pglogical.replicate_ddl_command($$
31+
DROP TABLE public.some_local_tbl;
32+
DROP TABLE public.some_local_tbl1;
33+
DROP TABLE public.some_local_tbl2;
34+
DROP TABLE public.some_local_tbl3;
35+
$$);

0 commit comments

Comments
 (0)