adding test scripts
[csql.git] / test / cache / MultiDsn / CacheToolOpts / test004.ksh
blob56708f7beed39a69a14ca707213d315fa97db8d8
1 #!/bin/ksh
3 # 1. Create 2 tables in each of the TDB in
4 # MySQL, Postgres,DB2 and Oracle.
6 # Default DSN is set as "myodbc3".
7 # Use "cachetable tool" to cache the tables from DSNs.
8 #
9 # 1. cache one table from each DSN.
10 # 2. Now use "cachetable -d <dsName>" to cache all tables
12 # Run this test only under cql/test or on this directory,
13 # Otherwise it will fail.
16 input=${PWD}/cache/MultiDsn/CacheToolOptions/mysqltable.sql
17 REL_PATH=.
18 if [ -s "$input" ]
19 then
20 REL_PATH=${PWD}/cache/MultiDsn/CacheToolOptions
23 rm -f /tmp/csql.conf
24 cp -f $REL_PATH/csql.conf /tmp
25 export CSQL_CONFIG_FILE=/tmp/csql.conf
27 echo DSN=$MYSQL_DSN >>$CSQL_CONFIG_FILE
29 rm -f /tmp/csql/csqlds.conf
30 touch /tmp/csql/csqlds.conf
32 ########## csqlds.conf entries #########
34 $CSQL_INSTALL_ROOT/bin/csqlds -U $MYSQL_USER -P $MYSQL_PASSWORD -D $MYSQL_DSN -N $MYSQL_TDB -a
35 if [ $? -ne 0 ]
36 then
37 exit 1;
39 echo "Entries made for $MYSQL_DSN in csqlds.conf file."
41 $CSQL_INSTALL_ROOT/bin/csqlds -U $POSTGRES_USER -P $POSTGRES_PASSWORD -D $POSTGRES_DSN -N $POSTGRES_TDB -a
42 if [ $? -ne 0 ]
43 then
44 exit 2;
46 echo "Entries made for $POSTGRES_DSN in csqlds.conf file."
48 $CSQL_INSTALL_ROOT/bin/csqlds -U $DB2_USER -P $DB2_PASSWORD -D $DB2_DSN -N $DB2_TDB -a
49 if [ $? -ne 0 ]
50 then
51 exit 3;
53 echo "Entries made for $DB2_DSN in csqlds.conf file."
55 $CSQL_INSTALL_ROOT/bin/csqlds -U $ORACLE_USER -P $ORACLE_PASSWORD -D $ORACLE_DSN -N $ORACLE_TDB -a
56 if [ $? -ne 0 ]
57 then
58 exit 4;
60 echo "Entries made for $ORACLE_DSN in csqlds.conf file."
62 #drop teh table in all DSN if exists.
63 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
64 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
65 isql $DS3 < ${REL_PATH}/drop.sql >/dev/null 2>&1
66 isql $DS4 < ${REL_PATH}/drop.sql >/dev/null 2>&1
68 ####### Craete Table in all DSN #######
70 isql $DS1 < ${REL_PATH}/mysqltable.sql >/dev/null 2>&1
71 if [ $? -ne 0 ]
72 then
73 exit 5;
75 echo "Table 't1 and t2' is created in $MYSQL_DSN"
77 isql $DS2 < ${REL_PATH}/psqltable.sql >/dev/null 2>&1
78 if [ $? -ne 0 ]
79 then
80 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
81 exit 6;
83 echo "Table 't3 and t4' is created in $POSTGRES_DSN"
85 isql $DS3 < ${REL_PATH}/db2table.sql >/dev/null 2>&1
86 if [ $? -ne 0 ]
87 then
88 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
89 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
90 exit 7;
92 echo "Table 't5 and t6' is created in $DB2_DSN"
94 isql $DS4 < ${REL_PATH}/oracletable.sql >/dev/null 2>&1
95 if [ $? -ne 0 ]
96 then
97 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
98 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
99 isql $DS3 < ${REL_PATH}/drop.sql >/dev/null 2>&1
100 exit 8;
102 echo "Table 't7 and t8' is created in $ORACLE_DSN"
105 rm -f /tmp/csql/csqltable.conf
106 touch /tmp/csql/csqltable.conf
108 # Start teh csql server.
109 $CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 &
110 pid=$!
111 sleep 5
113 #### cache single table from DSNs #####
114 echo " "
116 echo "Cache t1 table from MySQL."
117 $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -d $MYSQL_DSN
118 if [ $? -ne 0 ]
119 then
120 kill -9 $pid
121 ipcrm -M 1199 -M 2277
122 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
123 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
124 isql $DS3 < ${REL_PATH}/drop.sql >/dev/null 2>&1
125 isql $DS4 < ${REL_PATH}/drop.sql >/dev/null 2>&1
126 exit 7;
129 echo "Cache t3 table from Postgres."
130 $CSQL_INSTALL_ROOT/bin/cachetable -t t3 -d $POSTGRES_DSN
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 isql $DS3 < ${REL_PATH}/drop.sql >/dev/null 2>&1
138 isql $DS4 < ${REL_PATH}/drop.sql >/dev/null 2>&1
139 exit 7;
142 echo "Cache t5 table from DB2."
143 $CSQL_INSTALL_ROOT/bin/cachetable -t t5 -d $DB2_DSN
144 if [ $? -ne 0 ]
145 then
146 kill -9 $pid
147 ipcrm -M 1199 -M 2277
148 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
149 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
150 isql $DS3 < ${REL_PATH}/drop.sql >/dev/null 2>&1
151 isql $DS4 < ${REL_PATH}/drop.sql >/dev/null 2>&1
152 exit 7;
155 echo "Cache t7 table from Oracle."
156 $CSQL_INSTALL_ROOT/bin/cachetable -t t7 -d $ORACLE_DSN
157 if [ $? -ne 0 ]
158 then
159 kill -9 $pid
160 ipcrm -M 1199 -M 2277
161 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
162 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
163 isql $DS3 < ${REL_PATH}/drop.sql >/dev/null 2>&1
164 isql $DS4 < ${REL_PATH}/drop.sql >/dev/null 2>&1
165 exit 7;
168 #### cache all the table from DSNs #####
169 echo " "
170 echo "Table from MySQL"
171 $CSQL_INSTALL_ROOT/bin/cachetable -d $MYSQL_DSN
172 if [ $? -ne 0 ]
173 then
174 kill -9 $pid
175 ipcrm -M 1199 -M 2277
176 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
177 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
178 isql $DS3 < ${REL_PATH}/drop.sql >/dev/null 2>&1
179 isql $DS4 < ${REL_PATH}/drop.sql >/dev/null 2>&1
180 exit 9;
183 echo " "
184 echo "Tables from Postgres"
185 $CSQL_INSTALL_ROOT/bin/cachetable -d $POSTGRES_DSN
186 if [ $? -ne 0 ]
187 then
188 kill -9 $pid
189 ipcrm -M 1199 -M 2277
190 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
191 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
192 isql $DS3 < ${REL_PATH}/drop.sql >/dev/null 2>&1
193 isql $DS4 < ${REL_PATH}/drop.sql >/dev/null 2>&1
194 exit 10;
197 echo " "
198 echo "Tables from DB2"
199 $CSQL_INSTALL_ROOT/bin/cachetable -d $DB2_DSN
200 if [ $? -ne 0 ]
201 then
202 kill -9 $pid
203 ipcrm -M 1199 -M 2277
204 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
205 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
206 isql $DS3 < ${REL_PATH}/drop.sql >/dev/null 2>&1
207 isql $DS4 < ${REL_PATH}/drop.sql >/dev/null 2>&1
208 exit 11;
211 echo " "
212 echo "Tables from Oracle"
213 $CSQL_INSTALL_ROOT/bin/cachetable -d $ORACLE_DSN
214 if [ $? -ne 0 ]
215 then
216 kill -9 $pid
217 ipcrm -M 1199 -M 2277
218 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
219 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
220 isql $DS3 < ${REL_PATH}/drop.sql >/dev/null 2>&1
221 isql $DS4 < ${REL_PATH}/drop.sql >/dev/null 2>&1
222 exit 12;
225 rm -f /tmp/csql/csqltable.conf
226 touch /tmp/csql/csqltable.conf
228 rm -f /tmp/csql/csqlds.conf
229 touch /tmp/csql/csqlds.conf
231 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
232 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
233 isql $DS3 < ${REL_PATH}/drop.sql >/dev/null 2>&1
234 isql $DS4 < ${REL_PATH}/drop.sql >/dev/null 2>&1
237 $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/drop.sql > /dev/null 2>&1
238 kill -9 $pid
239 ipcrm -M 1199 -M 2277
240 exit 0;