adding test scripts
[csql.git] / test / cache / MultiDsn / Gateway / test001.ksh
blob872075b15651ca7e33208ff58df440b0a5992c96
1 #!/bin/ksh
3 # 1.Make sure Default DSN is myodbc3(CACHE_TABLE=myodbc3)
4 # DSN entries in csqlds.conf file for MySQL and Postgres.
5 # Create table 't1'and 't2' in MySQL with all supported
6 # data types in it with 5 records.
7 # Create table 'tt1' and 'tt2' in Postgres with all supported
8 # data type with 5 records.
9 # cache 't1' from MySQL and 'tt1' from Postgres.
10 # Select records from 't1' and 'tt1' table using Gateway,
11 # it should fetch the records from csql.
12 # Select records from 't2' and 'tt2' using gateway,
13 # it should fetch the records from their respective TDB.
15 # Run thsi test only under csql/test or on this directory,
16 # Otherwise it may fail.
18 input=${PWD}/cache/MultiDsn/Gateway/mysqltable.sql
19 REL_PATH=.
20 if [ -s "$input" ]
21 then
22 REL_PATH=${PWD}/cache/MultiDsn/Gateway
25 rm -f /tmp/csql.conf
26 cp $REL_PATH/csql.conf /tmp
27 export CSQL_CONFIG_FILE=/tmp/csql.conf
29 echo DSN=$MYSQL_DSN >>$CSQL_CONFIG_FILE
31 rm -f /tmp/csql/csqlds.conf
32 touch /tmp/csql/csqlds.conf
34 ########## csqlds.conf entries #########
36 $CSQL_INSTALL_ROOT/bin/csqlds -U $MYSQL_USER -P $MYSQL_PASSWORD -D $MYSQL_DSN -N $MYSQL_TDB -a
37 if [ $? -ne 0 ]
38 then
39 exit 1;
41 echo "Entries made for $MYSQL_DSN in csqlds.conf file."
43 $CSQL_INSTALL_ROOT/bin/csqlds -U $POSTGRES_USER -P $POSTGRES_PASSWORD -D $POSTGRES_DSN -N $POSTGRES_TDB -a
44 if [ $? -ne 0 ]
45 then
46 exit 2;
48 echo "Entries made for $POSTGRES_DSN in csqlds.conf file."
50 ########## END #########
52 #Drop the table both in Mysql and Postgres if exists
53 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
54 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
57 ########## Table in MYSQL and POSTGRES #######
59 isql $DS1 < ${REL_PATH}/mysqltable.sql >/dev/null 2>&1
60 if [ $? -ne 0 ]
61 then
62 exit 3;
64 echo "Table 't1 and t2' is created in $MYSQL_DSN"
66 echo "SELECT records from $MYSQL_DSN"
67 isql $DS1 < ${REL_PATH}/mysqlselect.sql
68 if [ $? -ne 0 ]
69 then
70 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
71 exit 4;
74 isql $DS2 < ${REL_PATH}/psqltable.sql >/dev/null 2>&1
75 if [ $? -ne 0 ]
76 then
77 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
78 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
79 exit 5;
81 echo "Table 'tt1 and tt2' is created in $POSTGRES_DSN"
83 echo "SELECT records from $POSTGRES_DSN"
84 isql $DS2 < ${REL_PATH}/psqlselect.sql
85 if [ $? -ne 0 ]
86 then
87 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
88 exit 6;
91 ######### END #########
94 rm -f /tmp/csql/csqltable.conf
95 touch /tmp/csql/csqltable.conf
97 $CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 &
98 pid=$!
99 sleep 5
101 ######### Cache t1 and tt1 table ##########
104 $CSQL_INSTALL_ROOT/bin/cachetable -t t1 >/dev/null 2>&1
105 if [ $? -ne 0 ]
106 then
107 kill -9 $pid
108 ipcrm -M 1199 -M 2277
109 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
110 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
111 exit 7;
113 echo "Table t1 is cached from $MYSQL_DSN."
115 $CSQL_INSTALL_ROOT/bin/cachetable -t tt1 -d $POSTGRES_DSN > /dev/null 2>&1
116 if [ $? -ne 0 ]
117 then
118 kill -9 $pid
119 ipcrm -M 1199 -M 2277
120 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
121 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
122 exit 8;
124 echo "Table 'tt1' is cached from $POSTGRES_DSN."
126 ######## END ########
129 ####### Fetch cached tables and non-cache table ######
131 echo ""
132 echo "Select records using Gateway(csql -g)"
133 echo "select records from t1 and t2"
134 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/mysqlselect.sql
135 if [ $? -ne 0 ]
136 then
137 kill -9 $pid
138 ipcrm -M 1199 -M 2277
139 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
140 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
141 exit 9;
144 echo "select records from tt1 and tt2."
145 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/psqlselect.sql
146 if [ $? -ne 0 ]
147 then
148 kill -9 $pid
149 ipcrm -M 1199 -M 2277
150 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
151 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
152 exit 10;
155 rm -f /tmp/csql/csqltable.conf
156 touch /tmp/csql/csqltable.conf
158 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
159 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
162 $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/drop.sql > /dev/null 2>&1
163 kill -9 $pid
164 ipcrm -M 1199 -M 2277
165 exit 0;
167 ######### END #########