adding test scripts
[csql.git] / test / cache / FailOver / test004a.ksh
bloba481b2836f5f6328e6168c51077fce966b012877
1 #!/bin/ksh
3 # 4a) After connect, csql goes down, then all select 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
14 rm -f /tmp/csql.conf
15 cp $REL_PATH/csql.conf /tmp
16 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;
28 isql $DS < $REL_PATH/dropt1t2.sql >/dev/null 2>&1
29 if [ $? -ne 0 ]
30 then
31 exit 2;
34 if [ $DSN = "oracle" ]
35 then
36 isql $DS < $REL_PATH/orainputt1.oracle >/dev/null 2>&1
37 elif [ $DSN = "sybase" ]
38 then
39 isql $DS < $REL_PATH/sybaseinputtest1.sql >/dev/null 2>&1
40 elif [ $DSN = "db2" ]
41 then
42 isql $DS < $REL_PATH/db2inputtest1.sql >/dev/null 2>&1
43 else
44 isql $DS < $REL_PATH/mysqlinputtest1.sql >/dev/null 2>&1
47 echo "table t1(to be cached) inserted into target db"
48 # edit /tmp/csql/csqltable.conf
49 rm -f /tmp/csql/csqltable.conf
50 touch /tmp/csql/csqltable.conf
52 $CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 &
53 pid=$!
54 sleep 5
55 $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -d $DSN
56 if [ $? -ne 0 ]
57 then
58 kill -9 $pid
59 ipcrm -M 1199 -M 2277
60 exit 3;
63 echo "table t1 cached into csql"
65 if [ $DSN = "oracle" ]
66 then
67 isql $DS < $REL_PATH/orainputt2.oracle >/dev/null 2>&1
68 elif [ $DSN = "sybase" ]
69 then
70 isql $DS < $REL_PATH/sybaseinputtest2.sql >/dev/null 2>&1
71 elif [ $DSN = "db2" ]
72 then
73 isql $DS < $REL_PATH/db2inputtest2.sql >/dev/null 2>&1
74 else
75 isql $DS < $REL_PATH/mysqlinputtest2.sql >/dev/null 2>&1
78 echo "table t2(not cached) inserted into target db"
80 if [ $DSN = "oracle" ]
81 then
82 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/orainputt3.oracle >/dev/null 2>&1
83 else
84 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/csqlinputt3.sql >/dev/null 2>&1
87 echo "table t3 inserted into csql db"
89 $REL_PATH/selectconncsqldown &
90 bgproc=$!
91 kill -9 $pid
92 ipcrm -M 1199 -M 2277
93 echo "csql server is down"
94 wait $bgproc
95 isql $DS < $REL_PATH/dropt1t2.sql >/dev/null 2>&1
96 if [ $? -ne 0 ]
97 then
98 exit 4;
101 rm -f /tmp/csql/csqltable.conf /tmp/csql/csqlds.conf
102 touch /tmp/csql/csqltable.conf /tmp/csql/csqlds.conf
103 exit 0;