adding test scripts
[csql.git] / test / cache / MultiDsn / CacheToolOpts / test002.ksh
blob7f0f5e2f480f27b9ab140e60391befb5c5d40b10
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 "csqlds -d " to get the DS names which are present in "csqlds.conf" file.
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/csqlds -U root -P manager -e
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 rm -f /tmp/csql/csqltable.conf
121 touch /tmp/csql/csqltable.conf
123 rm -f /tmp/csql/csqlds.conf
124 touch /tmp/csql/csqlds.conf
126 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
127 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
129 $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/drop.sql > /dev/null 2>&1
130 kill -9 $pid
131 ipcrm -M 1199 -M 2277
132 exit 0;