From bce90367581a660e6f6c12e166f2ec91fe3b1591 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zden=C4=9Bk=20=C5=A0ustr?= Date: Mon, 8 Sep 2008 09:02:02 +0000 Subject: [PATCH] New local test for local logger + minor improvements in server test. --- org.glite.testsuites.ctb/LB/lb-common.sh | 2 + .../LB/lb-test-logger-local.sh | 135 +++++++++++++++++++++ .../LB/lb-test-server-local.sh | 19 ++- 3 files changed, 145 insertions(+), 11 deletions(-) create mode 100755 org.glite.testsuites.ctb/LB/lb-test-logger-local.sh diff --git a/org.glite.testsuites.ctb/LB/lb-common.sh b/org.glite.testsuites.ctb/LB/lb-common.sh index bfc69ad..906c056 100755 --- a/org.glite.testsuites.ctb/LB/lb-common.sh +++ b/org.glite.testsuites.ctb/LB/lb-common.sh @@ -171,3 +171,5 @@ function check_socket_listener() return $TEST_OK fi } + +#df /var/lib/mysql/ | tail -n 1 | awk '{ print $4 }' diff --git a/org.glite.testsuites.ctb/LB/lb-test-logger-local.sh b/org.glite.testsuites.ctb/LB/lb-test-logger-local.sh new file mode 100755 index 0000000..034742c --- /dev/null +++ b/org.glite.testsuites.ctb/LB/lb-test-logger-local.sh @@ -0,0 +1,135 @@ +#!/bin/bash + +# show help and usage +progname=`basename $0` +showHelp() +{ +cat << EndHelpHeader +Script for testing the LB logger locally + +Prerequisities: + - LB logger running on local machine + - environment variables set: + + GLITE_LB_LOGGER_PORT - if nondefault port (9002) is used + +Tests called: + + pidof - return instance PIDs of the given binary + mysqladmin ping - check for response by the mysql server + check_socket() - simple tcp echo to all LB server ports + (9002 by default) + +Returned values: + Exit TEST_OK: Test Passed + Exit TEST_ERROR: Test Failed + Exit 2: Wrong Input + +EndHelpHeader + + echo "Usage: $progname [OPTIONS]" + echo "Options:" + echo " -h | --help Show this help message." + echo " -o | --output 'file' Redirect all output to the 'file' (stdout by default)." + echo " -t | --text Format output as plain ASCII text." + echo " -c | --color Format output as text with ANSI colours (autodetected by default)." + echo " -x | --html Format output as html." +} + +# read common definitions and functions +COMMON=lb-common.sh +if [ ! -r ${COMMON} ]; then + printf "Common definitions '${COMMON}' missing!" + exit 2 +fi +source ${COMMON} + +logfile=$$.tmp +flag=0 +while test -n "$1" +do + case "$1" in + "-h" | "--help") showHelp && exit 2 ;; + "-o" | "--output") shift ; logfile=$1 flag=1 ;; + "-t" | "--text") setOutputASCII ;; + "-c" | "--color") setOutputColor ;; + "-x" | "--html") setOutputHTML ;; + esac + shift +done + +# redirecting all output to $logfile +touch $logfile +if [ ! -w $logfile ]; then + echo "Cannot write to output file $logfile" + exit $TEST_ERROR +fi + +DEBUG=2 + +## +# Starting the test +##################### + +{ +test_start + +# check_binaries +printf "Testing if all binaries are available" +check_binaries +if [ $? -gt 0 ]; then + test_failed +else + test_done +fi + +# logger running: +printf "Testing if LB logger is running" +if [ "$(pidof ${LB_LOGD})" ]; then + test_done +else + test_failed + print_error "${LB_LOGD} is not running" +fi + +# logger listening: +printf "Testing if LB logger is listening on port ${GLITE_LB_LOGGER_PORT}" +check_listener ${LB_LOGD} ${GLITE_LB_LOGGER_PORT} +if [ $? -gt 0 ]; then + test_failed + print_error "LB logger is not listening on port ${GLITE_LB_LOGGER_PORT}" +else + test_done +fi + +# interlogger running: +printf "Testing if Interlogger is running" +if [ "$(pidof ${LB_INTERLOGD})" ]; then + test_done +else + test_failed + print_error "${LB_INTERLOGD} server is not running" +fi + + +# Interlogger listening on socket: +printf "Testing if interlogger is listening on socket ${GLITE_LB_IL_SOCK}" +check_socket_listener ${LB_INTERLOGD} ${GLITE_LB_IL_SOCK} +if [ $? -gt 0 ]; then + test_failed + print_error "LB interlogger is not listening on socket ${GLITE_LB_IL_SOCK}" +else + test_done +fi + + + +test_end +} &> $logfile + +if [ $flag -ne 1 ]; then + cat $logfile + rm $logfile +fi +exit $TEST_OK + diff --git a/org.glite.testsuites.ctb/LB/lb-test-server-local.sh b/org.glite.testsuites.ctb/LB/lb-test-server-local.sh index 75603af..d09a1eb 100755 --- a/org.glite.testsuites.ctb/LB/lb-test-server-local.sh +++ b/org.glite.testsuites.ctb/LB/lb-test-server-local.sh @@ -101,16 +101,16 @@ else print_error "mySQL server is not answering" fi -# glite-lb-bkserverd running: +# server running: printf "Testing if LB Server is running" -if [ "$(pidof glite-lb-bkserverd)" ]; then +if [ "$(pidof ${LB_SERVER})" ]; then test_done else test_failed - print_error "glite-lb-bkserverd server is not running" + print_error "${LB_SERVER} server is not running" fi -# glite-lb-bkserverd listening: +# Server listening: printf "Testing if LB Server is listening on port ${GLITE_LB_SERVER_PORT}" check_listener ${LB_SERVER} ${GLITE_LB_SERVER_PORT} if [ $? -gt 0 ]; then @@ -120,7 +120,7 @@ else test_done fi -# glite-lb-bkserverd listening: +# Server listening: printf "Testing if LB Server is listening on port ${GLITE_LB_SERVER_QPORT}" check_listener ${LB_SERVER} ${GLITE_LB_SERVER_QPORT} if [ $? -gt 0 ]; then @@ -130,7 +130,7 @@ else test_done fi -# glite-lb-bkserverd listening: +# Server listening: printf "Testing if LB Server is listening on port ${GLITE_LB_SERVER_WPORT}" check_listener ${LB_SERVER} ${GLITE_LB_SERVER_WPORT} if [ $? -gt 0 ]; then @@ -141,16 +141,13 @@ else fi -# glite-lb-interlogd running: -printf "Testing if Interlogger is running" - -# glite-lb-interlogd running: +# Interlogger running: printf "Testing if Interlogger is running" if [ "$(pidof ${LB_INTERLOGD})" ]; then test_done else test_failed - print_error "glite-lb-interlogd server is not running" + print_error "${LB_INTERLOGD} server is not running" fi -- 1.8.2.3