3 ################### Settings ########################################
4 #Timeout value for the hanging scripts
7 ################### TIMEOUT HANDLER #################################
12 echo "HANG_FLAG is set here"
13 kill -9 $CMD_PID 2>/dev
/null
17 ##################### Test Executor main starts here ##################
19 #TEST_RUN_DIR should be set before running this
20 if [ ! "$TEST_RUN_ROOT" ]
22 echo "TEST_RUN_ROOT should be set before running the tests"
25 if [ ! "$CSQL_INSTALL_ROOT" ]
27 echo "CSQL_INSTALL_ROOT should be set before running the tests"
31 if [ ! "$CSQL_CONFIG_FILE" ]
33 echo "setupenv.ksh should be run before running the tests"
36 DBFILE
=`grep DATABASE_FILE $CSQL_CONFIG_FILE| awk -F= '{ print $2}'`
37 CACHECONFFILE
=`grep TABLE_CONFIG_FILE $CSQL_CONFIG_FILE| awk -F= '{ print $2}'`
42 mkdir
-p $TEST_RUN_ROOT
43 SERVOUT
=$TEST_RUN_ROOT/serv.out
45 $CSQL_INSTALL_ROOT/bin
/csqlserver
>${SERVOUT} &
47 echo "Starting Server"
51 echo $MODULE |
grep "#" >/dev
/null
56 echo "MODULE READ is $MODULE"
58 if [ "$MODULE" = "system/lock" ]
60 echo "Restarting the server for lock module"
63 echo "csqlserver killed PID=${SERVER_PID}" >>$TEST_LOG
65 $CSQL_INSTALL_ROOT/bin
/csqlserver
>${SERVOUT} &
67 echo "csqlserver restarted with PID=${SERVER_PID}" >>$TEST_LOG
68 echo "Restarting Server"
71 TEST_SCRIPT_DIR
=${ROOT_DIR}/${MODULE}
72 TEST_RUN_DIR
=${TEST_RUN_ROOT}/${MODULE}
73 if [ -s "$TEST_RUN_DIR" ]
75 echo "TEST_RUN_ROOT directory is not empty. Clean and try again."
78 mkdir
-p $TEST_RUN_DIR
80 # TODO::check whether server is running
82 TEST_LOG
=$TEST_RUN_DIR/testlog
86 echo "TEST_RUN_DIR has files in it. Remove before running the tests"
90 TEST_EXEC_DIR
=$TEST_RUN_DIR/tests
94 echo "Test Executor log file" >$TEST_LOG
95 echo "----------------------" >>$TEST_LOG
97 TestList
=`ls ${TEST_SCRIPT_DIR}/test*`
101 echo "Running $test" >>$TEST_LOG
102 echo "Test started at : `date` "
103 echo "Test started at : `date` " >>$TEST_LOG
106 EXP_FILE
=exp.
`basename ${test}`
107 #echo "EXP_FILE is $EXP_FILE"
108 if [ -s "${TEST_SCRIPT_DIR}/${EXP_FILE}" ]
114 trap timeout_handler USR1
115 sleep ${HANG_TIMEOUT} && kill -s USR1 $$
&
118 if [ "$expPresent" = "yes" ]
120 cp ${TEST_SCRIPT_DIR}/${EXP_FILE} ${TEST_EXEC_DIR}
121 ${test} > ${TEST_EXEC_DIR}/cur.${EXP_FILE} 2>/dev
/null
&
123 ${test} >> ${TEST_LOG} 2>/dev
/null
&
126 wait ${CMD_PID} 2>/dev
/null
128 echo "Test Ended at : `date` "
129 echo "Test Ended at : `date` " >>$TEST_LOG
132 kill -9 ${SLEEP_PID} 2>/dev
/null
134 if [ "$HANG_FLAG" = "Yes" ]
136 echo "Test Hung. so it is killed." >>$TEST_LOG
137 echo "FAILED:Test $test failed" >>$TEST_LOG
138 #TODO::Reinitalize the database, as it may be in corrupted state.
140 mv ${SERVOUT} ${SERVOUT}.${SERVER_PID}.${CURTIME}
141 kill -9 ${SERVER_PID}
142 ipcrm
-M 2222 -M 3333
143 echo "csqlserver killed PID=${SERVER_PID}" >>$TEST_LOG
144 $CSQL_INSTALL_ROOT/bin
/csqlserver
>${SERVOUT} &
146 echo "csqlserver restarted with PID=${SERVER_PID}" >>$TEST_LOG
147 echo "Restarting Server"
156 if [ "$expPresent" = "yes" ]
158 #compare exp and current output
159 diff ${TEST_SCRIPT_DIR}/${EXP_FILE} ${TEST_EXEC_DIR}/cur.${EXP_FILE} > ${TEST_EXEC_DIR}/diff.${EXP_FILE}
163 echo "Exp and current output matched."
164 echo "Test $test passed"
165 echo "Exp and current output matched." >>$TEST_LOG
166 echo "PASSED:Test $test passed" >>$TEST_LOG
167 rm ${TEST_EXEC_DIR}/cur.
${EXP_FILE}
168 rm ${TEST_EXEC_DIR}/diff.
${EXP_FILE}
169 rm ${TEST_EXEC_DIR}/${EXP_FILE}
171 echo "Exp and current output not matched."
172 echo "Test $test failed"
173 echo "Exp and current output not matched." >>${TEST_LOG}
174 echo "FAILED:Test $test failed" >>$TEST_LOG
175 #TODO::Reinitalize the database, as it may be in corrupted state.
177 mv ${SERVOUT} ${SERVOUT}.${SERVER_PID}.${CURTIME}
178 echo "Refer ${SERVOUT}.${SERVER_PID}.${CURTIME} file for server log" >>$TEST_LOG
179 kill -9 ${SERVER_PID}
180 ipcrm
-M 2222 -M 3333
181 echo "csqlserver killed PID=${SERVER_PID}" >>${TEST_LOG}
183 $CSQL_INSTALL_ROOT/bin
/csqlserver
>${SERVOUT} &
185 echo "csqlserver restarted with PID=${SERVER_PID}" >>${TEST_LOG}
186 echo "Restarting Server"
191 echo "Test $test passed"
192 echo "Returned 0." >>$TEST_LOG
193 echo "PASSED:Test $test passed" >>$TEST_LOG
197 echo "Returned $ret "
198 echo "Test $test failed"
199 echo "Returned $ret " >>$TEST_LOG
200 echo "FAILED:Test $test failed" >>$TEST_LOG
201 #TODO::Reinitalize the database, as it may be in corrupted state.
203 mv ${SERVOUT} ${SERVOUT}.${SERVER_PID}.${CURTIME}
204 echo "Refer ${SERVOUT}.${SERVER_PID}.${CURTIME} file for server log" >>$TEST_LOG
205 kill -9 ${SERVER_PID}
206 ipcrm
-M 2222 -M 3333
207 echo "csqlserver killed PID=${SERVER_PID}" >>$TEST_LOG
209 $CSQL_INSTALL_ROOT/bin
/csqlserver
>${SERVOUT} 2>${SERVOUT} &
211 echo "csqlserver restarted with PID=${SERVER_PID}" >>${TEST_LOG}
212 echo "Restarting Server"
219 kill -9 ${SERVER_PID}
220 ipcrm
-M 2222 -M 3333
221 echo "csqlserver killed PID=${SERVER_PID}" >>${TEST_LOG}