adding test scripts
[csql.git] / test / cache / FailOver / test004b.ksh
bloba78db38c49b9d3babb83fd28e422e5890cf66ee3
1 #!/bin/ksh
3 # 4b. After connect, csql goes down, then all insert operations should go to MySQL directly for cached tables and MySQL tables.
5 #Run this test only under csql/test or on this directory.
6 #Otherwise, it may fail
7 CSQL_CONF=${PWD}/cache/FailOver/csql.conf
8 input=${PWD}/cache/FailOver/csqlinputt3.sql
9 REL_PATH=.
10 if [ -s "$input" -a -s "$CSQL_CONF" ]
11 then
12 REL_PATH=${PWD}/cache/FailOver
15 rm --f /tmp/csql.conf
16 cp $REL_PATH/csql.conf /tmp
17 export CSQL_CONFIG_FILE=/tmp/csql.conf
18 echo DSN=$DSN >>$CSQL_CONFIG_FILE
19 DS="$DSN $DBUSER $PASSWORD"
20 rm -f /tmp/csql/csqlds.conf
21 touch /tmp/csql/csqlds.conf
22 $CSQL_INSTALL_ROOT/bin/csqlds -U $DBUSER -P $PASSWORD -D $DSN -N $TDB -a
23 if [ $? -ne 0 ]
24 then
25 exit 1;
29 isql $DS < $REL_PATH/dropt1t2.sql >/dev/null 2>&1
30 if [ $? -ne 0 ]
31 then
32 exit 2;
35 if [ $DSN = "oracle" ]
36 then
37 isql $DS < $REL_PATH/orainputt1.oracle >/dev/null 2>&1
38 elif [ $DSN = "sybase" ]
39 then
40 isql $DS < $REL_PATH/sybaseinputtest1.sql >/dev/null 2>&1
41 elif [ $DSN = "db2" ]
42 then
43 isql $DS < $REL_PATH/db2inputtest1.sql >/dev/null 2>&1
44 else
45 isql $DS < $REL_PATH/mysqlinputtest1.sql >/dev/null 2>&1
48 echo "table t1(to be cached) inserted into target db"
49 # edit /tmp/csql/csqltable.conf
50 rm -f /tmp/csql/csqltable.conf
51 touch /tmp/csql/csqltable.conf
53 $CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 &
54 pid=$!
55 sleep 5
57 $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -d $DSN
58 if [ $? -ne 0 ]
59 then
60 kill -9 $pid
61 ipcrm -M 1199 -M 2277
62 exit 3;
65 echo "table t1 cached into csql"
67 if [ $DSN = "oracle" ]
68 then
69 isql $DS < $REL_PATH/orainputt2.oracle >/dev/null 2>&1
70 elif [ $DSN = "sybase" ]
71 then
72 isql $DS < $REL_PATH/sybaseinputtest2.sql >/dev/null 2>&1
73 elif [ $DSN = "db2" ]
74 then
75 isql $DS < $REL_PATH/db2inputtest2.sql >/dev/null 2>&1
76 else
77 isql $DS < $REL_PATH/mysqlinputtest2.sql >/dev/null 2>&1
80 echo "table t2(not cached) inserted into target db"
82 if [ $DSN = "oracle" ]
83 then
84 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/orainputt3.oracle >/dev/null 2>&1
86 else
87 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/csqlinputt3.sql >/dev/null 2>&1
90 echo "table t3 inserted into csql db"
92 if [ $DSN = "oracle" ]
93 then
94 ${REL_PATH}/insertconncsqldownora &
95 else
96 ${REL_PATH}/insertconncsqldown &
99 bgproc=$!
100 kill -9 $pid
101 ipcrm -M 1199 -M 2277
102 echo "csql server is down"
103 wait $bgproc
104 isql $DS < $REL_PATH/dropt1t2.sql >/dev/null 2>&1
105 if [ $? -ne 0 ]
106 then
107 exit 4;
110 rm -f /tmp/csql/csqltable.conf
111 touch /tmp/csql/csqltable.conf
112 exit 0;