From 362b329c6a8916427067e3f9804170ceb6c0eebe Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zden=C4=9Bk=20=C5=A0ustr?= Date: Fri, 25 Jun 2010 15:29:57 +0000 Subject: [PATCH] - A new statistics test - Fixed duality in constructing a list of jobs to purge. --- org.glite.testsuites.ctb/LB/tests/lb-common.sh | 7 +- .../LB/tests/lb-test-statistics.sh | 226 +++++++++++++++++++++ 2 files changed, 232 insertions(+), 1 deletion(-) create mode 100755 org.glite.testsuites.ctb/LB/tests/lb-test-statistics.sh diff --git a/org.glite.testsuites.ctb/LB/tests/lb-common.sh b/org.glite.testsuites.ctb/LB/tests/lb-common.sh index 55bcb8b..13ffb8d 100755 --- a/org.glite.testsuites.ctb/LB/tests/lb-common.sh +++ b/org.glite.testsuites.ctb/LB/tests/lb-common.sh @@ -67,6 +67,9 @@ LB_READY_SH=glite-lb-ready.sh LB_RUNNING_SH=glite-lb-running.sh LB_DONE_SH=glite-lb-done.sh +LB_STATS=glite-lb-stats +LB_FROMTO=glite-lb-stats-duration-fromto + #general grid binaries GRIDPROXYINFO=grid-proxy-info @@ -103,6 +106,9 @@ SYS_LDAPSEARCH=ldapsearch SYS_CAT=cat SYS_NL=nl SYS_TAIL=tail +SYS_DATE=date +SYS_EXPR=expr +SYS_BC=bc # not used at the moment DEBUG=2 @@ -228,7 +234,6 @@ function try_purge() { #Purge test job joblist=$1 - $SYS_ECHO $jobid > ${joblist} printf "Purging test job (Trying the best, result will not be tested)\n" diff --git a/org.glite.testsuites.ctb/LB/tests/lb-test-statistics.sh b/org.glite.testsuites.ctb/LB/tests/lb-test-statistics.sh new file mode 100755 index 0000000..2bf4d5b --- /dev/null +++ b/org.glite.testsuites.ctb/LB/tests/lb-test-statistics.sh @@ -0,0 +1,226 @@ +#!/bin/bash +# +# Copyright (c) Members of the EGEE Collaboration. 2004-2010. +# See http://www.eu-egee.org/partners for details on the copyright holders. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# show help and usage +progname=`basename $0` +showHelp() +{ +cat << EndHelpHeader +Script for testing statistic functions provided by the L&B Service + +Prerequisities: + - LB local logger, interlogger, and server running + - environment variables set: + + GLITE_LB_SERVER_PORT - if nondefault port (9000) is used + GLITE_LB_LOGGER_PORT - if nondefault port (9002) is used + GLITE_WMS_QUERY_SERVER + GLITE_WMS_LOG_DESTINATION + +Tests called: + + job registration + event logging + +Returned values: + Exit TEST_OK: Test Passed + Exit TEST_ERROR: Test Failed + Exit 2: Wrong Input + +EndHelpHeader + + echo "Usage: $progname [OPTIONS] [event file prefix]" + 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." + echo "" +} + +submitted_to_running () { + + EDG_WL_SEQUENCE="UI=000003:NS=0000000000:WM=000000:BH=0000000000:JSS=000000:LM=000000:LRMS=000000:APP=000000:LBS=000000" + EDG_WL_SEQUENCE=`${LBLOGEVENT} -j $1 -c $EDG_WL_SEQUENCE -s NetworkServer -e Accepted --from="UserInterface" --from_host="sending component hostname" --from_instance="sending component instance" --local_jobid="new jobId (Condor Globus ...)"` + EDG_WL_SEQUENCE=`${LBLOGEVENT} -j $1 -c $EDG_WL_SEQUENCE -s NetworkServer -e EnQueued --queue="destination queue" --job="job description in receiver language" --result=OK --reason="detailed description of transfer"` + EDG_WL_SEQUENCE=`${LBLOGEVENT} -j $1 -c $EDG_WL_SEQUENCE -s WorkloadManager -e DeQueued --queue="queue name" --local_jobid="new jobId assigned by the receiving component"` + EDG_WL_SEQUENCE=`${LBLOGEVENT} -j $1 -c $EDG_WL_SEQUENCE -s WorkloadManager -e HelperCall --helper_name="name of the called component" --helper_params="parameters of the call" --src_role=CALLING` + EDG_WL_SEQUENCE=`${LBLOGEVENT} -j $1 -c $EDG_WL_SEQUENCE -s WorkloadManager -e Match --dest_id="CE$datestr$$"` + EDG_WL_SEQUENCE=`${LBLOGEVENT} -j $1 -c $EDG_WL_SEQUENCE -s WorkloadManager -e HelperReturn --helper_name="name of the called component" --retval="returned data" --src_role=CALLING` + EDG_WL_SEQUENCE=`${LBLOGEVENT} -j $1 -c $EDG_WL_SEQUENCE -s WorkloadManager -e EnQueued --queue="destination queue" --job="job description in receiver language" --result=OK --reason="detailed description of transfer"` + EDG_WL_SEQUENCE=`${LBLOGEVENT} -j $1 -c $EDG_WL_SEQUENCE -s JobController -e DeQueued --queue="queue name" --local_jobid="new jobId assigned by the receiving component"` + EDG_WL_SEQUENCE=`${LBLOGEVENT} -j $1 -c $EDG_WL_SEQUENCE -s JobController -e Transfer --destination="LRMS" --dest_host="destination hostname" --dest_instance="destination instance" --job="job description in receiver language" --result=OK --reason="detailed description of transfer" --dest_jobid="destination internal jobid"` + EDG_WL_SEQUENCE=`${LBLOGEVENT} -j $1 -c $EDG_WL_SEQUENCE -s LogMonitor -e Accepted --from="JobController" --from_host="sending component hostname" --from_instance="sending component instance" --local_jobid="new jobId (Condor Globus ...)"` + EDG_WL_SEQUENCE=`${LBLOGEVENT} -j $1 -c $EDG_WL_SEQUENCE -s LogMonitor -e Transfer --destination="LRMS" --dest_host="destination hostname" --dest_instance="destination instance" --job="job description in receiver language" --result=OK --reason="detailed description of transfer" --dest_jobid="destination internal jobid"` + EDG_WL_SEQUENCE=`${LBLOGEVENT} -j $1 -c $EDG_WL_SEQUENCE -s LogMonitor -e Running --node="${CE_NODE:-worker node}"` +} + +running_to_done () { + + EDG_WL_SEQUENCE="UI=000003:NS=0000000004:WM=000010:BH=0000000000:JSS=000004:LM=000006:LRMS=000000:APP=000000:LBS=000000" + + EDG_WL_SEQUENCE=`${LBLOGEVENT} -j $1 -c $EDG_WL_SEQUENCE -s LogMonitor -e Done --status_code=OK --reason="reason for the change" --exit_code=0` + EDG_WL_SEQUENCE=`${LBLOGEVENT} -j $1 -c $EDG_WL_SEQUENCE -s LogMonitor -e Clear --reason=USER` +} + + + +# read common definitions and functions +COMMON=lb-common.sh +NOOFJOBS=10 +SEC_COVERAGE=600 +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 ;; + "-n" | "--noofjobs") shift ; NOOFJOBS=$1 ;; + *) EVENTFILE=$1 ;; + 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 $GRIDPROXYINFO $SYS_GREP $SYS_SED $LBJOBREG $SYS_AWK $LBJOBSTATUS $SYS_DATE $SYS_EXPR $LB_STATS $LB_FROMTO $SYS_BC +if [ $? -gt 0 ]; then + test_failed +else + test_done +fi + +printf "Testing credentials" + +timeleft=`${GRIDPROXYINFO} | ${SYS_GREP} -E "^timeleft" | ${SYS_SED} "s/timeleft\s*:\s//"` + +if [ "$timeleft" = "" ]; then + test_failed + print_error "No credentials" +else + if [ "$timeleft" = "0:00:00" ]; then + test_failed + print_error "Credentials expired" + else + test_done + + datestr=`$SYS_DATE +%Y%m%d%H%M` + + SEQUENCE=`eval "echo {1..${NOOFJOBS}}"` + + for i in $SEQUENCE + do + # Register job: + jobid[$i]=`${LBJOBREG} -m ${GLITE_WMS_QUERY_SERVER} -s application | ${SYS_GREP} "new jobid" | ${SYS_AWK} '{ print $3 }'` + + if [ -z ${jobid[$i]} ]; then + test_failed + print_error "Failed to register job" + fi + done + printf "Test jobs registered" + test_done + + sleep 10 + + printf "Sending events for all test jobs, Submitted => Running" + for i in $SEQUENCE + do + submitted_to_running ${jobid[$i]} + done + test_done + + sleep 10 + +# printf "Sending events for all test jobs, Running => Done" +# for i in $SEQUENCE +# do +# running_to_done ${jobid[$i]} +# done +# test_done + + expected_rate=`echo "scale=7;$NOOFJOBS/$SEC_COVERAGE" | bc` + printf "Getting job rate (should be around $expected_rate, testing if > 0): " + rate=`$LB_STATS -n $SEC_COVERAGE CE$datestr$$ 5 | ${SYS_GREP} "Average" | ${SYS_AWK} '{ print $6 }'` + cresult=`$SYS_EXPR $rate \> 0` + printf "$rate" + if [ "$cresult" -eq "1" ]; then + test_done + else + test_failed + print_error "Rate other than expected" + fi + printf "Getting average duration (should be a number > 10): " + average=`$LB_FROMTO CE$datestr$$ 1 5 | ${SYS_GREP} "Average duration" | ${SYS_AWK} '{ print $5 }'` + cresult=`$SYS_EXPR $average \> 10` + printf "$average" + if [ "$cresult" -eq "1" ]; then + test_done + else + test_failed + print_error "Average value other than expected" + fi + + + #Purge test job + joblist=$$_jobs_to_purge.txt + for i in $SEQUENCE + do + echo ${jobid[$i]} >> ${joblist} + done + try_purge ${joblist} + + fi +fi + +test_end +} &> $logfile + +if [ $flag -ne 1 ]; then + cat $logfile + $SYS_RM $logfile +fi +exit $TEST_OK + -- 1.8.2.3