adding test scripts
[csql.git] / test / cache / CacheTable / test037.ksh
blob79c67de7ab5bebf5bbb9904167d84a806e0ead32
1 #!/bin/ksh
2 # Test Case
4 # Bi-directional cache test
5 # Create table t1 with field f1 int unique ,f2 char,f3 smallint , f4 bigint . Make bidirectional flag and cache flag true. Cache the table with cachetable -t t1 -f f1,f2,f3 -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;
30 echo "create table t1(f1 int unique,f2 char(12),f3 smallint , f4 int);">$REL_PATH/t1.sql
31 if [ $DSN = "db2" ]
32 then
33 echo "create table t1(f1 int ,f2 char(12),f3 smallint , f4 int);">$REL_PATH/t1.sql
35 for a in 1 2 3 4 5 6 7 8 9
37 echo "insert into t1 values($a,'papu',12,$a+123124);"
38 done>>t1.sql
39 isql $DS < $REL_PATH/t1.sql >/dev/null 2>&1
40 if [ $? -ne 0 ]
41 then
42 echo "unable to create in target db"
43 rm -f $REL_PATH/t1.sql
44 exit 1
47 echo "drop table t1;">${REL_PATH}/dt1.sql
48 rm -f /tmp/csql/csqltable.conf
49 touch /tmp/csql/csqltable.conf
51 $CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 &
52 pid=$!
53 sleep 5
54 echo "server started"
55 if [ "$DSN" = "oracle" -o "$DSN" = "sybase" -o "$DSN" = "db2" ]
56 then
57 $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -p f1 -F
58 if [ $? -ne 0 ]
59 then
60 echo "Unable to cache"
61 isql $DS <${REL_PATH}/dt1.sql >/dev/null 2>&1
62 rm -f $REL_PATH/t1.sql ${REL_PATH}/dt1.sql
63 kill -9 $pid
64 ipcrm -M 4000 -M 4500
65 exit 2
67 else
68 $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -p f1
69 if [ $? -ne 0 ]
70 then
71 echo "Unable to cache"
72 isql $DS <${REL_PATH}/dt1.sql >/dev/null 2>&1
73 rm -f $REL_PATH/t1.sql ${REL_PATH}/dt1.sql
74 kill -9 $pid
75 ipcrm -M 4000 -M 4500
76 exit 3
79 isql $DS <${REL_PATH}/dt1.sql >/dev/null 2>&1
80 rm -f /tmp/csql/csqltable.conf
81 touch /tmp/csql/csqltable.conf
82 rm -f $REL_PATH/t1.sql ${REL_PATH}/dt1.sql
83 kill -9 $pid
84 ipcrm -M 4000 -M 4500
85 exit 0;