adding test scripts
[csql.git] / test / cache / CacheTable / test040.ksh
blob407bef69b0af57436ade2323be1db92f46534a36
1 #!/bin/ksh
2 # Test Case
4 # Bi-directional cache test
5 # Create table t1 with field f1 int ,f2 char,f3 smallint , f4 bigint primary key(f1) . Make bidirectional flag and cache flag true. Cache the table with cachetable -t t1 -f f1,f2 it should pass
7 # Author:=bijaya
10 input=${PWD}/cache/CacheTable/csql1.conf
12 REL_PATH=.
13 if [ -s "$input" ]
14 then
15 REL_PATH=${PWD}/cache/CacheTable
17 rm -f /tmp/csql1.conf
18 cp $REL_PATH/csql1.conf /tmp
19 export CSQL_CONFIG_FILE=/tmp/csql1.conf
20 echo DSN=$DSN >>$CSQL_CONFIG_FILE
21 DS="$DSN $DBUSER $PASSWORD"
22 rm -f /tmp/csql/csqlds.conf
23 touch /tmp/csql/csqlds.conf
24 $CSQL_INSTALL_ROOT/bin/csqlds -U $DBUSER -P $PASSWORD -D $DSN -N $TDB -a
25 if [ $? -ne 0 ]
26 then
27 exit 1;
30 echo $DS
31 echo "create table t1(f1 int ,f2 char(12),f3 smallint ,f4 int,primary key(f1));">$REL_PATH/t1.sql
32 if [ $DSN = "db2" ]
33 then
34 echo "create table t1(f1 int NOT NULL ,f2 char(12),f3 smallint ,f4 int,primary key(f1));">$REL_PATH/t1.sql
37 for a in 1 2 3 4 5 6 7 8 9
39 echo "insert into t1 values($a,'papu',12,$a+123124);"
40 done>>t1.sql
41 isql $DS < $REL_PATH/t1.sql >/dev/null 2>&1
42 if [ $? -ne 0 ]
43 then
44 echo "unable to creste in target db"
45 rm -f $REL_PATH/t1.sql
46 exit 1
49 echo "drop table t1;">${REL_PATH}/dt1.sql
50 rm -f /tmp/csql/csqltable.conf
51 touch /tmp/csql/csqltable.conf
53 $CSQL_INSTALL_ROOT/bin/csqlserver &
54 #>/dev/null 2>&1 &
55 pid=$!
56 sleep 5
57 echo "server started"
58 $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -f f1,f2,f3
59 if [ $? -ne 0 ]
60 then
61 echo "Unable to cache"
62 isql $DS <${REL_PATH}/dt1.sql >/dev/null 2>&1
63 rm -f $REL_PATH/t1.sql ${REL_PATH}/dt1.sql
64 kill -9 $pid
65 kill `ps -e | grep csqlcacheserver | gawk -F" " '{ print $1 }'`
66 ipcrm -M 4000 -M 4500
67 exit 2
69 echo "table cached and the test script passed"
70 $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u
71 isql $DS <${REL_PATH}/dt1.sql >/dev/null 2>&1
72 rm -f /tmp/csql/csqltable.conf
73 touch /tmp/csql/csqltable.conf
74 rm -f $REL_PATH/t1.sql ${REL_PATH}/dt1.sql
75 kill -9 $pid
76 kill `ps -e | grep csqlcacheserver | gawk -F" " '{ print $1 }'`
77 ipcrm -M 4000 -M 4500
78 exit 0;