bdr: copy bdr isolation tests from base tree
authorChristoph Moench-Tegeder <cmt@burggraben.net>
Mon, 8 Sep 2014 15:37:02 +0000 (17:37 +0200)
committerAndres Freund <andres@anarazel.de>
Mon, 8 Sep 2014 16:24:43 +0000 (18:24 +0200)
in preparation for their removal there

Makefile
expected/isolation/alter_table.out [new file with mode: 0644]
expected/isolation/basic_triple_node.out [new file with mode: 0644]
expected/isolation/update_pk_change_conflict.out [new file with mode: 0644]
specs/isolation/alter_table.spec [new file with mode: 0644]
specs/isolation/basic_triple_node.spec [new file with mode: 0644]
specs/isolation/update_pk_change_conflict.spec [new file with mode: 0644]

index 7b65bb830dc26b7a7a1ae911bccd89bc10798978..cee7b25d1e3b058691e790a52cee5cb2787f47c8 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -111,7 +111,10 @@ ISOLATIONCHECKS=\
    isolation/dmlconflict_ii \
    isolation/dmlconflict_uu \
    isolation/dmlconflict_ud \
-   isolation/dmlconflict_dd
+   isolation/dmlconflict_dd \
+   isolation/alter_table \
+   isolation/basic_triple_node \
+   isolation/update_pk_change_conflict
 
 isolationcheck: all | submake-isolation submake-btree_gist
    [ -e pg_hba.conf ] || ln -s $(top_srcdir)/contrib/bdr/pg_hba.conf .
