*** empty log message ***
[csql.git] / test / cache / FailOver / test004c.ksh
blob8f33dcc76808a5566abb634c8ed4747b3560f808
1 #!/bin/ksh
3 # 4.After connect, csql goes down, then all update 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;
28 isql $DS < $REL_PATH/dropt1t2.sql >/dev/null 2>&1
29 if [ $? -ne 0 ]
30 then
31 exit 2;
33 if [ $DSN = "oracle" ]
34 then
35 isql $DS < $REL_PATH/orainputt1.oracle >/dev/null 2>&1
36 elif [ $DSN = "sybase" ]
37 then
38 isql $DS < $REL_PATH/sybaseinputtest1.sql >/dev/null 2>&1
39 elif [ $DSN = "db2" ]
40 then
41 isql $DS < $REL_PATH/db2inputtest1.sql >/dev/null 2>&1
42 else
43 isql $DS < $REL_PATH/mysqlinputtest1.sql >/dev/null 2>&1
46 echo "table t1(to be cached) inserted into target db"
47 # edit /tmp/csql/csqltable.conf
48 rm -f /tmp/csql/csqltable.conf
49 touch /tmp/csql/csqltable.conf
51 $CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 &
52 pid=$!
53 sleep 5
54 $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -d $DSN
55 if [ $? -ne 0 ]
56 then
57 kill -9 $pid
58 ipcrm -M 1199 -M 2277
59 exit 3;
62 echo "table t1 cached into csql"
63 if [ $DSN = "oracle" ]
64 then
65 isql $DS < $REL_PATH/orainputt2.oracle >/dev/null 2>&1
66 elif [ $DSN = "sybase" ]
67 then
68 isql $DS < $REL_PATH/sybaseinputtest2.sql >/dev/null 2>&1
69 elif [ $DSN = "db2" ]
70 then
71 isql $DS < $REL_PATH/db2inputtest2.sql >/dev/null 2>&1
72 else
73 isql $DS < $REL_PATH/mysqlinputtest2.sql >/dev/null 2>&1
75 echo "table t2(not cached) inserted into target db"
77 if [ $DSN = "oracle" ]
78 then
79 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/orainputt3.oracle >/dev/null 2>&1
80 else
81 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/csqlinputt3.sql >/dev/null 2>&1
83 echo "table t3 inserted into csql db"
85 if [ $DSN = "oracle" ]
86 then
87 ${REL_PATH}/updateconncsqldownora &
88 else
89 ${REL_PATH}/updateconncsqldown &
92 bgproc=$!
93 kill -9 $pid
94 ipcrm -M 1199 -M 2277
95 echo "csql server is down"
96 wait $bgproc
97 isql $DS < $REL_PATH/dropt1t2.sql >/dev/null 2>&1
98 if [ $? -ne 0 ]
99 then
100 exit 4;
103 rm -f /tmp/csql/csqltable.conf /tmp/csql/csqlds.conf
104 touch /tmp/csql/csqltable.conf /tmp/csql/csqlds.conf
105 exit 0;