adding test scripts
[csql.git] / test / cache / MultiDsn / CacheToolOpts / test003.ksh
blobec41aee8f8ce523812b90b59b5985cff10a7d9ba
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 # in a range of MySQL,Postgres,DB2 and Oracle.
10 # Use "cachetable -d <dsnName>" to cache all the tables from a specific DSN.
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
33 ########## csqlds.conf entries #########
35 $CSQL_INSTALL_ROOT/bin/csqlds -U $MYSQL_USER -P $MYSQL_PASSWORD -D $MYSQL_DSN -N $MYSQL_TDB -a
36 if [ $? -ne 0 ]
37 then
38 exit 1;
40 echo "Entries made for $MYSQL_DSN in csqlds.conf file."
42 $CSQL_INSTALL_ROOT/bin/csqlds -U $POSTGRES_USER -P $POSTGRES_PASSWORD -D $POSTGRES_DSN -N $POSTGRES_TDB -a
43 if [ $? -ne 0 ]
44 then
45 exit 2;
47 echo "Entries made for $POSTGRES_DSN in csqlds.conf file."
49 $CSQL_INSTALL_ROOT/bin/csqlds -U $DB2_USER -P $DB2_PASSWORD -D $DB2_DSN -N $DB2_TDB -a
50 if [ $? -ne 0 ]
51 then
52 exit 3;
54 echo "Entries made for $DB2_DSN in csqlds.conf file."
56 $CSQL_INSTALL_ROOT/bin/csqlds -U $ORACLE_USER -P $ORACLE_PASSWORD -D $ORACLE_DSN -N $ORACLE_TDB -a
57 if [ $? -ne 0 ]
58 then
59 exit 4;
61 echo "Entries made for $ORACLE_DSN in csqlds.conf file."
63 #drop teh table in all DSN if exists.
64 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
65 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
66 isql $DS3 < ${REL_PATH}/drop.sql >/dev/null 2>&1
67 isql $DS4 < ${REL_PATH}/drop.sql >/dev/null 2>&1
70 ####### Craete Table in all DSN #######
72 isql $DS1 < ${REL_PATH}/mysqltable.sql >/dev/null 2>&1
73 if [ $? -ne 0 ]
74 then
75 exit 5;
77 echo "Table 't1 and t2' is created in $MYSQL_DSN"
79 isql $DS2 < ${REL_PATH}/psqltable.sql >/dev/null 2>&1
80 if [ $? -ne 0 ]
81 then
82 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
83 exit 6;
85 echo "Table 't3 and t4' is created in $POSTGRES_DSN"
87 isql $DS3 < ${REL_PATH}/db2table.sql >/dev/null 2>&1
88 if [ $? -ne 0 ]
89 then
90 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
91 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
92 exit 7;
94 echo "Table 't5 and t6' is created in $DB2_DSN"
96 isql $DS4 < ${REL_PATH}/oracletable.sql >/dev/null 2>&1
97 if [ $? -ne 0 ]
98 then
99 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
100 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
101 isql $DS3 < ${REL_PATH}/drop.sql >/dev/null 2>&1
102 exit 8;
104 echo "Table 't7 and t8' is created in $ORACLE_DSN"
107 rm -f /tmp/csql/csqltable.conf
108 touch /tmp/csql/csqltable.conf
110 # Start teh csql server.
111 $CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 &
112 pid=$!
113 sleep 5
115 #### cache all the table from DSNs #####
116 echo " "
117 echo "Table from MySQL"
118 $CSQL_INSTALL_ROOT/bin/cachetable -d $MYSQL_DSN
119 if [ $? -ne 0 ]
120 then
121 kill -9 $pid
122 ipcrm -M 1199 -M 2277
123 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
124 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
125 isql $DS3 < ${REL_PATH}/drop.sql >/dev/null 2>&1
126 isql $DS4 < ${REL_PATH}/drop.sql >/dev/null 2>&1
127 exit 9;
129 sleep 2
131 echo " "
132 echo "Tables from Postgres"
133 $CSQL_INSTALL_ROOT/bin/cachetable -d $POSTGRES_DSN
134 if [ $? -ne 0 ]
135 then
136 kill -9 $pid
137 ipcrm -M 1199 -M 2277
138 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
139 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
140 isql $DS3 < ${REL_PATH}/drop.sql >/dev/null 2>&1
141 isql $DS4 < ${REL_PATH}/drop.sql >/dev/null 2>&1
142 exit 10;
144 sleep 2
146 echo " "
147 echo "Tables from DB2"
148 $CSQL_INSTALL_ROOT/bin/cachetable -d $DB2_DSN
149 if [ $? -ne 0 ]
150 then
151 kill -9 $pid
152 ipcrm -M 1199 -M 2277
153 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
154 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
155 isql $DS3 < ${REL_PATH}/drop.sql >/dev/null 2>&1
156 isql $DS4 < ${REL_PATH}/drop.sql >/dev/null 2>&1
157 exit 11;
159 sleep 2
161 echo " "
162 echo "Tables from Oracle"
163 $CSQL_INSTALL_ROOT/bin/cachetable -d $ORACLE_DSN
164 if [ $? -ne 0 ]
165 then
166 kill -9 $pid
167 ipcrm -M 1199 -M 2277
168 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
169 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
170 isql $DS3 < ${REL_PATH}/drop.sql >/dev/null 2>&1
171 isql $DS4 < ${REL_PATH}/drop.sql >/dev/null 2>&1
172 exit 12;
174 sleep 2
176 #### Now use "cachetable -l <dsName>" ####
178 $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/showtables.sql
180 rm -f /tmp/csql/csqltable.conf
181 touch /tmp/csql/csqltable.conf
183 rm -f /tmp/csql/csqlds.conf
184 touch /tmp/csql/csqlds.conf
186 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
187 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
188 isql $DS3 < ${REL_PATH}/drop.sql >/dev/null 2>&1
189 isql $DS4 < ${REL_PATH}/drop.sql >/dev/null 2>&1
192 $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/drop.sql > /dev/null 2>&1
193 kill -9 $pid
194 ipcrm -M 1199 -M 2277
195 exit 0;