64 bit build fix
[csql.git] / test / cache / FailOver / test008b.ksh
bloba337f93e044d41342046f1a2b367cb19e6855ac2
1 #!/bin/ksh
3 # 8d. 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/csql.conf
18 export CSQL_CONFIG_FILE=/tmp/csql.conf
20 echo DSN=$DSN >>$CSQL_CONFIG_FILE
21 DS="$DSN $DBUSER $PASSWORD"
22 rm -f /tmp/csql/csqlds.conf
23 touch /tmp/csql/csqlds.conf
24 $CSQL_INSTALL_ROOT/bin/csqlds -U $DBUSER -P $PASSWORD -D $DSN -N $TDB -a
25 if [ $? -ne 0 ]
26 then
27 exit 1;
31 isql $DS < $REL_PATH/dropt1t2.sql >/dev/null 2>&1
32 if [ $? -ne 0 ]
33 then
34 exit 2;
37 if [ $DSN = "oracle" ]
38 then
39 isql $DS < $REL_PATH/orainputt1.oracle >/dev/null 2>&1
40 elif [ $DSN = "sybase" ]
41 then
42 isql $DS < $REL_PATH/sybaseinputtest1.sql >/dev/null 2>&1
43 elif [ $DSN = "db2" ]
44 then
45 isql $DS < $REL_PATH/db2inputtest1.sql >/dev/null 2>&1
46 else
47 isql $DS < $REL_PATH/mysqlinputtest1.sql >/dev/null 2>&1
49 if [ $? -ne 0 ]
50 then
51 exit 4;
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 5;
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 6;
87 echo "table t2(not cached) inserted into target db"
89 if [ $DSN = "oracle" ]
90 then
91 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/orainputt3.oracle >/dev/null 2>&1
92 else
93 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/csqlinputt3.sql >/dev/null 2>&1
96 echo "table t3 inserted into csql db"
98 if [ $DSN = "oracle" ]
99 then
100 ${REL_PATH}/insertexeccsqldownora &
101 else
102 ${REL_PATH}/insertexeccsqldown &
105 bgproc=$!
106 kill -9 $pid
107 ipcrm -M 1199 -M 2277
108 echo "csql server is down"
109 wait $bgproc
110 isql $DS < $REL_PATH/dropt1t2.sql >/dev/null 2>&1
111 if [ $? -ne 0 ]
112 then
113 cp /tmp/csql.conf $CSQL_CONFIG_FILE
114 exit 7;
116 rm -f /tmp/csql/csqltable.conf
117 touch /tmp/csql/csqltable.conf
118 exit 0;