adding test scripts
[csql.git] / test / cache / MultiDsn / Gateway / test025.ksh
blob98d66c5440b0e90d232100afef9291a7e10ac1fe
1 #!/bin/ksh
3 # 1.Make sure Default DSN is psql(CACHE_TABLE=psql)
4 # DSN entries in csqlds.conf file for Postgres and MySQL.
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 # INSERT records into t1,t2 tables in MySQL.
13 # INSERT records into 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 $POSTGRES_USER -P $POSTGRES_PASSWORD -D $POSTGRES_DSN -N $POSTGRES_TDB -a
37 if [ $? -ne 0 ]
38 then
39 exit 2;
41 echo "Entries made for $POSTGRES_DSN in csqlds.conf file."
43 $CSQL_INSTALL_ROOT/bin/csqlds -U $MYSQL_USER -P $MYSQL_PASSWORD -D $MYSQL_DSN -N $MYSQL_TDB -a
44 if [ $? -ne 0 ]
45 then
46 exit 1;
48 echo "Entries made for $MYSQL_DSN in csqlds.conf file."
51 ########## END #########
54 ########## Table in MYSQL and POSTGRES #######
56 isql $DS1 < ${REL_PATH}/mysqltable.sql >/dev/null 2>&1
57 if [ $? -ne 0 ]
58 then
59 exit 3;
61 echo "Table 't1 and t2' is created in $MYSQL_DSN"
63 echo "SELECT records from $MYSQL_DSN"
64 isql $DS1 < ${REL_PATH}/mysqlselect.sql
65 if [ $? -ne 0 ]
66 then
67 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
68 exit 4;
71 isql $DS2 < ${REL_PATH}/psqltable.sql >/dev/null 2>&1
72 if [ $? -ne 0 ]
73 then
74 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
75 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
76 exit 5;
78 echo "Table 'tt1 and tt2' is created in $POSTGRES_DSN"
80 echo "SELECT records from $POSTGRES_DSN"
81 isql $DS2 < ${REL_PATH}/psqlselect.sql
82 if [ $? -ne 0 ]
83 then
84 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
85 exit 6;
88 ######### END #########
91 rm -f /tmp/csql/csqltable.conf
92 touch /tmp/csql/csqltable.conf
94 $CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 &
95 pid=$!
96 sleep 5
98 ######### Cache t1 and tt1 table ##########
101 $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -d $MYSQL_DSN >/dev/null 2>&1
102 if [ $? -ne 0 ]
103 then
104 kill -9 $pid
105 ipcrm -M 1199 -M 2277
106 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
107 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
108 exit 7;
110 echo "Table t1 is cached from $MYSQL_DSN."
112 $CSQL_INSTALL_ROOT/bin/cachetable -t tt1 >/dev/null 2>&1
113 if [ $? -ne 0 ]
114 then
115 kill -9 $pid
116 ipcrm -M 1199 -M 2277
117 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
118 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
119 exit 8;
121 echo "Table 'tt1' is cached from $POSTGRES_DSN."
123 ######## END ########
126 ####### INSERT records into cache table as well as non-cache table ######
128 echo ""
129 echo "INSERT records using Gateway(csql -g)"
130 echo "INSERT records into t1 and t2 table."
131 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/mysqlinsert.sql
132 if [ $? -ne 0 ]
133 then
134 kill -9 $pid
135 ipcrm -M 1199 -M 2277
136 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
137 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
138 exit 9;
141 echo "INSERT records into tt1 and tt2 table."
142 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/psqlinsert.sql
143 if [ $? -ne 0 ]
144 then
145 kill -9 $pid
146 ipcrm -M 1199 -M 2277
147 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
148 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
149 exit 10;
152 ##### END ######
154 ####### SELECT update records from cached and non-cached tabales #######
155 echo ""
156 echo "SELECT records from cached and non-cached tables using Gateway(csql -g)"
157 echo "select 't1' and 't2' table."
158 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/mysqlselect.sql
159 if [ $? -ne 0 ]
160 then
161 kill -9 $pid
162 ipcrm -M 1199 -M 2277
163 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
164 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
165 exit 11;
168 echo "select 'tt1' and 'tt2' table."
169 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/psqlselect.sql
170 if [ $? -ne 0 ]
171 then
172 kill -9 $pid
173 ipcrm -M 1199 -M 2277
174 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
175 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
176 exit 12;
179 rm -f /tmp/csql/csqltable.conf
180 touch /tmp/csql/csqltable.conf
182 rm -f /tmp/csql/csqlds.conf
183 touch -f /tmp/csql/csqlds.conf
185 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
186 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
189 $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/drop.sql > /dev/null 2>&1
190 kill -9 $pid
191 ipcrm -M 1199 -M 2277
192 exit 0;
194 ######### END #########