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
6 # Third argument is user name
7 # Fourth argument is password
9 ################### Settings ########################################
10 #Timeout value for the hanging scripts
13 ################### TIMEOUT HANDLER #################################
18 echo "HANG_FLAG is set here"
19 kill -9 $CMD_PID 2>/dev
/null
22 restart_csqlserver
() {
23 echo "Restarting the server"
26 SRVPID
=`ps -ef | grep csqlserver|grep -v "grep" |tail -1| awk -F" " '{ print $2 }'`
27 if [ "$SRVPID" != "" ]
29 echo CSQL Server
$SRVPID is being killed
33 ipcrm
-M 2222 -M 3333 -M 1947
36 echo "csqlserver killed PID=${SERVER_PID}" >>$TEST_LOG
37 # rm -f /tmp/csql.conf
41 cp $CSQL_SRCROOT/csql.conf
/tmp
/csql
/csql.conf
42 export CSQL_CONFIG_FILE
=/tmp
/csql
/csql.conf
43 echo "MMAP=false" >>/tmp
/csql
/csql.conf
44 echo "CSQL_SQL_SERVER=true">>/tmp
/csql
/csql.conf
48 touch /tmp
/csql
/csqltable.conf
49 touch /tmp
/csql
/csqlnw.conf
50 touch /tmp
/csql
/csqlds.conf
51 $CSQL_INSTALL_ROOT/bin
/csqlds
-U $DBUSER -P $PASSWORD -D $DSN -N $TDB -a
52 $CSQL_INSTALL_ROOT/bin
/csqlserver
>${SERVOUT} &
54 echo "csqlserver restarted with PID=${SERVER_PID}" >>$TEST_LOG
62 SQLPID
=`ps -ef | grep csqlsqlserver|grep -v "grep" |tail -1| awk -F" " '{ print $2 }'`
63 if [ "$SQLPID" != "" ]
65 echo SQL Server
$SQLPID is being killed
71 #kill checkpoint setver
74 CHKPTPID
=`ps -ef | grep csqlcheckpointserver |grep -v "grep" |tail -1| awk -F" " '{ print $2 }'`
75 if [ "$CHKPTPID" != "" ]
77 echo Checkpoint server
$CHKPTPID is being killed
85 ##################### Test Executor main starts here ##################
87 if [ ! "$CSQL_CONFIG_FILE" ]
89 echo "setupenv.ksh script is not run"
93 #TEST_RUN_DIR should be set before running this
94 if [ ! "$TEST_RUN_ROOT" -a ! "$MODULE_NAME" ]
96 echo "TEST_RUN_ROOT should be set before running the tests"
99 if [ ! "$CSQL_INSTALL_ROOT" ]
101 echo "CSQL_INSTALL_ROOT should be set before running the tests"
105 cp $CSQL_SRCROOT/csql.conf
/tmp
/csql
/csql.conf
106 export CSQL_CONFIG_FILE
=/tmp
/csql
/csql.conf
107 echo "MMAP=false" >>/tmp
/csql.conf
108 echo "CSQL_SQL_SERVER=true">>/tmp
/csql.conf
113 echo "First argument is " $1
116 isql
$1 $3 $4 </dev
/null
>/dev
/null
2>/dev
/null
119 echo "Unable to connect to data source"
122 echo DSN
=$1 >>$CSQL_CONFIG_FILE
124 isql
$1 $3 $4</dev
/null
>/dev
/null
2>/dev
/null
127 echo "Unable to connect to data source"
130 echo DSN
=$1 >>$CSQL_CONFIG_FILE
135 if [ ! "$MYSQL_DSN" ]
137 echo "Set up needs to be done for MultiDSN by edit setMultiDsn.ksh file for all TDBs."
142 if [ ! "$MODULE_NAME" ]
145 mkdir
-p $TEST_RUN_ROOT
146 SERVOUT
=$TEST_RUN_ROOT/serv.out
148 $CSQL_INSTALL_ROOT/bin
/csqlserver
>${SERVOUT} &
150 echo "Starting Server"
154 echo $MODULE |
grep "#" >/dev
/null
159 echo "MODULE READ is $MODULE"
160 #if [ "$MODULE" = "adapter/Connect" -o "$MODULE" = "adapter/Parameter" -o "$MODULE" = "adapter/Select" ]
162 rm -f /tmp
/csql
/csqlds.conf
163 touch /tmp
/csql
/csqlds.conf
164 $CSQL_INSTALL_ROOT/bin
/csqlds
-U $DBUSER -P $PASSWORD -D $DSN -N $TDB -a
170 TEST_SCRIPT_DIR
=${ROOT_DIR}/${MODULE}
171 TEST_RUN_DIR
=${TEST_RUN_ROOT}/${MODULE}
172 if [ -s "$TEST_RUN_DIR" ]
175 ipcrm
-M 2222 -M 3333 -M 1947
176 echo "TEST_RUN_ROOT directory is not empty. Clean and try again."
179 mkdir
-p $TEST_RUN_DIR
181 # TODO::check whether server is running
183 TEST_LOG
=$TEST_RUN_DIR/testlog
185 if [ -s "$TEST_LOG" ]
187 echo "TEST_RUN_DIR has files in it. Remove before running the tests"
191 TEST_EXEC_DIR
=$TEST_RUN_DIR/tests
195 echo "Test Executor log file" >$TEST_LOG
196 echo "----------------------" >>$TEST_LOG
198 TestList
=`ls ${TEST_SCRIPT_DIR}/test*`
199 for test in $TestList
202 echo "Running $test" >>$TEST_LOG
203 echo "Test started at : `date` "
204 echo "Test started at : `date` " >>$TEST_LOG
209 EXPECTED_FILE
=exp.
`basename ${test}`
211 EXP_FILE
=$EXPECTED_FILE
212 if [ "$ARCH" = "x86_64" ]
214 EXP_FILE
=$EXPECTED_FILE.
$ARCH
217 if [ -s "${TEST_SCRIPT_DIR}/${EXP_FILE}" -a "$arch" = "yes" ]
222 if [ "$OS" = "SunOS" ]
224 EXP_FILE
=$EXPECTED_FILE.
$OS
227 if [ -s "${TEST_SCRIPT_DIR}/${EXP_FILE}" -a "$os" = "yes" ]
231 if [ "$expPresent" = "no" ]
233 EXP_FILE
=$EXPECTED_FILE.
$DSN
235 if [ -s "${TEST_SCRIPT_DIR}/${EXP_FILE}" ]
239 if [ "$expPresent" = "no" ]
241 if [ -s "${TEST_SCRIPT_DIR}/${EXPECTED_FILE}" ]
244 EXP_FILE
=$EXPECTED_FILE
248 echo "EXP_FILE is $EXP_FILE"
251 trap timeout_handler USR1
252 sleep ${HANG_TIMEOUT} && kill -s USR1 $$
&
255 if [ "$expPresent" = "yes" ]
257 cp ${TEST_SCRIPT_DIR}/${EXP_FILE} ${TEST_EXEC_DIR}
258 ${test} > ${TEST_EXEC_DIR}/cur.${EXP_FILE} 2>/dev
/null
&
260 ${test} >> ${TEST_LOG} 2>/dev
/null
&
263 wait ${CMD_PID} 2>/dev
/null
265 echo "Test Ended at : `date` "
266 echo "Test Ended at : `date` " >>$TEST_LOG
269 kill -9 ${SLEEP_PID} 2>/dev
/null
271 if [ "$HANG_FLAG" = "Yes" ]
273 echo "Test Hung. so it is killed." >>$TEST_LOG
274 echo "FAILED:Test $test failed" >>$TEST_LOG
275 #TODO::Reinitalize the database, as it may be in corrupted state.
277 mv ${SERVOUT} ${SERVOUT}.${SERVER_PID}.${CURTIME}
286 if [ "$expPresent" = "yes" ]
288 #compare exp and current output
289 diff ${TEST_SCRIPT_DIR}/${EXP_FILE} ${TEST_EXEC_DIR}/cur.${EXP_FILE} > ${TEST_EXEC_DIR}/diff.${EXP_FILE}
293 echo "Exp and current output matched."
294 echo "Test $test passed"
295 echo "Exp and current output matched." >>$TEST_LOG
296 echo "PASSED:Test $test passed" >>$TEST_LOG
297 rm ${TEST_EXEC_DIR}/cur.
${EXP_FILE}
298 rm ${TEST_EXEC_DIR}/diff.
${EXP_FILE}
299 rm ${TEST_EXEC_DIR}/${EXP_FILE}
301 echo "Exp and current output not matched."
302 echo "Test $test failed"
303 echo "Exp and current output not matched." >>${TEST_LOG}
304 echo "FAILED:Test $test failed" >>$TEST_LOG
305 #TODO::Reinitalize the database, as it may be in corrupted state.
307 mv ${SERVOUT} ${SERVOUT}.${SERVER_PID}.${CURTIME}
308 echo "Refer ${SERVOUT}.${SERVER_PID}.${CURTIME} file for server log" >>$TEST_LOG
313 echo "Test $test passed"
314 echo "Returned 0." >>$TEST_LOG
315 echo "PASSED:Test $test passed" >>$TEST_LOG
319 echo "Returned $ret "
320 echo "Test $test failed"
321 echo "Returned $ret " >>$TEST_LOG
322 echo "FAILED:Test $test failed" >>$TEST_LOG
323 #TODO::Reinitalize the database, as it may be in corrupted state.
325 mv ${SERVOUT} ${SERVOUT}.${SERVER_PID}.${CURTIME}
326 echo "Refer ${SERVOUT}.${SERVER_PID}.${CURTIME} file for server log" >>$TEST_LOG
331 done < CacheTestModules
332 kill -9 ${SERVER_PID}
334 ipcrm
-M 2222 -M 3333 -M 1947
335 echo "csqlserver killed PID=${SERVER_PID}" >>${TEST_LOG}
339 #For Single Script Test
340 if [ ! "$SCRIPT_NAME" ]
342 echo "Set SCRIPT_NAME to execute single script"
345 $CSQL_INSTALL_ROOT/bin
/csqlserver
>/dev
/null
2>&1 &
347 echo "Starting Server"
349 echo "MODULE Name is $MODULE_NAME"
350 echo "SCRIPT Name is $SCRIPT_NAME"
351 if [ "$MODULE_NAME" = "adapter/Connect" -o "$MODULE_NAME" = "adapter/Parameter" -o "$MODULE_NAME" = "adapter/Select" ]
353 rm -f /tmp
/csql
/csqlds.conf
354 touch /tmp
/csql
/csqlds.conf
355 $CSQL_INSTALL_ROOT/bin
/csqlds
-U $DBUSER -P $PASSWORD -D $DSN -N $TDB -a
361 test=${ROOT_DIR}/${MODULE_NAME}/${SCRIPT_NAME}
363 echo "Test started at : `date` "
365 EXPECTED_FILE
=exp.
`basename ${test}`
366 EXP_FILE
=$EXPECTED_FILE.
$DSN
367 TEST_SCRIPT_DIR
=${ROOT_DIR}/${MODULE_NAME}
368 if [ -s "${TEST_SCRIPT_DIR}/${EXP_FILE}" ]
372 if [ "$expPresent" = "no" ]
374 if [ -s "${TEST_SCRIPT_DIR}/${EXPECTED_FILE}" ]
377 EXP_FILE
=$EXPECTED_FILE
380 echo "EXP_FILE is $EXP_FILE"
382 trap timeout_handler USR1
383 sleep ${HANG_TIMEOUT} && kill -s USR1 $$
&
385 if [ "$expPresent" = "yes" ]
387 cp ${TEST_SCRIPT_DIR}/${EXP_FILE} ${ROOT_DIR}
388 ${test} >${ROOT_DIR}/cur.${EXP_FILE} 2>/dev
/null
&
390 ${test} 2>/dev
/null
&
393 wait ${CMD_PID} 2>/dev
/null
395 echo "Test Ended at : `date` "
398 kill -9 ${SLEEP_PID} 2>/dev
/null
399 if [ "$HANG_FLAG" = "Yes" ]
402 mv ${SERVOUT} ${SERVOUT}.${SERVER_PID}.${CURTIME}
403 kill -9 ${SERVER_PID}
404 ipcrm
-M 2222 -M 3333
405 echo "csqlserver killed due to HANG_FLAG PID=${SERVER_PID}"
410 if [ "$expPresent" = "yes" ]
412 diff ${TEST_SCRIPT_DIR}/${EXP_FILE} ${ROOT_DIR}/cur.${EXP_FILE} > ${ROOT_DIR}/diff.${EXP_FILE}
415 echo "Exp and current output matched."
416 echo "Test $test passed"
417 rm -f ${ROOT_DIR}/cur.${EXP_FILE} ${ROOT_DIR}/diff.${EXP_FILE} ${ROOT_DIR}/${EXP_FILE}
419 echo "Exp and current output not matched."
420 echo "Test $test failed"
424 echo "Test $test passed"
427 echo "Returned $ret "
428 echo "Test $test failed"
430 kill -9 ${SERVER_PID}
432 ipcrm
-M 2222 -M 3333 -M 1947