adding test scripts
[csql.git] / test / cache / FailOver / test008d.ksh
blob0306da2121cb9bfa5303309143eb390864be4c8c
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
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;
36 if [ $DSN = "oracle" ]
37 then
38 isql $DS < $REL_PATH/orainputt1.oracle >/dev/null 2>&1
39 elif [ $DSN = "sybase" ]
40 then
41 isql $DS < $REL_PATH/sybaseinputtest1.sql >/dev/null 2>&1
42 elif [ $DSN = "db2" ]
43 then
44 isql $DS < $REL_PATH/db2inputtest1.sql >/dev/null 2>&1
45 else
46 isql $DS < $REL_PATH/mysqlinputtest1.sql >/dev/null 2>&1
49 if [ $? -ne 0 ]
50 then
51 exit 3;
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 4;
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 else
79 isql $DS < $REL_PATH/mysqlinputtest2.sql >/dev/null 2>&1
82 if [ $? -ne 0 ]
83 then
84 exit 5;
87 echo "table t2(not cached) inserted into target db"
88 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/csqlinputt3.sql >/dev/null 2>&1
89 echo "table t3 inserted into csql db"
91 $REL_PATH/deleteexeccsqldown &
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 6;
103 rm -f /tmp/csql/csqltable.conf
104 touch /tmp/csql/csqltable.conf
105 exit 0;