adding test scripts
[csql.git] / test / cache / FailOver / test006a.ksh
blob5b7a0ea416a50239beb145279082f4869edee24c
1 #!/bin/ksh
3 # 6a. After connect and prepare, csql goes down. it should do select for cached tables and MySQL in MySQL directly
4 # non cached csql tables 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
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;
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 echo "table t1(to be cached) inserted into target db"
50 # edit /tmp/csql/csqltable.conf
51 rm -f /tmp/csql/csqltable.conf
52 touch /tmp/csql/csqltable.conf
54 $CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 &
55 pid=$!
56 sleep 5
57 $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -d $DSN
58 if [ $? -ne 0 ]
59 then
60 kill -9 $pid
61 ipcrm -M 1199 -M 2277
62 exit 3;
65 echo "table t1 cached into csql"
67 if [ $DSN = "oracle" ]
68 then
69 isql $DS < $REL_PATH/orainputt2.oracle >/dev/null 2>&1
70 elif [ $DSN = "sybase" ]
71 then
72 isql $DS < $REL_PATH/sybaseinputtest2.sql >/dev/null 2>&1
73 elif [ $DSN = "db2" ]
74 then
75 isql $DS < $REL_PATH/db2inputtest2.sql >/dev/null 2>&1
76 else
77 isql $DS < $REL_PATH/mysqlinputtest2.sql >/dev/null 2>&1
80 echo "table t2(not cached) inserted into target db"
81 if [ $DSN = "oracle" ]
82 then
83 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/orainputt3.oracle >/dev/null 2>&1
84 else
85 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/csqlinputt3.sql >/dev/null 2>&1
87 echo "table t3 inserted into csql db"
89 $REL_PATH/selectprepcsqldown &
90 bgproc=$!
91 kill -9 $pid
92 ipcrm -M 1199 -M 2277
93 echo "csql server is down"
94 wait $bgproc
95 isql $DS < $REL_PATH/dropt1t2.sql >/dev/null 2>&1
96 if [ $? -ne 0 ]
97 then
98 exit 4;
101 rm -f /tmp/csql/csqltable.conf
102 touch /tmp/csql/csqltable.conf
103 exit 0;