adding test scripts
[csql.git] / test / cache / CacheTable / test042.ksh
blob01eac2604e94b38b48ff539ff70a5c8ce7a381bd
1 #!/bin/ksh
2 # Test Case
4 # Bi-directional cache test
5 # Create table t1 with field create table t1(f1 int unique,f2 char(12),f3 smallint , f4 bigint,primary key(f2));. Make bidirectional flag and cache flag true. Cache the table with cachetable -t t1 -f f1,f3,f4 -p f1 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;
29 if [ "$DSN" = "oracle" ]
30 then
31 echo "create table t1(f1 integer unique, f2 char(12), f3 smallint , f4 number(18), primary key(f2));">$REL_PATH/t1.sql
32 else
33 echo "create table t1(f1 int unique,f2 char(12),f3 smallint , f4 bigint,primary key(f2));">$REL_PATH/t1.sql
35 if [ $DSN = "db2" ]
36 then
37 echo "create table t1(f1 int not null unique,f2 char(12) not null,f3 smallint , f4 bigint,primary key(f2));">$REL_PATH/t1.sql
39 for a in 1 2 3 4 5 6 7 8 9
41 echo "insert into t1 values($a,'papu',12,123124);"
42 done>>t1.sql
43 isql $DS < $REL_PATH/t1.sql >/dev/null 2>&1
44 if [ $? -ne 0 ]
45 then
46 echo "unable to create in target db"
47 rm -f $REL_PATH/t1.sql
48 exit 2
51 echo "drop table t1;">${REL_PATH}/dt1.sql
52 rm -f /tmp/csql/csqltable.conf
53 touch /tmp/csql/csqltable.conf
55 $CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 &
56 pid=$!
57 sleep 5
58 echo "server started"
59 if [ $DSN = "oracle" -o "$DSN" = "sybase" -o "$DSN" = "db2" ]
60 then
61 $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -f f1,f3,f4 -p f1 -F
62 if [ $? -eq 0 ]
63 then
64 echo "Table cached test script passed"
65 isql $DS <${REL_PATH}/dt1.sql >/dev/null 2>&1
66 rm -f $REL_PATH/t1.sql ${REL_PATH}/dt1.sql
67 kill -9 $pid
68 kill `ps -e | grep csqlcacheserver | gawk -F" " '{ print $1 }'`
69 ipcrm -M 4000 -M 4500
70 exit 0;
72 else
73 $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -f f1,f3,f4 -p f1
74 if [ $? -eq 0 ]
75 then
76 echo "Table cached test script passed"
77 isql $DS <${REL_PATH}/dt1.sql >/dev/null 2>&1
78 rm -f $REL_PATH/t1.sql ${REL_PATH}/dt1.sql
79 kill -9 $pid
80 kill `ps -e | grep csqlcacheserver | gawk -F" " '{ print $1 }'`
81 ipcrm -M 4000 -M 4500
82 exit 0;
85 echo "Table not cached test script failed"
86 isql $DS <${REL_PATH}/dt1.sql >/dev/null 2>&1
87 rm -f /tmp/csql/csqltable.conf
88 touch /tmp/csql/csqltable.conf
89 rm -f $REL_PATH/t1.sql ${REL_PATH}/dt1.sql
90 kill `ps -e | grep csqlcacheserver | gawk -F" " '{ print $1 }'`
91 kill -9 $pid
92 ipcrm -M 4000 -M 4500
93 exit 3;