CVS User Account cvsuser
Fri Aug 18 11:46:26 PDT 2006
Log Message:
-----------
Add in new test: testmultiplemoves

This creates 3 nodes, and a bunch of sets, subscribes them from node 1 to
2+3, then moves all the sets to originate at node 3

Added Files:
-----------
    slony1-engine/tests/testmultiplemoves:
        README (r1.1)
        generate_dml.sh (r1.1)
        init_add_tables.ik (r1.1)
        init_cluster.ik (r1.1)
        init_create_set.ik (r1.1)
        init_data.sql (r1.1)
        init_schema.sql (r1.1)
        init_subscribe_set.ik (r1.1)
        move_sets.ik (r1.1)
        schema.diff (r1.1)
        settings.ik (r1.1)

-------------- next part --------------
--- /dev/null
+++ tests/testmultiplemoves/init_add_tables.ik
@@ -0,0 +1,20 @@
+set add table (id=1, set id=1, origin=1, fully qualified name = 'public.table1', comment='a table');
+set add table (id=2, set id=1, origin=1, fully qualified name = 'public.table1a', comment='a table');
+set add table (id=3, set id=2, origin=1, fully qualified name = 'public.table2', comment='a table');
+set add table (id=4, set id=2, origin=1, fully qualified name = 'public.table2a', comment='a table');
+set add table (id=5, set id=3, origin=1, fully qualified name = 'public.table3', comment='a table');
+set add table (id=6, set id=3, origin=1, fully qualified name = 'public.table3a', comment='a table');
+set add table (id=7, set id=4, origin=1, fully qualified name = 'public.table4', comment='a table');
+set add table (id=8, set id=4, origin=1, fully qualified name = 'public.table4a', comment='a table');
+set add table (id=9, set id=5, origin=1, fully qualified name = 'public.table5', comment='a table');
+set add table (id=10, set id=5, origin=1, fully qualified name = 'public.table5a', comment='a table');
+set add table (id=11, set id=6, origin=1, fully qualified name = 'public.table6', comment='a table');
+set add table (id=12, set id=6, origin=1, fully qualified name = 'public.table6a', comment='a table');
+set add table (id=13, set id=7, origin=1, fully qualified name = 'public.table7', comment='a table');
+set add table (id=14, set id=7, origin=1, fully qualified name = 'public.table7a', comment='a table');
+set add table (id=15, set id=8, origin=1, fully qualified name = 'public.table8', comment='a table');
+set add table (id=16, set id=8, origin=1, fully qualified name = 'public.table8a', comment='a table');
+set add table (id=17, set id=9, origin=1, fully qualified name = 'public.table9', comment='a table');
+set add table (id=18, set id=9, origin=1, fully qualified name = 'public.table9a', comment='a table');
+set add table (id=19, set id=10, origin=1, fully qualified name = 'public.tablea', comment='a table');
+set add table (id=20, set id=10, origin=1, fully qualified name = 'public.tableaa', comment='a table');
\ No newline at end of file
--- /dev/null
+++ tests/testmultiplemoves/init_cluster.ik
@@ -0,0 +1 @@
+init cluster (id=1, comment = 'Regress test node');
--- /dev/null
+++ tests/testmultiplemoves/init_data.sql
@@ -0,0 +1,49 @@
+INSERT INTO table1(data) VALUES ('placeholder a');
+INSERT INTO table1(data) VALUES ('placeholder b');
+INSERT INTO table1a(table1_id,data) VALUES (1,'placeholder a');
+INSERT INTO table1a(table1_id,data) VALUES (2,'placeholder b');
+
+INSERT INTO table2(data) VALUES ('placeholder a');
+INSERT INTO table2(data) VALUES ('placeholder b');
+INSERT INTO table2a(table2_id,data) VALUES (1,'placeholder a');
+INSERT INTO table2a(table2_id,data) VALUES (2,'placeholder b');
+
+INSERT INTO table3(data) VALUES ('placeholder a');
+INSERT INTO table3(data) VALUES ('placeholder b');
+INSERT INTO table3a(table3_id,data) VALUES (1,'placeholder a');
+INSERT INTO table3a(table3_id,data) VALUES (2,'placeholder b');
+
+INSERT INTO table4(data) VALUES ('placeholder a');
+INSERT INTO table4(data) VALUES ('placeholder b');
+INSERT INTO table4a(table4_id,data) VALUES (1,'placeholder a');
+INSERT INTO table4a(table4_id,data) VALUES (2,'placeholder b');
+
+INSERT INTO table5(data) VALUES ('placeholder a');
+INSERT INTO table5(data) VALUES ('placeholder b');
+INSERT INTO table5a(table5_id,data) VALUES (1,'placeholder a');
+INSERT INTO table5a(table5_id,data) VALUES (2,'placeholder b');
+
+INSERT INTO table6(data) VALUES ('placeholder a');
+INSERT INTO table6(data) VALUES ('placeholder b');
+INSERT INTO table6a(table6_id,data) VALUES (1,'placeholder a');
+INSERT INTO table6a(table6_id,data) VALUES (2,'placeholder b');
+
+INSERT INTO table7(data) VALUES ('placeholder a');
+INSERT INTO table7(data) VALUES ('placeholder b');
+INSERT INTO table7a(table7_id,data) VALUES (1,'placeholder a');
+INSERT INTO table7a(table7_id,data) VALUES (2,'placeholder b');
+
+INSERT INTO table8(data) VALUES ('placeholder a');
+INSERT INTO table8(data) VALUES ('placeholder b');
+INSERT INTO table8a(table8_id,data) VALUES (1,'placeholder a');
+INSERT INTO table8a(table8_id,data) VALUES (2,'placeholder b');
+
+INSERT INTO table9(data) VALUES ('placeholder a');
+INSERT INTO table9(data) VALUES ('placeholder b');
+INSERT INTO table9a(table9_id,data) VALUES (1,'placeholder a');
+INSERT INTO table9a(table9_id,data) VALUES (2,'placeholder b');
+
+INSERT INTO tablea(data) VALUES ('placeholder a');
+INSERT INTO tablea(data) VALUES ('placeholder b');
+INSERT INTO tableaa(tablea_id,data) VALUES (1,'placeholder a');
+INSERT INTO tableaa(tablea_id,data) VALUES (2,'placeholder b');
--- /dev/null
+++ tests/testmultiplemoves/init_schema.sql
@@ -0,0 +1,23 @@
+-- $Id: init_schema.sql,v 1.1 2006/08/18 18:46:25 cbbrowne Exp $
+
+create table table1 (id serial primary key, data text);
+create table table2 (id serial primary key, data text);
+create table table3 (id serial primary key, data text);
+create table table4 (id serial primary key, data text);
+create table table5 (id serial primary key, data text);
+create table table6 (id serial primary key, data text);
+create table table7 (id serial primary key, data text);
+create table table8 (id serial primary key, data text);
+create table table9 (id serial primary key, data text);
+create table tableA (id serial primary key, data text);
+
+create table table1a (id serial primary key, table1_id int4 references table1a(id) on update cascade on delete cascade, data text);
+create table table2a (id serial primary key, table2_id int4 references table2a(id) on update cascade on delete cascade, data text);
+create table table3a (id serial primary key, table3_id int4 references table3a(id) on update cascade on delete cascade, data text);
+create table table4a (id serial primary key, table4_id int4 references table4a(id) on update cascade on delete cascade, data text);
+create table table5a (id serial primary key, table5_id int4 references table5a(id) on update cascade on delete cascade, data text);
+create table table6a (id serial primary key, table6_id int4 references table6a(id) on update cascade on delete cascade, data text);
+create table table7a (id serial primary key, table7_id int4 references table7a(id) on update cascade on delete cascade, data text);
+create table table8a (id serial primary key, table8_id int4 references table8a(id) on update cascade on delete cascade, data text);
+create table table9a (id serial primary key, table9_id int4 references table9a(id) on update cascade on delete cascade, data text);
+create table tableAa (id serial primary key, tableA_id int4 references tableAa(id) on update cascade on delete cascade, data text);
--- /dev/null
+++ tests/testmultiplemoves/settings.ik
@@ -0,0 +1,4 @@
+NUMCLUSTERS=${NUMCLUSTERS:-"1"}
+NUMNODES=${NUMNODES:-"3"}
+ORIGINNODE=1
+WORKERS=${WORKERS:-"1"}
--- /dev/null
+++ tests/testmultiplemoves/init_subscribe_set.ik
@@ -0,0 +1,42 @@
+subscribe set (id=1, provider=1, receiver = 2, forward=yes);
+wait for event (origin=all, confirmed=all, wait on=1);
+subscribe set (id=2, provider=1, receiver = 2, forward=yes);
+wait for event (origin=all, confirmed=all, wait on=1);
+subscribe set (id=3, provider=1, receiver = 2, forward=yes);
+wait for event (origin=all, confirmed=all, wait on=1);
+subscribe set (id=4, provider=1, receiver = 2, forward=yes);
+wait for event (origin=all, confirmed=all, wait on=1);
+subscribe set (id=5, provider=1, receiver = 2, forward=yes);
+wait for event (origin=all, confirmed=all, wait on=1);
+subscribe set (id=6, provider=1, receiver = 2, forward=yes);
+wait for event (origin=all, confirmed=all, wait on=1);
+subscribe set (id=7, provider=1, receiver = 2, forward=yes);
+wait for event (origin=all, confirmed=all, wait on=1);
+subscribe set (id=8, provider=1, receiver = 2, forward=yes);
+wait for event (origin=all, confirmed=all, wait on=1);
+subscribe set (id=9, provider=1, receiver = 2, forward=yes);
+wait for event (origin=all, confirmed=all, wait on=1);
+subscribe set (id=10, provider=1, receiver = 2, forward=yes);
+wait for event (origin=all, confirmed=all, wait on=1);
+
+
+subscribe set (id=1, provider=2, receiver = 3, forward=yes);
+wait for event (origin=all, confirmed=all, wait on=1);
+subscribe set (id=2, provider=2, receiver = 3, forward=yes);
+wait for event (origin=all, confirmed=all, wait on=1);
+subscribe set (id=3, provider=2, receiver = 3, forward=yes);
+wait for event (origin=all, confirmed=all, wait on=1);
+subscribe set (id=4, provider=2, receiver = 3, forward=yes);
+wait for event (origin=all, confirmed=all, wait on=1);
+subscribe set (id=5, provider=2, receiver = 3, forward=yes);
+wait for event (origin=all, confirmed=all, wait on=1);
+subscribe set (id=6, provider=2, receiver = 3, forward=yes);
+wait for event (origin=all, confirmed=all, wait on=1);
+subscribe set (id=7, provider=2, receiver = 3, forward=yes);
+wait for event (origin=all, confirmed=all, wait on=1);
+subscribe set (id=8, provider=2, receiver = 3, forward=yes);
+wait for event (origin=all, confirmed=all, wait on=1);
+subscribe set (id=9, provider=2, receiver = 3, forward=yes);
+wait for event (origin=all, confirmed=all, wait on=1);
+subscribe set (id=10, provider=2, receiver = 3, forward=yes);
+wait for event (origin=all, confirmed=all, wait on=1);
--- /dev/null
+++ tests/testmultiplemoves/init_create_set.ik
@@ -0,0 +1,10 @@
+create set (id=1, origin=1, comment='all tables in set 1');
+create set (id=2, origin=1, comment='all tables in set 2');
+create set (id=3, origin=1, comment='all tables in set 3');
+create set (id=4, origin=1, comment='all tables in set 4');
+create set (id=5, origin=1, comment='all tables in set 5');
+create set (id=6, origin=1, comment='all tables in set 6');
+create set (id=7, origin=1, comment='all tables in set 7');
+create set (id=8, origin=1, comment='all tables in set 8');
+create set (id=9, origin=1, comment='all tables in set 9');
+create set (id=10, origin=1, comment='all tables in set 10');
\ No newline at end of file
--- /dev/null
+++ tests/testmultiplemoves/generate_dml.sh
@@ -0,0 +1,94 @@
+. support_funcs.sh
+
+init_dml()
+{
+  echo "init_dml()"
+}
+
+begin()
+{
+  echo "begin()"
+}
+
+rollback()
+{
+  echo "rollback()"
+}
+
+commit()
+{
+  echo "commit()"
+}
+
+generate_initdata()
+{
+  numrows=$(random_number 50 1000)
+  i=0;
+  trippoint=`expr $numrows / 20`
+  j=0;
+  percent=0
+  status "generating ${numrows} tranactions of random data"
+  percent=`expr $j \* 5`
+  status "$percent %"
+  GENDATA="$mktmp/generate.data"
+  while : ; do
+    for set in 1 2 3 4 5 6 7 8 9 A; 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"`
+	echo "INSERT INTO table${set}(data) VALUES ('${txta}');" >> $GENDATA
+	echo "INSERT INTO table${set}a(table${set}_id,data) SELECT id, '${txtb}' FROM table${set} WHERE data='${txta}';" >> $GENDATA
+    done
+    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()
+{
+  originnode=${ORIGINNODE:-"1"}
+  eval db=\$DB${originnode}
+  eval host=\$HOST${originnode}
+  eval user=\$USER${originnode}
+  eval port=\$PORT${originnode}
+  generate_initdata
+  launch_poll
+  status "loading data"
+  $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 "Move sets to node 3"
+  init_preamble
+  cat ${testname}/move_sets.ik >> $mktmp/slonik.script
+  do_ik
+  status "Completed moving sets"
+
+  ORIGINNODE=3
+  originnode=${ORIGINNODE:-"1"}
+  eval db=\$DB${originnode}
+  eval host=\$HOST${originnode}
+  eval user=\$USER${originnode}
+  eval port=\$PORT${originnode}
+
+  status "Generate some more data, switching origin to node 3"
+  generate_initdata
+  status "loading extra data"
+
+  $pgbindir/psql -h $host -U $user -d $db < $mktmp/generate.data 1> $LOG 2> $LOG
+  status "done"
+}
--- /dev/null
+++ tests/testmultiplemoves/schema.diff
@@ -0,0 +1,20 @@
+select 'table1', id, data from table1 order by id
+select 'table1a', id, table1_id, data from table1a order by id
+select 'table2', id, data from table2 order by id
+select 'table2a', id, table2_id, data from table2a order by id
+select 'table3', id, data from table3 order by id
+select 'table3a', id, table3_id, data from table3a order by id
+select 'table4', id, data from table4 order by id
+select 'table4a', id, table4_id, data from table4a order by id
+select 'table5', id, data from table5 order by id
+select 'table5a', id, table5_id, data from table5a order by id
+select 'table6', id, data from table6 order by id
+select 'table6a', id, table6_id, data from table6a order by id
+select 'table7', id, data from table7 order by id
+select 'table7a', id, table7_id, data from table7a order by id
+select 'table8', id, data from table8 order by id
+select 'table8a', id, table8_id, data from table8a order by id
+select 'table9', id, data from table9 order by id
+select 'table9a', id, table9_id, data from table9a order by id
+select 'tableA', id, data from tableA order by id
+select 'tableAa', id, tableA_id, data from tableAa order by id
\ No newline at end of file
--- /dev/null
+++ tests/testmultiplemoves/move_sets.ik
@@ -0,0 +1,20 @@
+lock set (id=1, origin=1);
+move set (id=1, old origin=1, new origin=3);
+lock set (id=2, origin=1);
+move set (id=2, old origin=1, new origin=3);
+lock set (id=3, origin=1);
+move set (id=3, old origin=1, new origin=3);
+lock set (id=4, origin=1);
+move set (id=4, old origin=1, new origin=3);
+lock set (id=5, origin=1);
+move set (id=5, old origin=1, new origin=3);
+lock set (id=6, origin=1);
+move set (id=6, old origin=1, new origin=3);
+lock set (id=7, origin=1);
+move set (id=7, old origin=1, new origin=3);
+lock set (id=8, origin=1);
+move set (id=8, old origin=1, new origin=3);
+lock set (id=9, origin=1);
+move set (id=9, old origin=1, new origin=3);
+lock set (id=10, origin=1);
+move set (id=10, old origin=1, new origin=3);
\ No newline at end of file
--- /dev/null
+++ tests/testmultiplemoves/README
@@ -0,0 +1,6 @@
+$Id: README,v 1.1 2006/08/18 18:46:25 cbbrowne Exp $
+
+testmultiplemoves is a test that exercises MOVE SET on a 3 node
+cluster with 10 replication sets.
+  
+The interesting bit is that it requests MOVE SET on all 10 sets...



More information about the Slony1-commit mailing list