adding test scripts
[csql.git] / test / cache / CacheTable / test044.ksh
blob52cc1f64cc3a40e54ef40728659d82dcbfcd9654
1 #!/bin/ksh
2 # Test Case
4 # Bi-directional cache test, Describe with -S option.
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: Jitendra
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;
31 echo "create table t1(f1 int unique,f2 char(12),f3 int,f4 int,primary key(f2));">$REL_PATH/t1.sql
32 if [ $DSN = "db2" ]
33 then
34 echo "create table t1(f1 int not null unique,f2 char(12) not null ,f3 int,f4 int,primary key(f2));">$REL_PATH/t1.sql
36 for a in 1 2 3 4 5 6 7 8 9
38 echo "insert into t1 values($a,'papu',12,$a+123124);"
39 done>>t1.sql
40 isql $DS < $REL_PATH/t1.sql >/dev/null 2>&1
41 if [ $? -ne 0 ]
42 then
43 echo "unable to create in target db"
44 rm -f $REL_PATH/t1.sql
45 exit 1
48 echo "drop table t1;">${REL_PATH}/dt1.sql
49 rm -f /tmp/csql/csqltable.conf
50 touch /tmp/csql/csqltable.conf
52 $CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 &
53 pid=$!
54 sleep 5
55 echo "server started"
56 echo "=========================== cachetable -t t1 -c \"f1>12\" -f \"f1,f2\" -p f1 =======================================";
57 if [ "$DSN" = "oracle" -o "$DSN" = "sybase" -o "$DSN" = "db2" ]
58 then
60 $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -c "f1>12" -f "f1,f2" -p f1 -F >/dev/null 2>&1
61 if [ $? -ne 0 ]
62 then
63 echo "Unable to cache"
64 isql $DS <${REL_PATH}/dt1.sql >/dev/null 2>&1
65 rm -f $REL_PATH/t1.sql ${REL_PATH}/dt1.sql
66 kill -9 $pid
67 ipcrm -M 4000 -M 4500
68 exit 2
71 else
73 $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -c "f1>12" -f "f1,f2" -p f1 >/dev/null 2>&1
74 if [ $? -ne 0 ]
75 then
76 echo "Unable to cache"
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 ipcrm -M 4000 -M 4500
81 exit 3
86 $CSQL_INSTALL_ROOT/bin/cachetable -S
87 if [ $? -ne 0 ]
88 then
89 echo "Unable to cache"
90 isql $DS <${REL_PATH}/dt1.sql >/dev/null 2>&1
91 rm -f $REL_PATH/t1.sql ${REL_PATH}/dt1.sql
92 kill -9 $pid
93 ipcrm -M 4000 -M 4500
94 exit 4
97 $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u
98 isql $DS <${REL_PATH}/dt1.sql >/dev/null 2>&1
99 rm -f /tmp/csql/csqltable.conf
100 touch /tmp/csql/csqltable.conf
101 rm -f $REL_PATH/t1.sql ${REL_PATH}/dt1.sql
102 kill -9 $pid
103 ipcrm -M 4000 -M 4500
104 exit 0;