3 # First argument is the data source name to be used
4 # Second argument is the target database name
5 # valid names: MYSQL, PSQL, ORACLE
7 ################### Settings ########################################
8 #Timeout value for the hanging scripts
11 ################### TIMEOUT HANDLER #################################
16 echo "HANG_FLAG is set here"
17 kill -9 $CMD_PID 2>/dev
/null
21 ##################### Test Executor main starts here ##################
23 if [ ! "$CSQL_CONFIG_FILE" ]
25 echo "setupenv.ksh script is not run"
28 #TEST_RUN_DIR should be set before running this
29 if [ ! "$TEST_RUN_ROOT" ]
31 echo "TEST_RUN_ROOT should be set before running the tests"
34 if [ ! "$CSQL_INSTALL_ROOT" ]
36 echo "CSQL_INSTALL_ROOT should be set before running the tests"
41 echo "First argument is " $1
42 isql
$1 </dev
/null
>/dev
/null
2>/dev
/null
45 echo "Unable to connect to data source"
49 cp $CSQL_CONFIG_FILE /tmp
/csql.conf
50 echo DSN
=$1 >>$CSQL_CONFIG_FILE
53 mkdir
-p $TEST_RUN_ROOT
54 SERVOUT
=$TEST_RUN_ROOT/serv.out
56 $CSQL_INSTALL_ROOT/bin
/csqlserver
>${SERVOUT} &
58 echo "Starting Server"
62 echo $MODULE |
grep "#" >/dev
/null
67 echo "MODULE READ is $MODULE"
69 TEST_SCRIPT_DIR
=${ROOT_DIR}/${MODULE}
70 TEST_RUN_DIR
=${TEST_RUN_ROOT}/${MODULE}
71 if [ -s "$TEST_RUN_DIR" ]
73 echo "TEST_RUN_ROOT directory is not empty. Clean and try again."
76 mkdir
-p $TEST_RUN_DIR
78 # TODO::check whether server is running
80 TEST_LOG
=$TEST_RUN_DIR/testlog
84 echo "TEST_RUN_DIR has files in it. Remove before running the tests"
88 TEST_EXEC_DIR
=$TEST_RUN_DIR/tests
92 echo "Test Executor log file" >$TEST_LOG
93 echo "----------------------" >>$TEST_LOG
95 TestList
=`ls ${TEST_SCRIPT_DIR}/test*`
99 echo "Running $test" >>$TEST_LOG
100 echo "Test started at : `date` "
101 echo "Test started at : `date` " >>$TEST_LOG
104 EXP_FILE
=exp.
`basename ${test}`
105 #echo "EXP_FILE is $EXP_FILE"
106 if [ -s "${TEST_SCRIPT_DIR}/${EXP_FILE}" ]
112 trap timeout_handler USR1
113 sleep ${HANG_TIMEOUT} && kill -s USR1 $$
&
116 if [ "$expPresent" = "yes" ]
118 cp ${TEST_SCRIPT_DIR}/${EXP_FILE} ${TEST_EXEC_DIR}
119 ${test} > ${TEST_EXEC_DIR}/cur.${EXP_FILE} 2>/dev
/null
&
121 ${test} >> ${TEST_LOG} 2>/dev
/null
&
124 wait ${CMD_PID} 2>/dev
/null
126 echo "Test Ended at : `date` "
127 echo "Test Ended at : `date` " >>$TEST_LOG
130 kill -9 ${SLEEP_PID} 2>/dev
/null
132 if [ "$HANG_FLAG" = "Yes" ]
134 echo "Test Hung. so it is killed." >>$TEST_LOG
135 echo "FAILED:Test $test failed" >>$TEST_LOG
136 #TODO::Reinitalize the database, as it may be in corrupted state.
138 mv ${SERVOUT} ${SERVOUT}.${SERVER_PID}.${CURTIME}
139 kill -9 ${SERVER_PID}
140 ipcrm
-M 2222 -M 3333
141 echo "csqlserver killed PID=${SERVER_PID}" >>$TEST_LOG
142 $CSQL_INSTALL_ROOT/bin
/csqlserver
>${SERVOUT} &
144 echo "csqlserver restarted with PID=${SERVER_PID}" >>$TEST_LOG
145 echo "Restarting Server"
154 if [ "$expPresent" = "yes" ]
156 #compare exp and current output
157 diff ${TEST_SCRIPT_DIR}/${EXP_FILE} ${TEST_EXEC_DIR}/cur.${EXP_FILE} > ${TEST_EXEC_DIR}/diff.${EXP_FILE}
161 echo "Exp and current output matched."
162 echo "Test $test passed"
163 echo "Exp and current output matched." >>$TEST_LOG
164 echo "PASSED:Test $test passed" >>$TEST_LOG
165 rm ${TEST_EXEC_DIR}/cur.
${EXP_FILE}
166 rm ${TEST_EXEC_DIR}/diff.
${EXP_FILE}
167 rm ${TEST_EXEC_DIR}/${EXP_FILE}
169 echo "Exp and current output not matched."
170 echo "Test $test failed"
171 echo "Exp and current output not matched." >>${TEST_LOG}
172 echo "FAILED:Test $test failed" >>$TEST_LOG
173 #TODO::Reinitalize the database, as it may be in corrupted state.
175 mv ${SERVOUT} ${SERVOUT}.${SERVER_PID}.${CURTIME}
176 echo "Refer ${SERVOUT}.${SERVER_PID}.${CURTIME} file for server log" >>$TEST_LOG
177 kill -9 ${SERVER_PID}
178 ipcrm
-M 2222 -M 3333
179 echo "csqlserver killed PID=${SERVER_PID}" >>${TEST_LOG}
180 $CSQL_INSTALL_ROOT/bin
/csqlserver
>${SERVOUT} &
182 echo "csqlserver restarted with PID=${SERVER_PID}" >>${TEST_LOG}
183 echo "Restarting Server"
188 echo "Test $test passed"
189 echo "Returned 0." >>$TEST_LOG
190 echo "PASSED:Test $test passed" >>$TEST_LOG
194 echo "Returned $ret "
195 echo "Test $test failed"
196 echo "Returned $ret " >>$TEST_LOG
197 echo "FAILED:Test $test failed" >>$TEST_LOG
198 #TODO::Reinitalize the database, as it may be in corrupted state.
200 mv ${SERVOUT} ${SERVOUT}.${SERVER_PID}.${CURTIME}
201 echo "Refer ${SERVOUT}.${SERVER_PID}.${CURTIME} file for server log" >>$TEST_LOG
202 kill -9 ${SERVER_PID}
203 ipcrm
-M 2222 -M 3333
204 echo "csqlserver killed PID=${SERVER_PID}" >>$TEST_LOG
205 $CSQL_INSTALL_ROOT/bin
/csqlserver
>${SERVOUT} 2>${SERVOUT} &
207 echo "csqlserver restarted with PID=${SERVER_PID}" >>${TEST_LOG}
208 echo "Restarting Server"
213 done < CacheTestModules
215 kill -9 ${SERVER_PID}
216 ipcrm
-M 2222 -M 3333
217 echo "csqlserver killed PID=${SERVER_PID}" >>${TEST_LOG}
218 cp /tmp
/csql.conf
$CSQL_CONFIG_FILE