Tue Aug 1 14:28:19 PDT 2006
- Previous message: [Slony1-commit] By cbbrowne: New Directory
- Next message: [Slony1-commit] By xfade: Silence GCC warnings about missing braces around initializers.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Log Message: ----------- Add a regression test that sets up a "master" table and three other tables that inherit from it, and replicates all four tables. Added Files: ----------- slony1-engine/tests/testinherit: 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) schema.diff (r1.1) settings.ik (r1.1) -------------- next part -------------- --- /dev/null +++ tests/testinherit/init_add_tables.ik @@ -0,0 +1,4 @@ +set add table (id=1, set id=1, origin=1, fully qualified name = 'public.sub1', comment='sub table 1'); +set add table (id=2, set id=1, origin=1, fully qualified name = 'public.sub2', comment='sub table 2'); +set add table (id=3, set id=1, origin=1, fully qualified name = 'public.sub3', comment='sub table 3'); +set add table (id=4, set id=1, origin=1, fully qualified name = 'public.master', comment='master table'); --- /dev/null +++ tests/testinherit/init_cluster.ik @@ -0,0 +1 @@ +init cluster (id=1, comment = 'Regress test node'); --- /dev/null +++ tests/testinherit/init_data.sql @@ -0,0 +1,4 @@ +insert into master (data) values ('master 000'); +insert into sub1 (data) values ('sub1 a'); +insert into sub2 (data) values ('sub1 b'); +insert into sub3 (data) values ('sub1 c'); --- /dev/null +++ tests/testinherit/init_schema.sql @@ -0,0 +1,19 @@ +create table master ( + id serial primary key, + trans_on timestamptz default 'now()', + data text +); + +create table sub1 ( +) inherits (master); +alter table sub1 add primary key(id); + +create table sub2 ( +) inherits (master); +alter table sub2 add primary key(id); + +create table sub3 ( +) inherits (master); +alter table sub3 add primary key(id); + + --- /dev/null +++ tests/testinherit/settings.ik @@ -0,0 +1,4 @@ +NUMCLUSTERS=${NUMCLUSTERS:-"1"} +NUMNODES=${NUMNODES:-"2"} +ORIGINNODE=1 +WORKERS=${WORKERS:-"1"} --- /dev/null +++ tests/testinherit/init_subscribe_set.ik @@ -0,0 +1 @@ +subscribe set (id = 1, provider = 1, receiver = 2, forward = no); --- /dev/null +++ tests/testinherit/init_create_set.ik @@ -0,0 +1,2 @@ +create set (id=1, origin=1, comment='All test1 tables'); + --- /dev/null +++ tests/testinherit/generate_dml.sh @@ -0,0 +1,82 @@ +. 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 + 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"` + txtclen=$(random_number 1 100) + txtc=$(random_string ${txtclen}) + txtc=`echo ${txtc} | sed -e "s/\\\\\\\/\\\\\\\\\\\\\\/g" -e "s/'/''/g"` + txtdlen=$(random_number 1 100) + txtd=$(random_string ${txtdlen}) + txtd=`echo ${txtd} | sed -e "s/\\\\\\\/\\\\\\\\\\\\\\/g" -e "s/'/''/g"` + echo "INSERT INTO sub1(data) VALUES ('sub1 ${txta}');" >> $GENDATA + echo "INSERT INTO sub2(data) VALUES ('sub2 ${txtb}');" >> $GENDATA + echo "INSERT INTO sub3(data) VALUES ('sub3 ${txtc}');" >> $GENDATA + echo "INSERT INTO master(data) VALUES ('master ${txtd}');" >> $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() +{ + 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 "done" +} --- /dev/null +++ tests/testinherit/schema.diff @@ -0,0 +1,2 @@ +select id, trans_on, data from master order by id + --- /dev/null +++ tests/testinherit/README @@ -0,0 +1,6 @@ +$Id: README,v 1.1 2006/08/01 21:28:18 cbbrowne Exp $ + +testinherit does some simple handling of inheritance... + +A "master" table is created; three "sub tables" inherit from it, and +all four tables are replicated.
- Previous message: [Slony1-commit] By cbbrowne: New Directory
- Next message: [Slony1-commit] By xfade: Silence GCC warnings about missing braces around initializers.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Slony1-commit mailing list