adding test scripts
[csql.git] / test / cache / Gateway / test001.ksh
bloba0ab9d75c54ec1117444f3b291ab8cdecc1e69f0
1 #!/bin/ksh
3 # 1. Create table t1 in MySQL with all supported data types in it. and insert 10 records in it.
4 # Cache the table in CSQL. and run csqlserver -c to load the records.
5 # insert 10 more records using csql tool.
6 # select records with WHERE clause containing parameters for all the fields with different data types.
7 # update all fields with WHERE clause on primary key
8 # delete records with WHERE clause on all fields
10 #Run this test only under csql/test or on this directory.
11 #Otherwise, it may fail
12 input=${PWD}/cache/Gateway/mysqlinputtest1.sql
13 REL_PATH=.
14 if [ -s "$input" ]
15 then
16 REL_PATH=${PWD}/cache/Gateway
18 rm -f /tmp/csql.conf
20 cp $REL_PATH/csql.conf /tmp/csql.conf
21 export CSQL_CONFIG_FILE=/tmp/csql.conf
22 echo DSN=$DSN >>$CSQL_CONFIG_FILE
23 DS="$DSN $DBUSER $PASSWORD"
24 rm -f /tmp/csql/csqlds.conf
25 touch /tmp/csql/csqlds.conf
26 $CSQL_INSTALL_ROOT/bin/csqlds -U $DBUSER -P $PASSWORD -D $DSN -N $TDB -a
27 if [ $? -ne 0 ]
28 then
29 exit 1;
32 if [ $DSN = "oracle" ]
33 then
34 isql $DS < $REL_PATH/orainputt1.oracle >/dev/null 2>&1
35 elif [ $DSN = "sybase" ]
36 then
37 isql $DS < $REL_PATH/sybaseinputtest1.sql >/dev/null 2>&1
38 elif [ $DSN = "db2" ]
39 then
40 isql $DS < $REL_PATH/db2inputtest1.sql >/dev/null 2>&1
41 else
42 isql $DS < $REL_PATH/mysqlinputtest1.sql >/dev/null 2>&1
44 if [ $? -ne 0 ]
45 then
46 echo "DSN is not set for target db"
47 exit 2;
50 # edit /tmp/csql/csqltable.conf
51 rm -f /tmp/csql/csqltable.conf
52 touch /tmp/csql/csqltable.conf
53 $CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 &
54 pid=$!
55 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 if [ $DSN = "oracle" ]
66 then
67 for a in 51 52 53 54 55
69 echo "insert into t1 values($a,'KKK');"
70 done >> $REL_PATH/oracsqlinputt1.sql
71 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/oracsqlinputt1.sql >/dev/null 2>&1
72 elif [ $DSN = "db2" ]
73 then
74 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/csqldb2inputtest1.sql >/dev/null 2>&1
75 else
76 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/csqlinputtest1.sql >/dev/null 2>&1
79 if [ $? -ne 0 ]
80 then
81 echo "Server Not Open"
82 exit 4;
85 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/selectstar.sql
86 isql $DS < $REL_PATH/selectstar.sql
87 if [ $? -ne 0 ]
88 then
89 cp /tmp/csql.conf $CSQL_CONFIG_FILE
90 exit 5;
93 if [ $DSN = "oracle" ]
94 then
95 echo "select * from t1 where f1 in(10,30,50,54);" >> $REL_PATH/oraselect.sql
96 echo "select * from t1 where f1 between 20 and 54;" >> $REL_PATH/oraselect.sql
97 echo "update t1 set f2='LLL' where f1=20;" >> $REL_PATH/oraupdate.sql
98 echo "delete from t1 where f2='BBB';" >> $REL_PATH/oradelete.sql
99 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/oraselect.sql
100 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/oraupdate.sql >/dev/null 2>&1
101 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/oradelete.sql >/dev/null 2>&1
102 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/selectstar.sql
103 else
104 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/select.sql
105 if [ $DSN = "db2" ]
106 then
107 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/db2update.sql >/dev/null 2>&1
108 else
109 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/update.sql >/dev/null 2>&1
111 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/delete.sql >/dev/null 2>&1
112 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/selectstar.sql
116 isql $DS < $REL_PATH/selectstar.sql
117 isql $DS < $REL_PATH/dropt1t2t3.sql > /dev/null 2>&1
118 rm -f $REL_PATH/ora*.sql
119 rm -f /tmp/csql/csqltable.conf
120 touch /tmp/csql/csqltable.conf
121 kill -9 $pid
122 ipcrm -M 1199 -M 2277
123 exit 0;