adding test scripts
[csql.git] / test / cache / Durability / test001.ksh
blob56e74bf1e9f4fa6f15313303f64b7b1b151c7f41
1 #!/bin/ksh
2 # Test Case
3 # Create table t1 in Target DB and insert 5 records in TDB.
4 # Cache t1 table using cachetable -t option
5 # Create table t2 at CSQL and insert 5 records
6 # Both Cached and Non-Cached tables should be durable
8 CSQL_CONF=${PWD}/cache/Durability/csql.conf
9 REL_PATH=.
10 if [ -s "$CSQL_CONF" ]
11 then
12 REL_PATH=${PWD}/cache/Durability
15 rm -f /tmp/csql.conf
16 cp $CSQL_CONFIG_FILE /tmp/csql.conf
17 export CSQL_CONFIG_FILE=/tmp/csql.conf
19 echo CACHE_TABLE=true >>$CSQL_CONFIG_FILE
20 echo DURABILITY=true >>$CSQL_CONFIG_FILE
21 echo DSN=$DSN >>$CSQL_CONFIG_FILE
22 echo SYS_DB_KEY=2288 >>$CSQL_CONFIG_FILE
23 echo USER_DB_KEY=3377 >>$CSQL_CONFIG_FILE
24 DS="$DSN $DBUSER $PASSWORD"
25 rm -f /tmp/csql/csqlds.conf /tmp/csql/csqltable.conf
26 touch /tmp/csql/csqlds.conf /tmp/csql/csqltable.conf
28 rm -rf /tmp/csql/db/*
29 mkdir -p /tmp/csql/db
31 $CSQL_INSTALL_ROOT/bin/csqlds -U $DBUSER -P $PASSWORD -D $DSN -N $TDB -a
32 if [ $? -ne 0 ]
33 then
34 exit 1;
37 echo INSERTING 5 RECORDS IN TARGET DB
38 isql $DS < ${REL_PATH}/create_insert_attdb.sql >/dev/null 2>&1
39 if [ $? -ne 0 ]
40 then
41 isql $DS < ${REL_PATH}/drop_t1.sql
42 exit 1;
45 isql $DS < ${REL_PATH}/select_t1.sql
46 if [ $? -ne 0 ]
47 then
48 isql $DS < ${REL_PATH}/drop_t1.sql
49 exit 2;
52 # Setup Environment For site
53 # RUN CSQL SERVER at site
54 $CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 &
55 pid=$!
56 sleep 10
58 echo "CACHING THROUGH SITE1"
59 echo "cachetable -U root -P manager -t t1"
60 $CSQL_INSTALL_ROOT/bin/cachetable -U root -P manager -t t1
61 if [ $? -ne 0 ]
62 then
63 kill -9 $pid
64 ipcrm -M 2288 -M 3377 -M 1947 -Q 2525
65 isql $DS < ${REL_PATH}/drop_t1.sql
66 exit 3;
69 $CSQL_INSTALL_ROOT/bin/csql -u root -p manager -s ${REL_PATH}/create_insert_at_csql.sql
70 if [ $? -ne 0 ]
71 then
72 kill -9 $pid
73 ipcrm -M 2288 -M 3377 -M 1947 -Q 2525
74 isql $DS < ${REL_PATH}/drop_t1.sql
75 $CSQL_INSTALL_ROOT/bin/cachetable -U root -P manager -t t1 -u
76 exit 4;
79 $CSQL_INSTALL_ROOT/bin/csqldump -X >before.sql
81 kill -9 $pid
82 ipcrm -M 2288 -M 3377 -M 1947 -Q 2525
83 echo "Server Killed"
85 echo ""
86 echo "Durablity = TRUE"
87 echo "Server Started"
88 $CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 &
89 pid=$!
90 sleep 10
91 echo "Checking Durability"
92 $CSQL_INSTALL_ROOT/bin/csqldump -X >after.sql
93 diff before.sql after.sql
94 if [ $? -eq 0 ]
95 then
96 echo Durability Works Fine
97 else
98 echo Durability Does Not work fine
101 $CSQL_INSTALL_ROOT/bin/cachetable -U root -P manager -t t1 -u
102 if [ $? -ne 0 ]
103 then
104 kill -9 $pid1
105 rm -f before.sql after.sql
106 rm -M 2288 -M 3377 -M 1947 -Q 2525
107 exit 5;
110 isql $DS < ${REL_PATH}/drop_t1.sql
111 if [ $? -ne 0 ]
112 then
113 kill -9 $pid1
114 rm -f before.sql after.sql
115 ipcrm -M 2288 -M 3377 -M 1947 -Q 2525
116 exit 6;
119 echo "drop table t2;" >${REL_PATH}/drop_t2.sql
120 $CSQL_INSTALL_ROOT/bin/csql -u root -p manager -s ${REL_PATH}/drop_t2.sql
122 rm -f ${REL_PATH}/drop_t2.sql
123 rm -f before.sql after.sql
124 rm -rf /tmp/site
125 kill -9 $pid
126 ipcrm -M 2288 -M 3377 -M 1947 -Q 2525
127 exit 0;