Add in a test that has two disjoint sets to make sure that events
authorChristopher Browne <cbbrowne@ca.afilias.info>
Fri, 21 Sep 2007 21:34:56 +0000 (21:34 +0000)
committerChristopher Browne <cbbrowne@ca.afilias.info>
Fri, 21 Sep 2007 21:34:56 +0000 (21:34 +0000)
are propagating across the cluster

tests/testlistenpaths/README [new file with mode: 0644]
tests/testlistenpaths/gen_weak_user.sh [new file with mode: 0644]
tests/testlistenpaths/generate_dml.sh [new file with mode: 0755]
tests/testlistenpaths/init_add_tables.ik [new file with mode: 0755]
tests/testlistenpaths/init_cluster.ik [new file with mode: 0755]
tests/testlistenpaths/init_create_set.ik [new file with mode: 0755]
tests/testlistenpaths/init_data.sql [new file with mode: 0755]
tests/testlistenpaths/init_schema.sql [new file with mode: 0644]
tests/testlistenpaths/init_subscribe_set.ik [new file with mode: 0644]
tests/testlistenpaths/schema.diff [new file with mode: 0755]
tests/testlistenpaths/settings.ik [new file with mode: 0755]

diff --git a/tests/testlistenpaths/README b/tests/testlistenpaths/README
new file mode 100644 (file)
index 0000000..84ee2dc
--- /dev/null
@@ -0,0 +1,10 @@
+$Id: README,v 1.1 2007-09-21 21:34:56 cbbrowne Exp $
+  
+testlistenpaths verifies that some wacky listen-generation cases work
+properly.
+  
+It creates three simple tables as one replication set, and replicates
+them across nodes 1 and 3.
+
+It sets up the same tables as a second replication set, and replicates
+those across 2, 4, and 5.
diff --git a/tests/testlistenpaths/gen_weak_user.sh b/tests/testlistenpaths/gen_weak_user.sh
new file mode 100644 (file)
index 0000000..9c4e76c
--- /dev/null
@@ -0,0 +1,6 @@
+weakuser=$1;
+
+for i in 1 2 3 4 5; do
+   echo "grant select on table public.table${i} to ${weakuser};"
+   echo "grant select on table public.table${i}_id_seq to ${weakuser};"
+done
\ No newline at end of file
diff --git a/tests/testlistenpaths/generate_dml.sh b/tests/testlistenpaths/generate_dml.sh
new file mode 100755 (executable)
index 0000000..12ac3a2
--- /dev/null
@@ -0,0 +1,86 @@
+. support_funcs.sh
+
+init_dml()
+{
+  echo "init_dml()"
+}
+
+begin()
+{
+  echo "begin()"
+}
+
+rollback()
+{
+  echo "rollback()"
+}
+
+commit()
+{
+  echo "commit()"
+}
+
+generate_initdata()
+{
+  numrows=$(random_number 150 200)
+  i=0;
+  trippoint=`expr $numrows / 20`
+  j=0;
+  percent=0
+  status "generating ${numrows} transactions of random data"
+  percent=`expr $j \* 5`
+  status "$percent %"
+  GENDATA="$mktmp/generate.data"
+  echo "" > ${GENDATA}
+  while : ; do
+    txtalen=$(random_number 1 100)
+    txta=$(random_string ${txtalen})
+    txta=`echo ${txta} | sed -e "s/\\\\\\\/\\\\\\\\\\\\\\/g" -e "s/'/''/g"`
+    txtblen=$(random_number 1 100)
+    txtb=$(random_string ${txtblen})
+    txtb=`echo ${txtb} | sed -e "s/\\\\\\\/\\\\\\\\\\\\\\/g" -e "s/'/''/g"`
+    ra=$(random_number 1 9)
+    rb=$(random_number 1 9)
+    rc=$(random_number 1 9)
+    echo "INSERT INTO table1(id,data) VALUES (${i},'${txta}');" >> $GENDATA
+    echo "INSERT INTO table2(table1_id,data) SELECT id, '${txtb}' FROM table1 WHERE data='${txta}';" >> $GENDATA
+    echo "INSERT INTO table3(table2_id) SELECT id FROM table2 WHERE data ='${txtb}';" >> $GENDATA
+    echo "INSERT INTO table4(id,numcol,realcol,ptcol,pathcol,polycol,circcol,ipcol,maccol,bitcol) values (${i},'${ra}${rb}.${rc}','${ra}.${rb}${rc}','(${ra},${rb})','((${ra},${ra}),(${rb},${rb}),(${rc},${rc}),(${ra},${rc}))','((${ra},${rb}),(${rc},${ra}),(${rb},${rc}),(${rc},${rb}))','<(${ra},${rb}),${rc}>','192.168.${ra}.${rb}${rc}','08:00:2d:0${ra}:0${rb}:0${rc}',X'${ra}${rb}${rc}');" >> $GENDATA
+    if [ ${i} -ge ${numrows} ]; then
+      break;
+    else
+      i=$((${i} +1))
+      working=`expr $i % $trippoint`
+      if [ $working -eq 0 ]; then
+        j=`expr $j + 1`
+        percent=`expr $j \* 5`
+        status "$percent %"
+      fi 
+    fi
+  done
+  status "done"
+}
+
+do_initdata()
+{
+  generate_initdata
+  launch_poll
+  for org in 1 2; do
+      eval db=\$DB${org}
+      eval host=\$HOST${org}
+      eval user=\$USER${org}
+      eval port=\$PORT${org}
+
+      status "empty out schemas..."
+      for tbl in table1 table2 table3 table4; do
+         status "delete from table ${tbl}"
+         $pgbindir/psql -h $host -p $port -d $db -U $user -c "delete from ${tbl};"
+      done
+      status "loading data into node ${org}"
+      $pgbindir/psql -h $host -p $port -d $db -U $user < $mktmp/generate.data 1> $mktmp/initdata.log 2> $mktmp/initdata.log
+      if [ $? -ne 0 ]; then
+         warn 3 "do_initdata failed, see $mktmp/initdata.log for details"
+      fi 
+      status "data load complete for node ${org}"
+  done
+}
diff --git a/tests/testlistenpaths/init_add_tables.ik b/tests/testlistenpaths/init_add_tables.ik
new file mode 100755 (executable)
index 0000000..edb7fa0
--- /dev/null
@@ -0,0 +1,13 @@
+set add table (id=1, set id=1, origin=1, fully qualified name = 'public.table1', comment='accounts table');
+set add table (id=2, set id=1, origin=1, fully qualified name = 'public.table2', key='table2_id_key');
+
+try {
+   set add table (id=3, set id=1, origin=1, fully qualified name = 'public.table3', key = 'no_good_candidate_pk', comment='bad table - table 3');
+} on error {
+   echo 'Tried to replicate table3 with no good candidate PK - rejected';
+} on success {
+   echo 'Tried to replicate table3 with no good candidate PK - accepted';
+   exit 1;
+}
+
+set add table (id=4, set id=1, origin=1, fully qualified name = 'public.table4', comment='a table of many types');
\ No newline at end of file
diff --git a/tests/testlistenpaths/init_cluster.ik b/tests/testlistenpaths/init_cluster.ik
new file mode 100755 (executable)
index 0000000..55667c7
--- /dev/null
@@ -0,0 +1 @@
+init cluster (id=1, comment = 'Regress test node');
diff --git a/tests/testlistenpaths/init_create_set.ik b/tests/testlistenpaths/init_create_set.ik
new file mode 100755 (executable)
index 0000000..c328e9e
--- /dev/null
@@ -0,0 +1,2 @@
+create set (id=1, origin=1, comment='set subscribed by nodes 1, 3');
+
diff --git a/tests/testlistenpaths/init_data.sql b/tests/testlistenpaths/init_data.sql
new file mode 100755 (executable)
index 0000000..e69de29
diff --git a/tests/testlistenpaths/init_schema.sql b/tests/testlistenpaths/init_schema.sql
new file mode 100644 (file)
index 0000000..4737f0b
--- /dev/null
@@ -0,0 +1,31 @@
+CREATE TABLE table1(
+  id           SERIAL          PRIMARY KEY, 
+  data         TEXT
+);
+
+CREATE TABLE table2(
+  id           SERIAL          UNIQUE NOT NULL, 
+  table1_id    INT4            REFERENCES table1(id) 
+                                       ON UPDATE CASCADE ON DELETE CASCADE, 
+  data         TEXT
+);
+
+create table table3 (
+  id serial NOT NULL,
+  id2 integer
+);
+
+create unique index no_good_candidate_pk on table3 (id, id2);
+
+create table table4 (
+  id serial primary key,
+  numcol numeric(12,4), -- 1.23
+  realcol real,     -- (1.23)
+  ptcol point,      -- (1,2)
+  pathcol path,     -- ((1,1),(2,2),(3,3),(4,4))
+  polycol polygon,  -- ((1,1),(2,2),(3,3),(4,4))
+  circcol circle,   -- <(1,2>,3>
+  ipcol inet,       -- "192.168.1.1"
+  maccol macaddr,   -- "04:05:06:07:08:09"
+  bitcol bit varying(20)  -- X'123' 
+);
diff --git a/tests/testlistenpaths/init_subscribe_set.ik b/tests/testlistenpaths/init_subscribe_set.ik
new file mode 100644 (file)
index 0000000..10c5f8e
--- /dev/null
@@ -0,0 +1,9 @@
+subscribe set (id = 1, provider = 1, receiver = 3, forward = no);
+create set (id=2, origin=2, comment='set subscribed by nodes 2,4,5');
+
+
+set add table (id=1, set id=2, origin=2, fully qualified name = 'public.table1', comment='accounts table');
+set add table (id=2, set id=2, origin=2, fully qualified name = 'public.table2', key='table2_id_key');
+set add table (id=4, set id=2, origin=2, fully qualified name = 'public.table4', comment='a table of many types');
+subscribe set (id = 2, provider = 2, receiver = 4, forward = no);
+subscribe set (id = 2, provider = 2, receiver = 5, forward = no);
diff --git a/tests/testlistenpaths/schema.diff b/tests/testlistenpaths/schema.diff
new file mode 100755 (executable)
index 0000000..5ce36d3
--- /dev/null
@@ -0,0 +1,3 @@
+SELECT id,data FROM table1 ORDER BY id
+SELECT id,table1_id,data FROM table2 ORDER BY id
+SELECT id,numcol,realcol,ptcol,pathcol,polycol,circcol,ipcol,maccol, bitcol from table4 order by id;
diff --git a/tests/testlistenpaths/settings.ik b/tests/testlistenpaths/settings.ik
new file mode 100755 (executable)
index 0000000..edebf46
--- /dev/null
@@ -0,0 +1,4 @@
+NUMCLUSTERS=${NUMCLUSTERS:-"1"}
+NUMNODES=${NUMNODES:-"5"}
+ORIGINNODE=1
+WORKERS=${WORKERS:-"1"}