adding test scripts
[csql.git] / test / cache / FailOver / test008a.ksh
blob04ae576d103bdfb799a7aa431fdeb0c0ba10bf12
1 #!/bin/ksh
3 # 8.After connect, prepare, execute, CSQL goes down.fetch() should return records from MySQL for cached and MySQL table.
4 # fetch() on csql non-cached table will fail.
6 #Run this test only under csql/test or on this directory.
7 #Otherwise, it may fail
8 CSQL_CONF=${PWD}/cache/FailOver/csql.conf
9 input=${PWD}/cache/FailOver/csqlinputt3.sql
10 REL_PATH=.
11 if [ -s "$input" -a -s "$CSQL_CONF" ]
12 then
13 REL_PATH=${PWD}/cache/FailOver
16 rm -f /tmp/csql.conf
17 cp $REL_PATH/csql.conf /tmp
18 export CSQL_CONFIG_FILE=/tmp/csql.conf
19 echo DSN=$DSN >>$CSQL_CONFIG_FILE
20 DS="$DSN $DBUSER $PASSWORD"
21 rm -f /tmp/csql/csqlds.conf
22 touch /tmp/csql/csqlds.conf
23 $CSQL_INSTALL_ROOT/bin/csqlds -U $DBUSER -P $PASSWORD -D $DSN -N $TDB -a
24 if [ $? -ne 0 ]
25 then
26 exit 1;
30 isql $DS < $REL_PATH/dropt1t2.sql >/dev/null 2>&1
31 if [ $? -ne 0 ]
32 then
33 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 if [ $? -ne 0 ]
49 then
50 exit 1;
53 echo "table t1(to be cached) inserted into target db"
54 # edit /tmp/csql/csqltable.conf
55 rm -f /tmp/csql/csqltable.conf
56 touch /tmp/csql/csqltable.conf
58 $CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 &
59 pid=$!
60 sleep 5
61 $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -d $DSN
62 if [ $? -ne 0 ]
63 then
64 kill -9 $pid
65 ipcrm -M 1199 -M 2277
66 exit 3;
69 echo "table t1 cached into csql"
71 if [ $DSN = "oracle" ]
72 then
73 isql $DS < $REL_PATH/orainputt2.oracle >/dev/null 2>&1
74 elif [ $DSN = "sybase" ]
75 then
76 isql $DS < $REL_PATH/sybaseinputtest2.sql >/dev/null 2>&1
77 elif [ $DSN = "db2" ]
78 then
79 isql $DS < $REL_PATH/db2inputtest2.sql >/dev/null 2>&1
80 else
81 isql $DS < $REL_PATH/mysqlinputtest2.sql >/dev/null 2>&1
83 if [ $? -ne 0 ]
84 then
85 exit 4;
88 echo "table t2(not cached) inserted into target db"
90 if [ $DSN = "oracle" ]
91 then
92 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/orainputt3.oracle >/dev/null 2>&1
93 else
94 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/csqlinputt3.sql >/dev/null 2>&1
97 echo "table t3 inserted into csql db"
99 $REL_PATH/selectexeccsqldown &
100 bgproc=$!
101 kill -9 $pid
102 ipcrm -M 1199 -M 2277
103 echo "csql server is down"
104 wait $bgproc
105 isql $DS < $REL_PATH/dropt1t2.sql >/dev/null 2>&1
106 if [ $? -ne 0 ]
107 then
108 exit 5;
110 rm -f /tmp/csql/csqltable.conf
111 touch /tmp/csql/csqltable.conf
112 exit 0;