adding test scripts
[csql.git] / test / cache / CacheTable / test046.ksh
blob7c381b892d9249dedff0d22a02589e0be7d9803c
1 #!/bin/ksh
2 # Test Case
3 # Create table t1 in Target DB with 3 fields say (f1 int, f2 smallint, f3 int).
4 # Create composite index on f1 and f3 field.
5 # Set CACHE_TABLE=true in csql.conf
6 # Cache the table t1
7 # She Catalog tool displays the composite key index informations or not
9 CSQL_CONF=${PWD}/cache/CacheTable/csql.conf
10 REL_PATH=.
11 if [ -s "$CSQL_CONF" ]
12 then
13 REL_PATH=${PWD}/cache/CacheTable
16 rm -f /tmp/csql.conf
17 cp $REL_PATH/csql.conf /tmp
18 export CSQL_CONFIG_FILE=/tmp/csql.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 # Site1 Configuration
31 mkdir -p /tmp/CSQL
32 mkdir -p /tmp/CSQL/log
33 mkdir -p /tmp/CSQL/log/csql
34 mkdir -p /tmp/CSQL
35 mkdir -p /tmp/CSQL/db
36 cp /tmp/csql.conf /tmp/CSQL/
37 echo SYS_DB_KEY=2288 >>/tmp/CSQL/csql.conf
38 echo USER_DB_KEY=3377 >>/tmp/CSQL/csql.conf
39 echo LOG_FILE=/tmp/CSQL/log/csql/log.out >>/tmp/CSQL/csql.conf
40 echo DATABASE_FILE=/tmp/CSQL/db >>/tmp/CSQL/csql.conf
41 echo CACHE_TABLE=true >>/tmp/CSQL/csql.conf
42 echo SITE_ID=1 >>/tmp/CSQL/csql.conf
43 echo TABLE_CONFIG_FILE=/tmp/CSQL/csqltable.conf >>/tmp/CSQL/csql.conf
44 sleep 2
45 echo CREATING TABLE t1 and INSERTING 1 RECORDS IN TARGET DB
46 echo "CREATE TABLE t1(f1 int, f2 smallint, f3 int);" >${REL_PATH}/t1create_compo.sql
47 echo "CREATE INDEX idx1 on t1(f1,f3)" >>${REL_PATH}/t1create_compo.sql
49 isql $DS < ${REL_PATH}/t1create_compo.sql
50 if [ $? -ne 0 ]
51 then
52 rm -f ${REL_PATH}/t1create_compo.sql
53 isql $DS < ${REL_PATH}/drop_t1.sql
54 exit 1;
57 # Setup Environment For CSQL
58 export CSQL_CONFIG_FILE=/tmp/CSQL/csql.conf
59 rm -f /tmp/CSQL/csqltable.conf
60 touch /tmp/CSQL/csqltable.conf
62 # RUN CSQL SERVER at CSQL
63 $CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 &
64 pid1=$!
65 sleep 2
67 $CSQL_INSTALL_ROOT/bin/cachetable -t t1
68 if [ $? -ne 0 ]
69 then
70 rm -f ${REL_PATH}/t1create_compo.sql
71 isql $DS < ${REL_PATH}/drop_t1.sql
72 ipcrm -M 2288 -M 3377
73 exit 2;
76 $CSQL_INSTALL_ROOT/bin/catalog -l
77 if [ $? -ne 0 ]
78 then
79 $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u
80 rm -f ${REL_PATH}/t1create_compo.sql
81 isql $DS < ${REL_PATH}/drop_t1.sql
82 ipcrm -M 2288 -M 3377
83 exit 3;
86 $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u
87 if [ $? -ne 0 ]
88 then
89 rm -f ${REL_PATH}/t1create_compo.sql
90 isql $DS < ${REL_PATH}/drop_t1.sql
91 ipcrm -M 2288 -M 3377
92 exit 4;
95 isql $DS < ${REL_PATH}/drop_t1.sql
96 if [ $? -ne 0 ]
97 then
98 kill -9 $pid1
99 ipcrm -M 2288 -M 3377
100 exit 5;
103 rm -rf /tmp/CSQL
104 kill -9 $pid1
105 ipcrm -M 2288 -M 3377
106 exit 0;