fixing timing issue in test script
[csql.git] / test / durability / recovery / testMMAP016.ksh
blob075a3c95cefc0577e257197bc7db586d6ab452a6
1 #!/bin/ksh
2 # Testing Durability in MMAP Architecture.
3 # set DURABILITY=true and MMAP=true in csql.conf
4 # Start csqlserver.
5 # Then create a table t1 in CSQL Client.
6 # Set MAX_SYS_DB_SIZE=10MB and MAX_DB_SIZE=100MB
7 # Create a table say t1 having 10k record with no index.
8 # Create a table say t1 having 10k record with UNIQUE HASH Index.
9 # Create a table say t1 having 10k record with UNIQUE TREE Index.
10 # Create a table say t1 having 10k record with PRIMARY KEY on INT field.
11 # Create a table say t1 having 10k record with PRIMARY KEY on CHAR field.
12 # kill the currently running Server.
13 # Restart the server.
14 # csqldump should dump the database with table and index information
16 CSQL_CONF=${PWD}/durability/recovery/csql.conf
17 REL_PATH=.
18 if [ -s "$CSQL_CONF" ]
19 then
20 REL_PATH=${PWD}/durability/recovery
23 i=1
24 while [[ $i -lt 6 ]];do
25 j=1
26 while [[ $j -lt 2001 ]];do
27 echo "INSERT INTO t$i VALUES($j,'LAKSHYA_CSQL$j');"
28 (( j +=1 ))
29 done >>${REL_PATH}/ins_t$i.sql
30 (( i +=1 ))
31 done
33 i=1
34 while [[ $i -lt 6 ]];do
35 echo "DROP TABLE t$i;"
36 (( i +=1 ))
37 done >>${REL_PATH}/drop_5table.sql
39 rm -f /tmp/csql.conf
40 rm -rf /tmp/csql/db
41 mkdir -p /tmp/csql/db
42 cp -f $REL_PATH/csql.conf /tmp
43 echo SYS_DB_KEY=5555 >>/tmp/csql.conf
44 echo USER_DB_KEY=7777 >>/tmp/csql.conf
45 echo MAX_SYS_DB_SIZE=10485760 >>/tmp/csql.conf
46 echo MAX_DB_SIZE=104857600 >>/tmp/csql.conf
47 echo DURABILITY=true >>/tmp/csql.conf
48 echo MMAP=true >>/tmp/csql.conf
49 export CSQL_CONFIG_FILE=/tmp/csql.conf
51 echo "Durablity = TRUE"
52 echo "Server Started"
53 $CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 &
54 pid=$!
55 sleep 3
57 $CSQL_INSTALL_ROOT/bin/csql -u root -p manager -s ${REL_PATH}/create_5teble.sql >/dev/null 2>&1
58 if [ $? -ne 0 ]
59 then
60 i=1
61 while [[ $i -lt 6 ]];do
62 rm -f ${REL_PATH}/ins_t$i.sql
63 (( i +=1 ))
64 done
65 rm -f ${REL_PATH}/drop_5table.sql
66 kill -9 $pid
67 ipcrm -M 5555
68 exit 1;
71 i=1
72 while [[ $i -lt 6 ]];do
73 $CSQL_INSTALL_ROOT/bin/csql -u root -p manager -s ${REL_PATH}/ins_t$i.sql >/dev/null 2>&1
74 (( i +=1 ))
75 done
76 if [ $? -ne 0 ]
77 then
78 i=1
79 while [[ $i -lt 6 ]];do
80 rm -f ${REL_PATH}/ins_t$i.sql
81 (( i+=1 ))
82 done
83 $CSQL_INSTALL_ROOT/bin/csql -u root -p manager -s ${REL_PATH}/drop_5table.sql
84 rm -f ${REL_PATH}/drop_5table.sql
85 kill -9 $pid
86 ipcrm -M 5555
87 exit 2;
89 $CSQL_INSTALL_ROOT/bin/csqldump >${REL_PATH}/before.sql
90 sleep 10
91 kill -9 $pid
92 ipcrm -M 5555
93 echo "Server Killed"
94 echo ""
95 echo DURABILITY=true >>/tmp/csql.conf
96 echo "Checking Durability"
97 $CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 &
98 if [ $? -ne 0 ]
99 then
100 echo "Server could not be Started"
101 rm -rf /tmp/csql/db
102 mkdir -p /tmp/csql/db
104 while [[ $i -lt 6 ]];do
105 rm -f ${REL_PATH}/ins_t$i.sql
106 (( i +=1 ))
107 done
109 $CSQL_INSTALL_ROOT/bin/csql -u root -p manager -s ${REL_PATH}/drop_5table.sql
110 rm -f ${REL_PATH}/drop_5table.sql
111 kill -9 $pid
112 ipcrm -M 5555
113 exit 4;
115 pid=$!
116 echo "Server Started"
117 sleep 30
119 $CSQL_INSTALL_ROOT/bin/csqldump >${REL_PATH}/after.sql
120 echo ""
121 sleep 1
122 diff ${REL_PATH}/before.sql ${REL_PATH}/after.sql
123 if [ $? -eq 0 ]
124 then
125 echo Durability Works Fine
129 while [[ $i -lt 6 ]];do
130 rm -f ${REL_PATH}/ins_t$i.sql
131 (( i +=1 ))
132 done
133 $CSQL_INSTALL_ROOT/bin/csql -u root -p manager -s ${REL_PATH}/drop_5table.sql
134 rm -f ${REL_PATH}/drop_5table.sql
135 kill -9 $pid
136 ipcrm -M 5555
137 exit 0;