adding test scripts
[csql.git] / test / cache / Gateway / test005.ksh
blobb08a66ff9a21c6ad3c06fa46daf17325a372c8c5
1 #!/bin/ksh
3 # 5. Cached table there in csql, but complex query (avg on some field). It should get the correct value from mysql.
5 #Run this test only under csql/test or on this directory.
6 #Otherwise, it may fail
7 input=${PWD}/cache/Gateway/mysqlinputtest1.sql
8 REL_PATH=.
9 if [ -s "$input" ]
10 then
11 REL_PATH=${PWD}/cache/Gateway
13 rm -f /tmp/csql.conf
15 cp $REL_PATH/csql.conf /tmp/csql.conf
16 export CSQL_CONFIG_FILE=/tmp/csql.conf
17 echo DSN=$DSN >>$CSQL_CONFIG_FILE
18 DS="$DSN $DBUSER $PASSWORD"
19 rm -f /tmp/csql/csqlds.conf
20 touch /tmp/csql/csqlds.conf
21 $CSQL_INSTALL_ROOT/bin/csqlds -U $DBUSER -P $PASSWORD -D $DSN -N $TDB -a
22 if [ $? -ne 0 ]
23 then
24 exit 1;
27 if [ $DSN = "oracle" ]
28 then
29 isql $DS < $REL_PATH/orainputt1.oracle >/dev/null 2>&1
30 elif [ $DSN = "sybase" ]
31 then
32 isql $DS < $REL_PATH/sybaseinputtest1.sql >/dev/null 2>&1
33 elif [ $DSN = "db2" ]
34 then
35 isql $DS < $REL_PATH/db2inputtest1.sql >/dev/null 2>&1
36 else
37 isql $DS < $REL_PATH/mysqlinputtest1.sql >/dev/null 2>&1
40 if [ $? -ne 0 ]
41 then
42 echo "DSN is not set for target db"
43 exit 1
46 # edit /tmp/csql/csqltable.conf
47 rm -f /tmp/csql/csqltable.conf
48 touch /tmp/csql/csqltable.conf
49 $CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 &
50 pid=$!
51 sleep 5
52 $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -d $DSN
53 if [ $? -ne 0 ]
54 then
55 kill -9 $pid
56 ipcrm -M 1199 -M 2277
57 exit 3;
60 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/selectstar.sql
61 if [ $? -ne 0 ]
62 then
63 echo "Unable to start server"
64 exit 4
67 if [ $DSN = "oracle" ]
68 then
69 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/complex.oracle
70 elif [ $DSN = "sybase" -o $DSN = "db2" ]
71 then
72 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/complex.sybase
73 else
74 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/complex.sql
77 isql $DS < $REL_PATH/dropt1t2t3.sql > /dev/null 2>&1
78 rm -f /tmp/csql/csqltable.conf
79 touch /tmp/csql/csqltable.conf
80 kill -9 $pid
81 ipcrm -M 1199 -M 2277
82 exit 0;