Layer 2 tests
authorsrugovac <>
Wed, 14 Mar 2007 13:15:56 +0000 (13:15 +0000)
committersrugovac <>
Wed, 14 Mar 2007 13:15:56 +0000 (13:15 +0000)
org.glite.testsuites.ctb/LB/lb-l2.sh [new file with mode: 0755]
org.glite.testsuites.ctb/LB/lb-l2Stat.sh [new file with mode: 0755]

diff --git a/org.glite.testsuites.ctb/LB/lb-l2.sh b/org.glite.testsuites.ctb/LB/lb-l2.sh
new file mode 100755 (executable)
index 0000000..69f6a25
--- /dev/null
@@ -0,0 +1,253 @@
+#!/bin/bash
+#3.1.4 et 3.2.1: Normal event delivery and Normal Job States
+
+#Prerequisities: All services running 
+
+#Actions:
+#Registers jobs with glite-lb-job-reg prferably pointing to remote LB Server
+#Check of the job status
+#Logs sequences of events with glite-lb-logevent
+#Checks with glite-lb-job_log that the events got delivered aftewards
+#Checks with glite-lb-job_status that the status of the jobs are correct
+
+
+PATH=/opt/glite/examples:$PATH
+#echo $PATH
+LBJOBREG=${LBJOBREG:-glite-lb-job_reg}
+LBLOGEVENT=${LBLOGEVENT:-glite-lb-logevent}
+LBJOBSTATUS=${LBJOBSTATUS:-glite-lb-job_status}
+LBJOBLOG=${LBJOBLOG:-glite-lb-job_log}
+LBJOBSTAT=${LBJOBSTAT:-glite-lb-job_status}
+LBPURGE=${PURGE:-glite-lb-purge}
+
+BKSERVER="pc900.iihe.ac.be"
+STATES="aborted cancelled done ready running scheduled waiting submitted "
+SOURCES="NetworkServer WorkloadManager BigHelper JobController LogMonitor LRMS Application UserInterface"
+
+stest=1
+i=0
+JOBS_ARRAY_SIZE=10
+INTERVAL=2
+
+init()
+{
+export EDG_WL_QUERY_SERVER="$BKSERVER:9000"
+export EDG_WL_LOG_DESTINATION="$BKSERVER:9002"
+BKSERVER_HOST="$BKSERVER:9000"
+BKSERVER_OPT="-m $BKSERVER"
+}
+
+
+getJobId()
+{
+cat jobreg |grep "EDG_JOBID" |cut -c12- > jobList2
+res=`cat jobList2 |wc -c`
+res=$[$res-2]
+cat jobList2 |cut -c1-`echo $res` > jobreg
+rm jobList2
+}
+
+#registrating a job
+job_reg()
+{
+eval $LBJOBREG -m pc900.iihe.ac.be:9000  -s userInterface > jobreg
+getJobId
+job=`cat jobreg`
+rm jobreg
+}
+
+#registering a list of jobs which jobid's are placed in an array
+array_job_reg()
+{
+echo "Registering $JOBS_ARRAY_SIZE jobs...................."
+job_id=0
+st_count=`echo $SOURCES | wc -w`
+while [ $job_id -lt $JOBS_ARRAY_SIZE ] ; do
+        tmp=`echo $RANDOM % $st_count + 1 | bc`
+        jsource=`echo $SOURCES | cut -d " " -f $tmp | tr A-Z a-z`
+        job_reg $jsource
+        echo $job
+        SAMPLE_JOBS_ARRAY[$job_id]=$job
+        job_id=$[$job_id+1]
+        done
+}
+
+#Event delivery  test
+testLB()
+{
+echo "Checking the Events............................................."
+echo
+job_id=0
+while [ $job_id -lt $JOBS_ARRAY_SIZE ] ; do
+       #sleep 2
+       dtest=0
+       #out is the list of events sent, we count the number of events and then we extract the job status
+       nbEvents=`cat out[$job_id] |grep glite-lb-logevent | wc -l`
+       nbEvents=$[$nbEvents+1]
+       cat out[$job_id] |gawk -F"-e " '{ print $2 }' > eventsTemp
+       echo "UserTag"> events
+       echo "RegJob">> events
+       cat eventsTemp|gawk -F" --" '{ print $1 }'>> events
+       rm eventsTemp
+       events3="blank"
+        i=0
+        cmp -s events events3
+       while [ $? -ne 0 ] && [ $i -lt $INTERVAL ] ; do
+
+
+       #we use glite-lb-job_log and apply the same treatment as above to the output
+               eval $LBJOBLOG -r $INTERVAL -d 2  ${SAMPLE_JOBS_ARRAY[$job_id]} > joblog2
+               nbevents=`cat joblog2 | grep DATE | wc -l`
+               cat joblog2|gawk -F"DG.EVNT=\"" '{ print $2 }' > eventsTemp2
+               cat eventsTemp2|gawk -F"\"" '{ print $1 }'> events2
+               cat events2|sed /^$/d > events3
+               rm eventsTemp2 events2 joblog2
+               #Comparison of the outputs and intermediary printout
+               echo "Events Sent....." >> LoggedEvents.log
+               cat -n events >> LoggedEvents.log
+#              cat -n events
+               echo "Events recorded in the LB server....." >> LoggedEvents.log
+               cat -n events3 >> LoggedEvents.log
+#              cat -n events3
+               i=$[$i+1]
+               cmp -s events events3
+       done
+       cmp -s events events3
+       if [ $? -eq 0 ]; then
+               dtest=1
+               echo "Job $job_id ....................[OK]"  
+               i=0
+
+       else
+               echo "Job $job_id.....................[FAILED]" 
+       fi
+       rm events events3 out[$job_id]
+       job_id=$[$job_id+1]
+done
+echo
+echo "A detailed list of events logged has been printed to LoggedEvents.log"
+echo
+}
+
+#job status test
+testLB2()
+{
+echo "Checking the Jobs Status........................................" 
+echo
+job_id=0
+ while [ $job_id -lt $JOBS_ARRAY_SIZE ] ; do
+        #sleep 1
+        eval $LBJOBSTATUS ${SAMPLE_JOBS_ARRAY[$job_id]} > status
+        testStatus=`cat status |grep -i state.*${SAMPLE_JOBS_STATES[$job_id]}|wc -l`
+       i=0
+       while [ $testStatus -ne 1 ] && [ $i -lt $INTERVAL ] ; do
+               bkserver_state=`cat status |grep -i state.*${SAMPLE_JOBS_STATES[$job_id]}`
+                testStatus=`cat status |grep -i state.*${SAMPLE_JOBS_STATES[$job_id]}|wc -l`
+               i=$[$i+1]
+       done
+       if [$testStatus -eq 1 ] ; then
+               echo "Job: $job_id ..Logged state:${SAMPLE_JOBS_STATES[$job_id]}-Recorded `cat status |grep -i state.*${SAMPLE_JOBS_STATES[$job_id]}`.......[OK]"
+        else
+               echo "Job: $job_id ..Logged state:${SAMPLE_JOBS_STATES[$job_id]}-Recorded `cat status |grep -i state.*${SAMPLE_JOBS_STATES[$job_id]}`.......[FAILED]"
+               cat status > errorStatus.tmp
+               echo "Detailed status has been copied to errorStatus.tmp"
+               echo
+                dtest=0
+        fi
+       rm status
+job_id=$[$job_id+1]
+done
+}
+showHelp()
+{
+        echo  "Usage: $0 [OPTIONS] "
+        echo  "Options:"
+        echo  " -h | --help                   Show this help message."
+        echo  " -r | --retries                Number of test retries (2 by default)"
+       echo  " -n | --nbjobs                 Number of jobs (10 by default)"
+       echo  " -m | --bkserver               Host address of the BKServer ex:pc900.iihe.ac.be "
+        echo  " -s | --states                 List of states in which could tested jobs fall."
+       echo  " -l | --large-stress 'size'    Do a large stress logging ('size' random data added to the messages."
+        echo  ""
+
+#       echo  "For proper operation check your grid-proxy-info"
+#       grid-proxy-info
+}
+
+#logging events to the jobs. Events are selected randomly from a list.
+logEvents()
+{
+echo "Logging events to the $JOBS_ARRAY_SIZE jobs...................................."
+echo
+job_id2=0
+st_count=`echo $STATES | wc -w`
+       while [ $job_id2 -lt $JOBS_ARRAY_SIZE ] ; do
+        tmp=`echo $RANDOM % $st_count + 1 | bc`
+        state=`echo $STATES | cut -d " " -f $tmp | tr A-Z a-z`
+       SAMPLE_JOBS_STATES[$job_id2]=$state
+       echo > LoggedEvents.log
+       echo "Submitting events to the job: ${SAMPLE_JOBS_ARRAY[$job_id2]} " >> LoggedEvents.log
+       echo >> LoggedEvents.log
+
+       echo "event submitted.......................................[$state]" >> LoggedEvents.log
+       eval glite-lb-$state.sh $LARGE_STRESS -j ${SAMPLE_JOBS_ARRAY[$job_id2]} 2>out[$job_id2]
+       job_id2=$(($job_id2 + 1))
+done
+}
+
+#logging tags to the jobs
+logTags()
+{
+echo "Logging tags to the $JOBS_ARRAY_SIZE jobs...................................."
+echo
+
+job_id=0
+while [ $job_id -lt $JOBS_ARRAY_SIZE ] ; do
+       eval $LBLOGEVENT -s Application -e UserTag -j ${SAMPLE_JOBS_ARRAY[$job_id]} -name testTag -value 12345  >> LoggedEvents.log
+job_id=$[$job_id+1]
+done
+}
+
+
+
+#input
+if [ -z "$1" ]; then
+  showHelp
+  exit 2
+fi
+while test -n "$1"
+do
+        case "$1" in
+        "-h" | "--help") showHelp && exit 2 ;;
+        "-r" | "--retries") shift ; INTERVAL=$1 ;;
+       "-n" | "--nbjobs") shift ; JOBS_ARRAY_SIZE=$1 ;;
+        "-m" | "--bkserver") shift ; BKSERVER=$1 ;;
+        "-s" | "--states") shift; STATES="$1" ;;
+       "-l" | "--large-stress") shift ; LARGE_STRESS="-l $1" ;;
+#       "-g" | "--log") shift ; logfile=$1 ;;
+
+        *) echo "Unrecognized option $1 try -h for help"; exit 2 ;;
+
+        esac
+        shift
+done
+echo
+
+
+#main..................................................................
+init
+array_job_reg
+logEvents
+logTags
+testLB
+testLB2
+#testProxy
+#eval $LBPURGE -h
+echo
+if [ $stest -eq 1  ];then
+        echo "Final test result .........................................[OK]"
+       exit 1
+else   echo "Final test result .........................................[FAILED]"
+       exit 0
+ fi
+echo
diff --git a/org.glite.testsuites.ctb/LB/lb-l2Stat.sh b/org.glite.testsuites.ctb/LB/lb-l2Stat.sh
new file mode 100755 (executable)
index 0000000..1e5d9e2
--- /dev/null
@@ -0,0 +1,217 @@
+#!/bin/bash
+# Normal event delivery and Normal Job States with internal BKsrever performance
+
+#Prerequisities: All services running 
+#Actions:
+#Registers jobs with glite-lb-job-reg prferably pointing to remote LB Server
+#Check of the job status
+#Logs sequences of events with glite-lb-logevent
+#Check with glite-lb-job_status that the status of the jobs are correct and mesures how long it took to get results
+
+
+PATH=/opt/glite/examples:$PATH
+#echo $PATH
+LBJOBREG=${LBJOBREG:-glite-lb-job_reg}
+LBLOGEVENT=${LBLOGEVENT:-glite-lb-logevent}
+LBJOBSTATUS=${LBJOBSTATUS:-glite-lb-job_status}
+LBJOBLOG=${LBJOBLOG:-glite-lb-job_log}
+LBJOBSTAT=${LBJOBSTAT:-glite-lb-job_status}
+LBPURGE=${PURGE:-glite-lb-purge}
+
+# -m host
+BKSERVER="pc900.iihe.ac.be"
+STATES="aborted cancelled done ready running scheduled waiting submitted "
+SOURCES="NetworkServer WorkloadManager BigHelper JobController LogMonitor LRMS Application UserInterface"
+
+stest=1
+i=0
+JOBS_ARRAY_SIZE=10
+# timeouts for polling the bkserver
+timeout=10
+maxtimeout=300
+NB_TAGS=50
+INTERVAL=2
+
+init()
+{
+export EDG_WL_QUERY_SERVER="$BKSERVER:9000"
+export EDG_WL_LOG_DESTINATION="$BKSERVER:9002"
+BKSERVER_HOST="$BKSERVER:9000"
+BKSERVER_OPT="-m $BKSERVER"
+}
+
+get_time()
+{
+    sec=`date +%s`
+    nsec=`date +%N`
+    time=`echo "1000000000*$sec + $nsec"|bc`
+#    time=$sec
+    return 0
+}
+
+getJobId()
+{
+cat jobreg |grep "EDG_JOBID" |cut -c12- > jobList2
+res=`cat jobList2 |wc -c`
+res=$[$res-2]
+cat jobList2 |cut -c1-`echo $res` > jobreg
+rm jobList2
+}
+
+#registrating a job
+job_reg()
+{
+eval $LBJOBREG -m pc900.iihe.ac.be:9000  -s userInterface > jobreg
+getJobId
+job=`cat jobreg`
+rm jobreg
+}
+
+array_job_reg()
+{
+echo "Registering $JOBS_ARRAY_SIZE jobs...................."
+job_id=0
+st_count=`echo $SOURCES | wc -w`
+while [ $job_id -lt $JOBS_ARRAY_SIZE ] ; do
+        tmp=`echo $RANDOM % $st_count + 1 | bc`
+        jsource=`echo $SOURCES | cut -d " " -f $tmp | tr A-Z a-z`
+        job_reg $jsource
+        echo $job
+        SAMPLE_JOBS_ARRAY[$job_id]=$job
+        job_id=$[$job_id+1]
+        done
+}
+
+#job status test
+testLBP()
+{
+echo "Checking the Events............................................."
+echo
+job_id=0
+while [ $job_id -lt $JOBS_ARRAY_SIZE ] ; do
+       get_time
+       start=$time
+       logEvent $job_id
+       logTag $job_id
+       
+       
+       eval $LBJOBSTATUS ${SAMPLE_JOBS_ARRAY[$job_id]} > status
+        testStatus=`cat status |grep -i state.*${SAMPLE_JOBS_STATES[$job_id]}|wc -l`
+       response=0
+        while [ $testStatus -ne 1 ];do
+               bkserver_state=`cat status |grep -i state.*${SAMPLE_JOBS_STATES[$job_id]}`
+               testStatus=`cat status |grep -i state.*${SAMPLE_JOBS_STATES[$job_id]}|wc -l`
+               echo "**Retrying**"
+               sleep $timeout
+               response=$(($response + $timeout ))
+               if test $response -gt $maxtimeout ; then
+                       echo -e "ERROR\n\tstatus of job ${SAMPLE_JOBS_ARRAY[$job_id]} as queried from bkserver ($bkserver_state) has not become ${SAMPLE_JOBS_STATES[$job_id]} for more than $response seconds!"
+                       echo "Detailed status has been copied to errorStatus.tmp"
+                       echo
+                       dtest=0
+                       exit 1;
+               fi      
+       done
+       get_time
+       response=`echo "scale=9; ($time - $start)/1000000000"|bc`
+       SAMPLE_JOBS_RESPONSES[$job_id]=$response
+        echo "Job: $job_id ....[`cat status |grep -i state.*${SAMPLE_JOBS_STATES[$job_id]}`].......[OK]"
+       echo
+       rm status
+        job_id=$[$job_id+1]
+       done
+       j=0
+        total=0
+        echo "Sending events took for individual jobs the following time"
+        while [ $j -lt $JOBS_ARRAY_SIZE ] ; do
+                total=`echo "scale=9; $total + ${SAMPLE_JOBS_RESPONSES[$j]}" |bc`
+                echo -e "${SAMPLE_JOBS_ARRAY[$j]} \t${SAMPLE_JOBS_RESPONSES[$j]} seconds"
+                        j=$(($j + 1))
+        done
+       echo -e "Total time for $JOBS_ARRAY_SIZE jobs: \t$total"
+       echo -e -n "Average time for event: \t" 
+       echo "scale=9; $total / $JOBS_ARRAY_SIZE "|bc
+        echo -e -n "Average time for event and tags: \t" 
+        echo "scale=9; $total / $JOBS_ARRAY_SIZE / $NB_TAGS"|bc
+       echo -e -n "Event throughput (events/sec): \t"
+       echo "scale=9; $NB_TAGS * $JOBS_ARRAY_SIZE / $total"|bc
+       echo
+       echo "A detailed list of events logged has been printed to LoggedEvents.log"
+       echo
+}
+
+showHelp()
+{
+        echo  "Usage: $0 [OPTIONS] "
+        echo  "Options:"
+        echo  " -h | --help                   Show this help message."
+       echo  " -n | --nbjobs                 Number of jobs"
+        echo  " -s | --states                 List of states in which could tested jobs fall."
+       echo  " -m | --bkserver               Host address of the BKServer "
+       echo  " -t | --tags                   Number of user tags to load to each job."
+       echo  " -l | --large-stress 'size'    Do a large stress logging ('size' rand om data added to the messages."
+        echo  ""
+
+#       echo  "For proper operation check your grid-proxy-info"
+#       grid-proxy-info
+}
+
+logEvent()
+#ARG1: Number of the job considered in the jobs array
+{
+st_count=`echo $STATES | wc -w`
+tmp=`echo $RANDOM % $st_count + 1 | bc`
+state=`echo $STATES | cut -d " " -f $tmp | tr A-Z a-z`
+SAMPLE_JOBS_STATES[$1]=$state
+echo "Logging event to the job($1).........................[$state]"
+echo > LoggedEvents.log
+echo "Submitting events to the job: ${SAMPLE_JOBS_ARRAY[$1]} " >> LoggedEvents.log
+echo >> LoggedEvents.log
+echo "event submitted.......................................[$state]" >> LoggedEvents.log
+eval glite-lb-$state.sh $LARGE_STRESS -j ${SAMPLE_JOBS_ARRAY[$1]} 2>out
+}
+logTag()
+{
+i=0
+echo "Logging $NB_TAGS tags to the job................"
+eval $LBLOGEVENT -s Application -n $NB_TAGS -e UserTag -j ${SAMPLE_JOBS_ARRAY[$1]} -name testTag -value 12345  >> LoggedEvents.log
+}
+
+
+
+#input
+if [ -z "$1" ]; then
+  showHelp
+  exit 2
+fi
+while test -n "$1"
+do
+        case "$1" in
+        "-h" | "--help") showHelp && exit 2 ;;
+       "-n" | "--nbjobs") shift ; JOBS_ARRAY_SIZE=$1 ;;
+       "-s" | "--states") shift; STATES="$1" ;;
+        "-m" | "--bkserver") shift ; BKSERVER_HOST=$1 ;;
+       "-t" | "--tags") shift ; NB_TAGS=$1 ;;
+       "-l" | "--large-stress") shift ; LARGE_STRESS="-l $1" ;;
+#       "-g" | "--log") shift ; logfile=$1 ;;
+
+        *) echo "Unrecognized option $1 try -h for help"; exit 2 ;;
+
+        esac
+        shift
+done
+
+echo "Test of job status with several jobs "
+echo "***********************************"
+echo
+init
+array_job_reg
+testLBP
+echo
+if [ $stest -eq 1  ];then
+        echo "Final test result .........................................[OK]"
+       exit 1
+else   echo "Final test result .........................................[FAILED]"
+       exit 0
+ fi
+echo