64 bit build fix
[csql.git] / test / cache / FailOver / test004d.ksh
blob55b602b1ee5b8118219f82b49c22bb7e3a897923
1 #!/bin/ksh
3 # 4.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
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;
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 if [ $? -ne 0 ]
49 then
50 cp /tmp/csql.conf $CSQL_CONFIG_FILE
51 exit 1;
54 echo "table t1(to be cached) inserted into target db"
55 # edit /tmp/csql/csqltable.conf
56 rm -f /tmp/csql/csqltable.conf
57 touch /tmp/csql/csqltable.conf
59 $CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 &
60 pid=$!
61 sleep 5
62 $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -d $DSN
63 if [ $? -ne 0 ]
64 then
65 kill -9 $pid
66 ipcrm -M 1199 -M 2277
67 exit 3;
70 echo "table t1 cached into csql"
72 if [ $DSN = "oracle" ]
73 then
74 isql $DS < $REL_PATH/orainputt2.oracle >/dev/null 2>&1
75 elif [ $DSN = "sybase" ]
76 then
77 isql $DS < $REL_PATH/sybaseinputtest2.sql >/dev/null 2>&1
78 elif [ $DSN = "db2" ]
79 then
80 isql $DS < $REL_PATH/db2inputtest2.sql >/dev/null 2>&1
81 else
82 isql $DS < $REL_PATH/mysqlinputtest2.sql >/dev/null 2>&1
85 echo "table t2(not cached) inserted into target db"
87 if [ $DSN = "oracle" ]
88 then
89 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/orainputt3.oracle >/dev/null 2>& 1
90 else
91 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/csqlinputt3.sql >/dev/null 2>&1
93 echo "table t3 inserted into csql db"
95 $REL_PATH/deleteconncsqldown &
96 bgproc=$!
97 kill -9 $pid
98 ipcrm -M 1199 -M 2277
99 echo "csql server is down"
100 wait $bgproc
101 isql $DS < $REL_PATH/dropt1t2.sql >/dev/null 2>&1
102 if [ $? -ne 0 ]
103 then
104 exit 4;
107 rm -f /tmp/csql/csqltable.conf
108 touch /tmp/csql/csqltable.conf
109 exit 0;