adding test scripts
[csql.git] / test / cache / MultiDsn / Gateway / test023.ksh
blob599d75407ce3f4272ce876595fef0af0729dedc7
1 #!/bin/ksh
3 # 1.Make sure Default DSN is psql(CACHE_TABLE=psql)
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.
10 # cache 't1' from MySQL and 'tt1' from Postgres.
12 # DELTE records from t1,t2 tables in MySQL.
13 # DELTE records from tt1,tt2 tables in Postgres.
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=$POSTGRES_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 #########
53 ########## Table in MYSQL and POSTGRES #######
55 isql $DS1 < ${REL_PATH}/mysqltable.sql >/dev/null 2>&1
56 if [ $? -ne 0 ]
57 then
58 exit 3;
60 echo "Table 't1 and t2' is created in $MYSQL_DSN"
62 echo "SELECT records from $MYSQL_DSN"
63 isql $DS1 < ${REL_PATH}/mysqlselect.sql
64 if [ $? -ne 0 ]
65 then
66 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
67 exit 4;
70 isql $DS2 < ${REL_PATH}/psqltable.sql >/dev/null 2>&1
71 if [ $? -ne 0 ]
72 then
73 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
74 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
75 exit 5;
77 echo "Table 'tt1 and tt2' is created in $POSTGRES_DSN"
79 echo "SELECT records from $POSTGRES_DSN"
80 isql $DS2 < ${REL_PATH}/psqlselect.sql
81 if [ $? -ne 0 ]
82 then
83 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
84 exit 6;
87 ######### END #########
90 rm -f /tmp/csql/csqltable.conf
91 touch /tmp/csql/csqltable.conf
93 $CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 &
94 pid=$!
95 sleep 5
97 ######### Cache t1 and tt1 table ##########
100 $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -d $MYSQL_DSN >/dev/null 2>&1
101 if [ $? -ne 0 ]
102 then
103 kill -9 $pid
104 ipcrm -M 1199 -M 2277
105 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
106 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
107 exit 7;
109 echo "Table t1 is cached from $MYSQL_DSN."
111 $CSQL_INSTALL_ROOT/bin/cachetable -t tt1 >/dev/null 2>&1
112 if [ $? -ne 0 ]
113 then
114 kill -9 $pid
115 ipcrm -M 1199 -M 2277
116 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
117 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
118 exit 8;
120 echo "Table 'tt1' is cached from $POSTGRES_DSN."
122 ######## END ########
125 ####### UPDATE cache table as well as non-cache table ######
127 echo ""
128 echo "DELETE records from tables using Gateway(csql -g)"
129 echo "DELETE records from t1 and t2 table."
130 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/mysqldelete.sql
131 if [ $? -ne 0 ]
132 then
133 kill -9 $pid
134 ipcrm -M 1199 -M 2277
135 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
136 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
137 exit 9;
140 echo "DELETE records from tt1 and tt2 table."
141 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/psqldelete.sql
142 if [ $? -ne 0 ]
143 then
144 kill -9 $pid
145 ipcrm -M 1199 -M 2277
146 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
147 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
148 exit 10;
151 ##### END ######
153 ####### SELECT update records from cached and non-cached tabales #######
154 echo ""
155 echo "SELECT records from cached and non-cached tables using Gateway(csql -g)"
156 echo "select 't1' and 't2' table."
157 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/mysqlselect.sql
158 if [ $? -ne 0 ]
159 then
160 kill -9 $pid
161 ipcrm -M 1199 -M 2277
162 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
163 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
164 exit 11;
167 echo "select 'tt1' and 'tt2' table."
168 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/psqlselect.sql
169 if [ $? -ne 0 ]
170 then
171 kill -9 $pid
172 ipcrm -M 1199 -M 2277
173 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
174 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
175 exit 12;
178 rm -f /tmp/csql/csqltable.conf
179 touch /tmp/csql/csqltable.conf
181 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
182 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
185 $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/drop.sql > /dev/null 2>&1
186 kill -9 $pid
187 ipcrm -M 1199 -M 2277
188 exit 0;
190 ######### END #########