adding test scripts
[csql.git] / test / cache / MultiDsn / CacheToolOpts / test001.ksh
blobc369a417973431572fe340631a84fd3fdef70781
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 teh tables from DSNs.
8 # Use "cachetable -l <dsnName>" to get the cached tables
9 # present in the specified DSN.
11 # Run this test only under cql/test or on this directory,
12 # Otherwise it will fail.
15 input=${PWD}/cache/MultiDsn/CacheToolOptions/mysqltable.sql
16 REL_PATH=.
17 if [ -s "$input" ]
18 then
19 REL_PATH=${PWD}/cache/MultiDsn/CacheToolOptions
22 rm -f /tmp/csql.conf
23 cp -f $REL_PATH/csql.conf /tmp
24 export CSQL_CONFIG_FILE=/tmp/csql.conf
26 echo DSN=$MYSQL_DSN >>$CSQL_CONFIG_FILE
28 rm -f /tmp/csql/csqlds.conf
29 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 #drop teh table in all DSN if exists.
49 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
50 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
53 ####### Craete Table in all DSN #######
55 isql $DS1 < ${REL_PATH}/mysqltable.sql >/dev/null 2>&1
56 if [ $? -ne 0 ]
57 then
58 exit 5;
60 echo "Table 't1 and t2' is created in $MYSQL_DSN"
62 isql $DS2 < ${REL_PATH}/psqltable.sql >/dev/null 2>&1
63 if [ $? -ne 0 ]
64 then
65 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
66 exit 6;
68 echo "Table 't3 and t4' is created in $POSTGRES_DSN"
70 rm -f /tmp/csql/csqltable.conf
71 touch /tmp/csql/csqltable.conf
73 # Start teh csql server.
74 $CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 &
75 pid=$!
76 sleep 5
78 #### cache all the table from DSNs #####
79 for a in 1 2
81 $CSQL_INSTALL_ROOT/bin/cachetable -t t$a -d $MYSQL_DSN
82 if [ $? -ne 0 ]
83 then
84 kill -9 $pid
85 ipcrm -M 1199 -M 2277
86 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
87 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
88 exit 7;
90 sleep 2
91 done
93 for a in 3 4
95 $CSQL_INSTALL_ROOT/bin/cachetable -t t$a -d $POSTGRES_DSN
96 if [ $? -ne 0 ]
97 then
98 kill -9 $pid
99 ipcrm -M 1199 -M 2277
100 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
101 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
102 exit 8;
104 sleep 2
105 done
107 #### Now use "cachetable -l <dsName>" ####
109 echo "Tables in $MYSQL_DSN"
110 $CSQL_INSTALL_ROOT/bin/cachetable -l $MYSQL_DSN
111 if [ $? -ne 0 ]
112 then
113 kill -9 $pid
114 ipcrm -M 1199 -M 2277
115 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
116 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
117 exit 9;
120 echo "Tables in $POSTGRES_DSN"
121 $CSQL_INSTALL_ROOT/bin/cachetable -l $POSTGRES_DSN
122 if [ $? -ne 0 ]
123 then
124 kill -9 $pid
125 ipcrm -M 1199 -M 2277
126 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
127 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
128 exit 10;
131 rm -f /tmp/csql/csqltable.conf
132 touch /tmp/csql/csqltable.conf
134 rm -f /tmp/csql/csqlds.conf
135 touch /tmp/csql/csqlds.conf
137 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
138 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
140 $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/drop.sql > /dev/null 2>&1
141 kill -9 $pid
142 ipcrm -M 1199 -M 2277
143 exit 0;