bdr: Add minimal checks for the cloning of databases with contents.
authorAndres Freund <andres@anarazel.de>
Thu, 21 May 2015 21:36:41 +0000 (23:36 +0200)
committerAndres Freund <andres@anarazel.de>
Mon, 25 May 2015 01:54:41 +0000 (03:54 +0200)
These should be expanded, but are better than nothing.

Makefile.in
bdr_regress_bdr.conf
bdr_regress_udr.conf
expected/preseed.out [new file with mode: 0644]
expected/preseed_check.out [new file with mode: 0644]
sql/preseed.sql [new file with mode: 0644]
sql/preseed_check.sql [new file with mode: 0644]

index d0fb4b1cf064f2df8e0570e7e6ae1d189b23f0db..4f2ed3227d6158df788807322c2f6879df627ea3 100644 (file)
@@ -244,7 +244,9 @@ endif
 
 REGRESSCHECKS= \
    init \
+   preseed \
    $(REGRESSINIT) \
+   preseed_check \
    supervisordb \
    upgrade \
    identifier \
index c5ae0546bb612ae0d3edf3c087cacce0de5151dd..cee4f47429688e360d968a837751c548884a11f6 100644 (file)
@@ -2,6 +2,7 @@ track_commit_timestamp = on
 
 include = 'bdr_regress_common.conf'
 
+bdrtest.origdb = 'postgres'
 bdrtest.readdb1 = 'regression'
 bdrtest.readdb2 = 'postgres'
 bdrtest.writedb1 = 'regression'
index 4536320eeda9b3aef1e4b836fff023d5bf895f8c..988deaa53437190e26601f4e0fdf345bdf425486 100644 (file)
@@ -5,6 +5,7 @@ bdr.connections = 'node1'
 bdr.node1_dsn = 'dbname=regression'
 bdr.node1_local_dbname = 'postgres'
 
+bdrtest.origdb = 'regression'
 bdrtest.readdb1 = 'postgres'
 bdrtest.readdb2 = 'postgres'
 bdrtest.writedb1 = 'regression'
diff --git a/expected/preseed.out b/expected/preseed.out
new file mode 100644 (file)
index 0000000..a681690
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Tests to ensure that objects/data that exists pre-clone is successfully
+ * cloned. The results are checked, after the clone, in preseed_check.sql.
+ */
+-- Unfortunately the cloned DB currently isn't the same between bdr and udr
+SELECT current_setting('bdrtest.origdb') AS origdb
+\gset
+\c :origdb
+DO $DO$BEGIN
+IF bdr.bdr_variant() = 'BDR' THEN
+    SET default_sequenceam = local;
+END IF;
+END; $DO$;
+CREATE SEQUENCE some_local_seq;
+CREATE TABLE some_local_tbl(id serial primary key, key text unique not null, data text);
+INSERT INTO some_local_tbl(key, data) VALUES('key1', 'data1');
+INSERT INTO some_local_tbl(key, data) VALUES('key2', NULL);
+INSERT INTO some_local_tbl(key, data) VALUES('key3', 'data3');
diff --git a/expected/preseed_check.out b/expected/preseed_check.out
new file mode 100644 (file)
index 0000000..9df28e6
--- /dev/null
@@ -0,0 +1,45 @@
+-- Verify data from preseed.sql has correctly been cloned
+\c regression
+\d some_local_tbl
+                         Table "public.some_local_tbl"
+ Column |  Type   |                          Modifiers                          
+--------+---------+-------------------------------------------------------------
+ id     | integer | not null default nextval('some_local_tbl_id_seq'::regclass)
+ key    | text    | not null
+ data   | text    | 
+Indexes:
+    "some_local_tbl_pkey" PRIMARY KEY, btree (id)
+    "some_local_tbl_key_key" UNIQUE CONSTRAINT, btree (key)
+Triggers:
+    truncate_trigger AFTER TRUNCATE ON some_local_tbl FOR EACH STATEMENT EXECUTE PROCEDURE bdr.queue_truncate()
+
+SELECT * FROM some_local_tbl ORDER BY id;
+ id | key  | data  
+----+------+-------
+  1 | key1 | data1
+  2 | key2 | 
+  3 | key3 | data3
+(3 rows)
+
+\c postgres
+\d some_local_tbl
+                         Table "public.some_local_tbl"
+ Column |  Type   |                          Modifiers                          
+--------+---------+-------------------------------------------------------------
+ id     | integer | not null default nextval('some_local_tbl_id_seq'::regclass)
+ key    | text    | not null
+ data   | text    | 
+Indexes:
+    "some_local_tbl_pkey" PRIMARY KEY, btree (id)
+    "some_local_tbl_key_key" UNIQUE CONSTRAINT, btree (key)
+Triggers:
+    truncate_trigger AFTER TRUNCATE ON some_local_tbl FOR EACH STATEMENT EXECUTE PROCEDURE bdr.queue_truncate()
+
+SELECT * FROM some_local_tbl ORDER BY id;
+ id | key  | data  
+----+------+-------
+  1 | key1 | data1
+  2 | key2 | 
+  3 | key3 | data3
+(3 rows)
+
diff --git a/sql/preseed.sql b/sql/preseed.sql
new file mode 100644 (file)
index 0000000..75acafe
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Tests to ensure that objects/data that exists pre-clone is successfully
+ * cloned. The results are checked, after the clone, in preseed_check.sql.
+ */
+
+-- Unfortunately the cloned DB currently isn't the same between bdr and udr
+SELECT current_setting('bdrtest.origdb') AS origdb
+\gset
+\c :origdb
+
+DO $DO$BEGIN
+IF bdr.bdr_variant() = 'BDR' THEN
+    SET default_sequenceam = local;
+END IF;
+END; $DO$;
+
+CREATE SEQUENCE some_local_seq;
+CREATE TABLE some_local_tbl(id serial primary key, key text unique not null, data text);
+INSERT INTO some_local_tbl(key, data) VALUES('key1', 'data1');
+INSERT INTO some_local_tbl(key, data) VALUES('key2', NULL);
+INSERT INTO some_local_tbl(key, data) VALUES('key3', 'data3');
diff --git a/sql/preseed_check.sql b/sql/preseed_check.sql
new file mode 100644 (file)
index 0000000..37298d1
--- /dev/null
@@ -0,0 +1,8 @@
+-- Verify data from preseed.sql has correctly been cloned
+\c regression
+\d some_local_tbl
+SELECT * FROM some_local_tbl ORDER BY id;
+
+\c postgres
+\d some_local_tbl
+SELECT * FROM some_local_tbl ORDER BY id;