adding DSN to csql.conf based on the cache test mode
[csql.git] / test / cache / Bidirectional / test014.ksh
blobd884a3d570a0aacd5f50309f9da3fb9d8fa07f19
1 #!/bin/sh
2 # Test Case
3 # Create 100 table in target database with a integer primary key.
4 # Run trigger for all table. Make sure Log table is in target database
5 # Run cache server with bi-directional and cache flag true. Cache all tables.
6 # Update some record in each table in target database. Check in csql node records are inserted or not .
7 # Author := Bijaya
9 input=${PWD}/cache/Bidirectional/mysqlcreatelogtable.sql
11 REL_PATH=.
12 if [ -s "$input" ]
13 then
14 REL_PATH=${PWD}/cache/Bidirectional
17 for((a=1; a<=100; a++))
19 echo "create table t$a(f1 int,f2 int,primary key(f1));"
20 echo "insert into t$a values(1,2);"
21 echo "insert into t$a values(10,20);"
22 echo "insert into t$a values(11,21);"
23 done >>$REL_PATH/create100table.sql
24 echo "table creation file created"
26 for((a=1; a<=100; a++))
28 echo "echo select * from t$a;"
29 echo "select * from t$a;"
30 done >>$REL_PATH/selectfrom100.sql
31 echo "select file created"
33 for((a=1; a<=100; a++))
35 echo "drop table t$a;"
36 done >>$REL_PATH/drop100table.sql
38 echo "use test;">>$REL_PATH/updatetrigger100.sql
39 for((a=1; a<=100; a++))
41 echo "drop trigger if exists triggerupdatet$a;"
42 echo "create trigger triggerupdatet$a AFTER UPDATE on t$a FOR EACH ROW BEGIN Insert into csql_log_int (tablename, pkid, operation,cacheid) values ('t$a', OLD.f1, 2,1);Insert into csql_log_int (tablename, pkid, operation,cacheid) values ('t$a', NEW.f1, 1,1); End;"
43 done >> $REL_PATH/updatetrigger100.sql
44 echo "Trigger file generated"
46 for((a=1; a<=100; a++))
48 echo "drop trigger if exists triggerupdatet$a;"
49 done >>$REL_PATH/dropupdatetrigger.sql
50 echo "Drop trigger file generated"
52 for((a=1; a<=100; a++))
54 echo "update t$a set f2=50 where f2 >19;"
55 done >> $REL_PATH/update100table.sql
56 echo "Update file created"
58 #cp $CSQL_CONFIG_FILE /tmp/csql.conf
59 #echo DSN=$DSN >>$CSQL_CONFIG_FILE
60 isql $DSN < $REL_PATH/mysqlcreatelogtable.sql >/dev/null 2>&1
61 echo Log table created in target DB
62 isql $DSN < $REL_PATH/create100table.sql >/dev/null
63 rm -f /tmp/csql/csqltable.conf /tmp/csql/csql.db
64 touch /tmp/csql/csqltable.conf /tmp/csql/csql.db
65 isql $DSN <$REL_PATH/updatetrigger100.sql >/dev/null
67 export CSQL_CONFIG_FILE=$REL_PATH/csql1.conf
68 echo DSN=$DSN >>$CSQL_CONFIG_FILE
70 for (( a=1; a<=100; a++ ))
72 echo "1:t$a NULL NULL NULL"
73 done >> /tmp/csql/csqltable.conf
75 $CSQL_INSTALL_ROOT/bin/csqlserver -c >/dev/null 2>&1 &
76 pid=$!
77 sleep 30
78 echo "server started"
80 $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/selectfrom100.sql
81 if [ $? -ne 0 ]
82 then
83 echo "unable to locate cache 1"
84 isql $DSN < ${REL_PATH}/drop100table.sql >/dev/null 2>&1
85 rm -f $REL_PATH/create100table.sql
86 rm -f $REL_PATH/update100table.sql
87 rm -f $REL_PATH/selectfrom100.sql
88 rm -f $REL_PATH/drop100table.sql
89 rm -f $REL_PATH/dropupdatetrigger.sql
90 rm -f $REL_PATH/updatetrigger100.sql
91 # cp /tmp/csql.conf $CSQL_CONFIG_FILE
92 exit 1
95 echo "Update some record in target database"
96 isql $DSN < ${REL_PATH}/update100table.sql >/dev/null 2>&1
97 sleep 30
98 echo "Records in csql after update in target DB"
99 $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/selectfrom100.sql
101 $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/drop100table.sql > /dev/null 2>&1
102 isql $DSN < ${REL_PATH}/drop100table.sql >/dev/null 2>&1
103 rm -f /tmp/csql/csqltable.conf /tmp/csql/csql.db
104 touch /tmp/csql/csqltable.conf /tmp/csql/csql.db
105 isql $DSN < $REL_PATH/dropupdatetrigger.sql >/dev/null 2>&1
106 isql $DSN < $REL_PATH/mysqldeletelogtable.sql >/dev/null 2>&1
107 kill -2 $pid
108 ipcrm -M 4000 -M 4500
110 rm -f $REL_PATH/create100table.sql
111 rm -f $REL_PATH/update100table.sql
112 rm -f $REL_PATH/selectfrom100.sql
113 rm -f $REL_PATH/drop100table.sql
114 rm -f $REL_PATH/updatetrigger100.sql
115 rm -f $REL_PATH/dropupdatetrigger.sql
116 # cp /tmp/csql.conf $CSQL_CONFIG_FILE
117 exit 0;