diff --git a/expected/isolation/alter_table.out b/expected/isolation/alter_table.out
new file mode 100644 (file)
index 0000000..974736f
--- /dev/null
@@ -0,0 +1,126 @@
+Parsed test spec with 2 sessions
+
+starting permutation: n1s1 n1sync n2read n1s2 n1sync n2read n1s3 n1s4 n1sync n2read n1s5 n1s6 n1sync n2read n1s7 n1sync n2read n1s8 n1s9 n1s10 n2s1 n2sync n1s11 n1sync n2sync n2read n1read n2s2 n2sync n1read
+step n1s1: INSERT INTO tst (a, b) VALUES (4, 'four');
+step n1sync: SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication;
+pg_xlog_wait_remote_apply
+
+               
+               
+step n2read: SELECT * FROM tst ORDER BY a;
+a              b              
+
+1              one            
+2              two            
+3              three          
+4              four           
+step n1s2: ALTER TABLE tst ADD COLUMN c TEXT;
+step n1sync: SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication;
+pg_xlog_wait_remote_apply
+
+               
+               
+step n2read: SELECT * FROM tst ORDER BY a;
+a              b              c              
+
+1              one                           
+2              two                           
+3              three                         
+4              four                          
+step n1s3: INSERT INTO tst (a, b, c) VALUES (5, 'five', 'new');
+step n1s4: UPDATE tst set c = 'updated' WHERE c IS NULL;
+step n1sync: SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication;
+pg_xlog_wait_remote_apply
+
+               
+               
+step n2read: SELECT * FROM tst ORDER BY a;
+a              b              c              
+
+1              one            updated        
+2              two            updated        
+3              three          updated        
+4              four           updated        
+5              five           new            
+step n1s5: ALTER TABLE tst ALTER COLUMN c SET DEFAULT 'dflt';
+step n1s6: INSERT INTO tst (a, b) VALUES (6, 'six');
+step n1sync: SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication;
+pg_xlog_wait_remote_apply
+
+               
+               
+step n2read: SELECT * FROM tst ORDER BY a;
+a              b              c              
+
+1              one            updated        
+2              two            updated        
+3              three          updated        
+4              four           updated        
+5              five           new            
+6              six            dflt           
+step n1s7: DELETE FROM tst where a = 5;
+step n1sync: SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication;
+pg_xlog_wait_remote_apply
+
+               
+               
+step n2read: SELECT * FROM tst ORDER BY a;
+a              b              c              
+
+1              one            updated        
+2              two            updated        
+3              three          updated        
+4              four           updated        
+6              six            dflt           
+step n1s8: ALTER TABLE tst ADD COLUMN d INTEGER DEFAULT 100;
+ERROR:  ALTER TABLE ... ADD COLUMN ... DEFAULT may only affect UNLOGGED or TEMPORARY tables when BDR is active; tst is a regular table
+step n1s9: BEGIN;
+step n1s10: ALTER TABLE tst DROP COLUMN c;
+step n2s1: UPDATE tst SET c = 'changed' WHERE a = 1;
+ERROR:  database is locked against writes
+step n2sync: SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication;
+pg_xlog_wait_remote_apply
+
+               
+               
+step n1s11: COMMIT;
+step n1sync: SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication;
+pg_xlog_wait_remote_apply
+
+               
+               
+step n2sync: SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication;
+pg_xlog_wait_remote_apply
+
+               
+               
+step n2read: SELECT * FROM tst ORDER BY a;
+a              b              
+
+1              one            
+2              two            
+3              three          
+4              four           
+6              six            
+step n1read: SELECT * FROM tst ORDER BY a;
+a              b              
+
+1              one            
+2              two            
+3              three          
+4              four           
+6              six            
+step n2s2: UPDATE tst SET b = 'changed' WHERE a = 1;
+step n2sync: SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication;
+pg_xlog_wait_remote_apply
+
+               
+               
+step n1read: SELECT * FROM tst ORDER BY a;
+a              b              
+
+1              changed        
+2              two            
+3              three          
+4              four           
+6              six            
diff --git a/expected/isolation/basic_triple_node.out b/expected/isolation/basic_triple_node.out
new file mode 100644 (file)
index 0000000..09b2346
--- /dev/null
@@ -0,0 +1,116 @@
+Parsed test spec with 3 sessions
+
+starting permutation: n1s1 n1sync n2reada n2readb n2readc n2s1 n2sync n3reada n3s1 n3sync n1readb n1s2 n1sync n2readc n2s2 n2sync n3reada n3readb n3s2 n3sync n1readb
+step n1s1: 
+ INSERT INTO tsta (a, b) VALUES
+  (1, ARRAY['aaa', 'bba', 'cca']),
+  (2, ARRAY['aab', 'bbb', 'ccb']),
+  (3, ARRAY['aac', 'bbc', 'ccc']);
+ INSERT INTO tstb (a, b) VALUES
+  (1, '[2001-01-01 01:01:01, 2001-02-03 02:02:02]'),
+  (2, '[2002-02-02 02:02:02, 2002-03-04 02:02:02]'),
+  (3, '[2003-03-03 03:03:03, 2003-04-05 03:03:03]');
+ INSERT INTO tstc (a, b) VALUES
+  (1, '{"t1": "aaa", "t2": "bba", "t3": "cca"}'::jsonb),
+  (2, '{"t1": "aab", "t2": "bbb", "t3": "ccb"}'::jsonb),
+  (3, '{"t1": "aac", "t2": "bbc", "t3": "ccc"}'::jsonb);
+
+step n1sync: SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication;
+pg_xlog_wait_remote_apply
+
+               
+               
+step n2reada: SELECT a, b FROM tsta ORDER BY a;
+a              b              
+
+1              {aaa,bba,cca}  
+2              {aab,bbb,ccb}  
+3              {aac,bbc,ccc}  
+step n2readb: SELECT a, b FROM tstb ORDER BY a;
+a              b              
+
+1              ["Mon Jan 01 01:01:01 2001 PST","Sat Feb 03 02:02:02 2001 PST"]
+2              ["Sat Feb 02 02:02:02 2002 PST","Mon Mar 04 02:02:02 2002 PST"]
+3              ["Mon Mar 03 03:03:03 2003 PST","Sat Apr 05 03:03:03 2003 PST"]
+step n2readc: SELECT a, b FROM tstc ORDER BY a;
+a              b              
+
+1              {"t1": "aaa", "t2": "bba", "t3": "cca"}
+2              {"t1": "aab", "t2": "bbb", "t3": "ccb"}
+3              {"t1": "aac", "t2": "bbc", "t3": "ccc"}
+step n2s1: 
+ UPDATE tsta SET b = b || ('dd' || (ARRAY['a', 'b', 'c']::text[])[a]);
+
+step n2sync: SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication;
+pg_xlog_wait_remote_apply
+
+               
+               
+step n3reada: SELECT a, b FROM tsta ORDER BY a;
+a              b              
+
+1              {aaa,bba,cca,dda}
+2              {aab,bbb,ccb,ddb}
+3              {aac,bbc,ccc,ddc}
+step n3s1: 
+ UPDATE tstb SET b = '[2525-01-01 23:55:00, 2525-01-02 00:05:00]' WHERE a = 3;
+
+step n3sync: SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication;
+pg_xlog_wait_remote_apply
+
+               
+               
+step n1readb: SELECT a, b FROM tstb ORDER BY a;
+a              b              
+
+1              ["Mon Jan 01 01:01:01 2001 PST","Sat Feb 03 02:02:02 2001 PST"]
+2              ["Sat Feb 02 02:02:02 2002 PST","Mon Mar 04 02:02:02 2002 PST"]
+3              ["Mon Jan 01 23:55:00 2525 PST","Tue Jan 02 00:05:00 2525 PST"]
+step n1s2: 
+ UPDATE tstc set b = '{"t1": "aac", "t2": "bbc", "t3": "ccc"}'::jsonb;
+
+step n1sync: SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication;
+pg_xlog_wait_remote_apply
+
+               
+               
+step n2readc: SELECT a, b FROM tstc ORDER BY a;
+a              b              
+
+1              {"t1": "aac", "t2": "bbc", "t3": "ccc"}
+2              {"t1": "aac", "t2": "bbc", "t3": "ccc"}
+3              {"t1": "aac", "t2": "bbc", "t3": "ccc"}
+step n2s2: 
+ DELETE FROM tsta WHERE a = 3;
+ DELETE FROM tstb WHERE b = '[2525-01-01 23:55:00, 2525-01-02 00:05:00]';
+
+step n2sync: SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication;
+pg_xlog_wait_remote_apply
+
+               
+               
+step n3reada: SELECT a, b FROM tsta ORDER BY a;
+a              b              
+
+1              {aaa,bba,cca,dda}
+2              {aab,bbb,ccb,ddb}
+step n3readb: SELECT a, b FROM tstb ORDER BY a;
+a              b              
+
+1              ["Mon Jan 01 01:01:01 2001 PST","Sat Feb 03 02:02:02 2001 PST"]
+2              ["Sat Feb 02 02:02:02 2002 PST","Mon Mar 04 02:02:02 2002 PST"]
+step n3s2: 
+ INSERT INTO tstb (a, b) VALUES
+  (3, '[2003-03-03 03:03:03, 2003-04-05 03:03:03]');
+
+step n3sync: SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication;
+pg_xlog_wait_remote_apply
+
+               
+               
+step n1readb: SELECT a, b FROM tstb ORDER BY a;
+a              b              
+
+1              ["Mon Jan 01 01:01:01 2001 PST","Sat Feb 03 02:02:02 2001 PST"]
+2              ["Sat Feb 02 02:02:02 2002 PST","Mon Mar 04 02:02:02 2002 PST"]
+3              ["Mon Mar 03 03:03:03 2003 PST","Sat Apr 05 03:03:03 2003 PST"]
diff --git a/expected/isolation/update_pk_change_conflict.out b/expected/isolation/update_pk_change_conflict.out
new file mode 100644 (file)
index 0000000..553070b
--- /dev/null
@@ -0,0 +1,56 @@
+Parsed test spec with 3 sessions
+
+starting permutation: n1sync n1s1 n1sync n3read n2s1 n2sync n3read n1s2 n2s2 n1s3 n2s3 n1s4 n2s4 n1sync n2sync n1read n2read n3read
+step n1sync: select pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication;
+pg_xlog_wait_remote_apply
+
+               
+               
+step n1s1: UPDATE tst SET a = 2;
+step n1sync: select pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication;
+pg_xlog_wait_remote_apply
+
+               
+               
+step n3read: SELECT * FROM tst;
+a              b              
+
+2              one            
+step n2s1: UPDATE tst SET a = 3;
+step n2sync: select pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication;
+pg_xlog_wait_remote_apply
+
+               
+               
+step n3read: SELECT * FROM tst;
+a              b              
+
+3              one            
+step n1s2: BEGIN;
+step n2s2: BEGIN;
+step n1s3: UPDATE tst SET a = 4;
+step n2s3: UPDATE tst SET a = 5;
+step n1s4: COMMIT;
+step n2s4: COMMIT;
+step n1sync: select pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication;
+pg_xlog_wait_remote_apply
+
+               
+               
+step n2sync: select pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication;
+pg_xlog_wait_remote_apply
+
+               
+               
+step n1read: SELECT * FROM tst;
+a              b              
+
+5              one            
+step n2read: SELECT * FROM tst;
+a              b              
+
+5              one            
+step n3read: SELECT * FROM tst;
+a              b              
+
+5              one            
diff --git a/specs/isolation/alter_table.spec b/specs/isolation/alter_table.spec
new file mode 100644 (file)
index 0000000..16c86d8
--- /dev/null
@@ -0,0 +1,40 @@
+# various ALTER TABLE combinations
+conninfo "node1" "port=15432 dbname=test_db"
+conninfo "node2" "port=15433 dbname=test_db"
+
+setup
+{
+ CREATE TABLE tst (a INTEGER PRIMARY KEY, b TEXT);
+ INSERT INTO tst (a, b) VALUES (1, 'one'), (2, 'two'), (3, 'three');
+}
+
+teardown
+{
+ DROP TABLE tst;
+}
+
+session "s1"
+connection "node1"
+step "n1read" { SELECT * FROM tst ORDER BY a; }
+step "n1sync" { SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication; }
+step "n1s1" { INSERT INTO tst (a, b) VALUES (4, 'four'); }
+step "n1s2" { ALTER TABLE tst ADD COLUMN c TEXT; }
+step "n1s3" { INSERT INTO tst (a, b, c) VALUES (5, 'five', 'new'); }
+step "n1s4" { UPDATE tst set c = 'updated' WHERE c IS NULL; }
+step "n1s5" { ALTER TABLE tst ALTER COLUMN c SET DEFAULT 'dflt'; }
+step "n1s6" { INSERT INTO tst (a, b) VALUES (6, 'six'); }
+step "n1s7" { DELETE FROM tst where a = 5; }
+step "n1s8" { ALTER TABLE tst ADD COLUMN d INTEGER DEFAULT 100; }
+step "n1s9" { BEGIN; }
+step "n1s10" { ALTER TABLE tst DROP COLUMN c; }
+step "n1s11" { COMMIT; }
+
+session "s2"
+connection "node2"
+step "n2sync" { SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication; }
+step "n2read" { SELECT * FROM tst ORDER BY a; }
+step "n2s1" { UPDATE tst SET c = 'changed' WHERE a = 1; }
+step "n2s2" { UPDATE tst SET b = 'changed' WHERE a = 1; }
+
+permutation "n1s1" "n1sync" "n2read" "n1s2" "n1sync" "n2read" "n1s3" "n1s4" "n1sync" "n2read" "n1s5" "n1s6" "n1sync" "n2read" "n1s7" "n1sync" "n2read" "n1s8" "n1s9" "n1s10" "n2s1" "n2sync" "n1s11" "n1sync" "n2sync" "n2read" "n1read" "n2s2" "n2sync" "n1read"
+
diff --git a/specs/isolation/basic_triple_node.spec b/specs/isolation/basic_triple_node.spec
new file mode 100644 (file)
index 0000000..62ea167
--- /dev/null
@@ -0,0 +1,73 @@
+conninfo "node1" "port=15432 dbname=test_db"
+conninfo "node2" "port=15433 dbname=test_db"
+conninfo "node3" "port=15434 dbname=test_db"
+
+setup
+{
+ CREATE TABLE tsta (a INTEGER PRIMARY KEY, b TEXT[]);
+ CREATE TABLE tstb (a INTEGER PRIMARY KEY, b tstzrange);
+ CREATE TABLE tstc (a INTEGER PRIMARY KEY, b jsonb);
+}
+
+teardown
+{
+ DROP TABLE tsta;
+ DROP TABLE tstb;
+ DROP TABLE tstc;
+}
+
+session "s1"
+connection "node1"
+step "n1sync" { SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication; }
+step "n1reada" { SELECT a, b FROM tsta ORDER BY a; }
+step "n1readb" { SELECT a, b FROM tstb ORDER BY a; }
+step "n1readc" { SELECT a, b FROM tstc ORDER BY a; }
+step "n1s1"
+{
+ INSERT INTO tsta (a, b) VALUES
+  (1, ARRAY['aaa', 'bba', 'cca']),
+  (2, ARRAY['aab', 'bbb', 'ccb']),
+  (3, ARRAY['aac', 'bbc', 'ccc']);
+ INSERT INTO tstb (a, b) VALUES
+  (1, '[2001-01-01 01:01:01, 2001-02-03 02:02:02]'),
+  (2, '[2002-02-02 02:02:02, 2002-03-04 02:02:02]'),
+  (3, '[2003-03-03 03:03:03, 2003-04-05 03:03:03]');
+ INSERT INTO tstc (a, b) VALUES
+  (1, '{"t1": "aaa", "t2": "bba", "t3": "cca"}'::jsonb),
+  (2, '{"t1": "aab", "t2": "bbb", "t3": "ccb"}'::jsonb),
+  (3, '{"t1": "aac", "t2": "bbc", "t3": "ccc"}'::jsonb);
+}
+step "n1s2"
+{
+ UPDATE tstc set b = '{"t1": "aac", "t2": "bbc", "t3": "ccc"}'::jsonb;
+}
+
+session "s2"
+connection "node2"
+step "n2sync" { SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication; }
+step "n2reada" { SELECT a, b FROM tsta ORDER BY a; }
+step "n2readb" { SELECT a, b FROM tstb ORDER BY a; }
+step "n2readc" { SELECT a, b FROM tstc ORDER BY a; }
+step "n2s1" {
+ UPDATE tsta SET b = b || ('dd' || (ARRAY['a', 'b', 'c']::text[])[a]);
+}
+step "n2s2" {
+ DELETE FROM tsta WHERE a = 3;
+ DELETE FROM tstb WHERE b = '[2525-01-01 23:55:00, 2525-01-02 00:05:00]';
+}
+
+session "s3"
+connection "node3"
+step "n3sync" { SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication; }
+step "n3reada" { SELECT a, b FROM tsta ORDER BY a; }
+step "n3readb" { SELECT a, b FROM tstb ORDER BY a; }
+step "n3readc" { SELECT a, b FROM tstc ORDER BY a; }
+step "n3s1" {
+ UPDATE tstb SET b = '[2525-01-01 23:55:00, 2525-01-02 00:05:00]' WHERE a = 3;
+}
+step "n3s2" {
+ INSERT INTO tstb (a, b) VALUES
+  (3, '[2003-03-03 03:03:03, 2003-04-05 03:03:03]');
+}
+
+permutation "n1s1" "n1sync" "n2reada" "n2readb" "n2readc" "n2s1" "n2sync" "n3reada" "n3s1" "n3sync" "n1readb" "n1s2" "n1sync" "n2readc" "n2s2" "n2sync" "n3reada" "n3readb" "n3s2" "n3sync" "n1readb"
diff --git a/specs/isolation/update_pk_change_conflict.spec b/specs/isolation/update_pk_change_conflict.spec
new file mode 100644 (file)
index 0000000..755e3a7
--- /dev/null
@@ -0,0 +1,40 @@
+# test conflict handling on primary key changes
+conninfo "node1" "port=15432 dbname=test_db"
+conninfo "node2" "port=15433 dbname=test_db"
+conninfo "node3" "port=15434 dbname=test_db"
+
+setup
+{
+ CREATE TABLE tst (a INTEGER PRIMARY KEY, b TEXT);
+ INSERT INTO tst (a, b) VALUES (1, 'one');
+}
+
+teardown
+{
+ DROP TABLE tst;
+}
+
+session "s1"
+connection "node1"
+step "n1read" { SELECT * FROM tst; }
+step "n1sync" { select pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication; }
+step "n1s1" { UPDATE tst SET a = 2; }
+step "n1s2" { BEGIN; }
+step "n1s3" { UPDATE tst SET a = 4; }
+step "n1s4" { COMMIT; }
+
+session "s2"
+connection "node2"
+step "n2read" { SELECT * FROM tst; }
+step "n2sync" { select pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication; }
+step "n2s1" { UPDATE tst SET a = 3; }
+step "n2s2" { BEGIN; }
+step "n2s3" { UPDATE tst SET a = 5; }
+step "n2s4" { COMMIT; }
+
+session "s3"
+connection "node3"
+step "n3read" { SELECT * FROM tst; }
+step "n3sync" { select pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication; }
+
+permutation "n1sync" "n1s1" "n1sync" "n3read" "n2s1" "n2sync" "n3read" "n1s2" "n2s2" "n1s3" "n2s3" "n1s4" "n2s4" "n1sync" "n2sync" "n1read" "n2read" "n3read"