adding test scripts
[csql.git] / test / cache / FailOver / test003.ksh
blob0d8fb2e02a197965f350aee43c8a088f12e81126
1 #!/bin/ksh
3 # 3. SELECT/INSERT/UPDATE/DELETE on MySQL table, when csqlserver is down should pass.
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/csqlinput.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
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
31 if [ $DSN = "oracle" ]
32 then
33 isql $DS < $REL_PATH/orainputt1.oracle >/dev/null 2>&1
34 elif [ $DSN = "sybase" ]
35 then
36 isql $DS < $REL_PATH/sybaseinputtest1.sql >/dev/null 2>&1
37 elif [ $DSN = "db2" ]
38 then
39 isql $DS < $REL_PATH/db2inputtest1.sql >/dev/null 2>&1
40 else
41 isql $DS < $REL_PATH/mysqlinputtest1.sql >/dev/null 2>&1
43 if [ $? -ne 0 ]
44 then
45 exit 2;
48 echo "table t1 inserted into target db"
49 # edit /tmp/csql/csqltable.conf
50 echo "csql server is down"
51 if [ $DSN = "oracle" ]
52 then
53 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/oracsqlinput.oracle
54 else
55 if [ $DSN = "db2" ]
56 then
57 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/csqldb2input.sql
58 else
59 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/csqlinput.sql
61 fi
63 isql $DS < $REL_PATH/dropt1t2.sql >/dev/null 2>&1
64 rm -f /tmp/csql/csqltable.conf /tmp/csql/csqlds.conf
65 touch /tmp/csql/csqltable.conf /tmp/csql/csqlds.conf
66 exit 0;