adding test scripts
[csql.git] / test / cache / Durability / test002.ksh
blob1788f39916472a6c3562e3ffabfb1e7f442ebbe3
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 # Do all DML Operations in both cached as well as non-cached tables.
7 # Both Cached and Non-Cached tables should be durable, and The data Should be Consistent
8 #
9 CSQL_CONF=${PWD}/cache/Durability/csql.conf
10 REL_PATH=.
11 if [ -s "$CSQL_CONF" ]
12 then
13 REL_PATH=${PWD}/cache/Durability
16 rm -f /tmp/csql.conf
17 cp $CSQL_CONFIG_FILE /tmp/csql.conf
18 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 # CSQL Configuration
38 echo INSERTING 5 RECORDS IN TARGET DB
39 isql $DS < ${REL_PATH}/create_insert_attdb.sql >/dev/null 2>&1
40 if [ $? -ne 0 ]
41 then
42 isql $DS < ${REL_PATH}/drop_t1.sql
43 exit 1;
46 isql $DS < ${REL_PATH}/select_t1.sql
47 if [ $? -ne 0 ]
48 then
49 isql $DS < ${REL_PATH}/drop_t1.sql
50 exit 2;
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 >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 >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
100 #Insertion in cached table at csql
101 echo INSERTING 5 RECORDS IN CACHED TABLE t1 AT CSQL
102 $CSQL_INSTALL_ROOT/bin/csql -g -u root -p manager -s ${REL_PATH}/insert5_atsite1.sql
103 if [ $? -ne 0 ]
104 then
105 kill -9 $pid
106 ipcrm -M 2288 -M 3377 -M 1947 -Q 2525
107 isql $DS < ${REL_PATH}/drop_t1.sql
108 $CSQL_INSTALL_ROOT/bin/cachetable -U root -P manager -t t1 -u
109 exit 5;
112 echo INSERTING 5 RECORDS AT NON CACHED TABLE t2 AT CSQL
113 $CSQL_INSTALL_ROOT/bin/csql -u root -p manager -s ${REL_PATH}/noncached_insert_t2.sql
114 if [ $? -ne 0 ]
115 then
116 kill -9 $pid
117 ipcrm -M 2288 -M 3377 -M 1947 -Q 2525
118 isql $DS < ${REL_PATH}/drop_t1.sql
119 $CSQL_INSTALL_ROOT/bin/cachetable -U root -P manager -t t1 -u
120 exit 6;
123 $CSQL_INSTALL_ROOT/bin/csqldump >before.sql
125 kill -9 $pid
126 ipcrm -M 2288 -M 3377 -M 1947 -Q 2525
127 echo "Server Killed"
128 echo ""
129 echo "Durablity = TRUE"
130 echo "Server Started"
131 $CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 &
132 pid=$!
133 sleep 10
134 echo "Checking Durability"
135 $CSQL_INSTALL_ROOT/bin/csqldump >after.sql
136 diff before.sql after.sql
137 if [ $? -eq 0 ]
138 then
139 echo Durability Works Fine
140 else
141 echo Durability Does Not work fine
144 #Updation in cached table at csql
145 echo UPDATING 5 RECORDS IN CACHED TABLE t1 AT CSQL
146 $CSQL_INSTALL_ROOT/bin/csql -g -u root -p manager -s ${REL_PATH}/update5_atsite1.sql
147 if [ $? -ne 0 ]
148 then
149 kill -9 $pid
150 ipcrm -M 2288 -M 3377 -M 1947 -Q 2525
151 isql $DS < ${REL_PATH}/drop_t1.sql
152 $CSQL_INSTALL_ROOT/bin/cachetable -U root -P manager -t t1 -u
153 exit 7;
156 echo UPDATING 5 RECORDS AT NON CACHED TABLE t2 AT CSQL
157 $CSQL_INSTALL_ROOT/bin/csql -u root -p manager -s ${REL_PATH}/noncached_update_t2.sql
158 if [ $? -ne 0 ]
159 then
160 kill -9 $pid
161 ipcrm -M 2288 -M 3377 -M 1947 -Q 2525
162 isql $DS < ${REL_PATH}/drop_t1.sql
163 $CSQL_INSTALL_ROOT/bin/cachetable -U root -P manager -t t1 -u
164 exit 8;
167 $CSQL_INSTALL_ROOT/bin/csqldump >before.sql
169 kill -9 $pid
170 ipcrm -M 2288 -M 3377 -M 1947 -Q 2525
171 echo "Server Killed"
173 echo ""
174 echo "Durablity = TRUE"
175 echo "Server Started"
176 $CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 &
177 pid=$!
178 sleep 10
179 echo "Checking Durability"
180 $CSQL_INSTALL_ROOT/bin/csqldump >after.sql
181 diff before.sql after.sql
182 if [ $? -eq 0 ]
183 then
184 echo Durability Works Fine
185 else
186 echo Durability Does Not work fine
189 #Deletion in cached table at csql
190 echo DELETING 7 RECORDS IN CACHED TABLE t1 AT CSQL
191 $CSQL_INSTALL_ROOT/bin/csql -g -u root -p manager -s ${REL_PATH}/delete7_atsite1.sql
192 if [ $? -ne 0 ]
193 then
194 kill -9 $pid
195 ipcrm -M 2288 -M 3377 -M 1947 -Q 2525
196 isql $DS < ${REL_PATH}/drop_t1.sql
197 $CSQL_INSTALL_ROOT/bin/cachetable -U root -P manager -t t1 -u
198 exit 9;
201 echo DELETING 7 RECORDS AT NON CACHED TABLE t2 AT CSQL
202 $CSQL_INSTALL_ROOT/bin/csql -u root -p manager -s ${REL_PATH}/noncached_delete_t2.sql
203 if [ $? -ne 0 ]
204 then
205 kill -9 $pid
206 ipcrm -M 2288 -M 3377 -M 1947 -Q 2525
207 isql $DS < ${REL_PATH}/drop_t1.sql
208 $CSQL_INSTALL_ROOT/bin/cachetable -U root -P manager -t t1 -u
209 exit 10;
212 $CSQL_INSTALL_ROOT/bin/csqldump >before.sql
214 kill -9 $pid
215 ipcrm -M 2288 -M 3377 -M 1947 -Q 2525
216 echo "Server Killed"
218 echo ""
219 echo "Durablity = TRUE"
220 echo "Server Started"
221 $CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 &
222 pid=$!
223 sleep 10
224 echo "Checking Durability"
225 $CSQL_INSTALL_ROOT/bin/csqldump >after.sql
226 diff before.sql after.sql
227 if [ $? -eq 0 ]
228 then
229 echo Durability Works Fine
230 else
231 echo Durability Does Not work fine
234 #export CSQL_CONFIG_FILE=/tmp/site/csql.conf
235 $CSQL_INSTALL_ROOT/bin/cachetable -U root -P manager -t t1 -u
236 if [ $? -ne 0 ]
237 then
238 kill -9 $pid1
239 rm -f before.sql after.sql
240 rm -M 2288 -M 3377 -M 1947 -Q 2525
241 exit 11;
244 isql $DS < ${REL_PATH}/drop_t1.sql
245 if [ $? -ne 0 ]
246 then
247 kill -9 $pid1
248 rm -f before.sql after.sql
249 ipcrm -M 2288 -M 3377 -M 1947 -Q 2525
250 exit 12;
253 echo "drop table t2;" >${REL_PATH}/drop_t2.sql
254 $CSQL_INSTALL_ROOT/bin/csql -u root -p manager -s ${REL_PATH}/drop_t2.sql
256 rm -f ${REL_PATH}/drop_t2.sql
257 rm -f before.sql after.sql
258 rm -rf /tmp/site
259 kill -9 $pid
260 ipcrm -M 2288 -M 3377 -M 1947 -Q 2525
261 exit 0;