Job Registration test extended to cover JobID reuse with/without the 'exclusive'...
authorZdeněk Šustr <sustr4@cesnet.cz>
Tue, 8 Jun 2010 10:08:20 +0000 (10:08 +0000)
committerZdeněk Šustr <sustr4@cesnet.cz>
Tue, 8 Jun 2010 10:08:20 +0000 (10:08 +0000)
org.glite.testsuites.ctb/LB/tests/lb-common.sh
org.glite.testsuites.ctb/LB/tests/lb-test-job-registration.sh
org.glite.testsuites.ctb/LB/tests/test-common.sh

index b418bb1..55bcb8b 100755 (executable)
@@ -57,6 +57,7 @@ LBPARSEEFILE=glite-lb-parse_eventsfile
 LB4AGUACTINFO=glite-lb-ws_lb4agu_GetActivityInfo
 LB4AGUACTSTATUS=glite-lb-ws_lb4agu_GetActivityStatus
 LBREGSANDBOX=glite-lb-register_sandbox
+LBHISTORY=glite-lb-state_history
 
 LB_LOGD=glite-lb-logd 
 LB_INTERLOGD=glite-lb-interlogd
@@ -100,6 +101,8 @@ SYS_RM="rm -f"
 SYS_CHMOD=chmod
 SYS_LDAPSEARCH=ldapsearch
 SYS_CAT=cat
+SYS_NL=nl
+SYS_TAIL=tail
 
 # not used at the moment
 DEBUG=2
index ec70aa3..b268eed 100755 (executable)
@@ -132,10 +132,75 @@ else
                                print_error "Job has not been submitted"
                        fi
 
+                       printf "Trying to re-register job with the same jobid..."
+                       ${LBJOBREG} -m ${GLITE_WMS_QUERY_SERVER} -s application -j $jobid > /dev/null
+
+                       noofevents=`${LBHISTORY} $jobid | $SYS_NL | $SYS_TAIL -n 1 | ${SYS_AWK} '{print $1}'`
+
+                       printf "(Event No. $noofevents)..."             
+       
+                       if [ "${noofevents}" = "2" ]; then
+                               test_done
+                       else
+                               test_failed
+                               print_error "Second registration did not take place"
+                       fi
+
+
+                       printf "Trying to re-register job with the same jobid, 'exclusive' flag on..."
+                       ${LBJOBREG} -m ${GLITE_WMS_QUERY_SERVER} -s application -j $jobid -E > /dev/null
+
+                       noofevents=`${LBHISTORY} $jobid | $SYS_NL | $SYS_TAIL -n 1 | ${SYS_AWK} '{print $1}'`
+
+                       printf "(Event No. $noofevents)..."             
+       
+                       if [ "${noofevents}" = "2" ]; then
+                               test_done
+                       else
+                               test_failed
+                               print_error "Wrong number of registration events"
+                       fi
+
+
                        #Purge test job
                        joblist=$$_jobs_to_purge.txt
                        echo $jobid > ${joblist}
-                       try_purge ${joblist}
+                       ${LBPURGE} -j ${joblist} > /dev/null
+                       $SYS_RM ${joblist}
+
+                       jobstate=`${LBJOBSTATUS} ${jobid} | $SYS_GREP "state :" | ${SYS_AWK} '{print $3}'`
+                        printf "Test job purged. Testing state... ($jobstate)"
+
+                        if [ "${jobstate}" = "Purged" ]; then
+                                test_done
+
+
+                               ${LBJOBREG} -h 2>&1 | $SYS_GREP '\-E' > /dev/null
+
+                               if [ $? = 0 ]; then
+                                       printf "Trying to re-register. Same JobID, exclusive flag..."
+                                       ${LBJOBREG} -m ${GLITE_WMS_QUERY_SERVER} -s application -j $jobid -E > /dev/null
+                                       jobstate=`${LBJOBSTATUS} ${jobid} | $SYS_GREP "state :" | ${SYS_AWK} '{print $3}'`
+
+                                       if [ "${jobstate}" = "Purged" ]; then
+                                               test_done
+                                       else
+                                               test_failed
+                                               print_error "Job has not remained in purged state"
+                                       fi
+
+                               else
+                                       printf "Client does not support the 'exclusive' flag."
+                                       test_skipped
+                               fi
+
+
+                        else
+                                printf "Job has not been purged, re-registration test will be skipped"
+
+                               test_skipped
+                        fi
+
 
                fi
 
index 327a5c8..f0ca470 100644 (file)
@@ -205,7 +205,10 @@ function update_error()
 function print_error()
 {
        printf "${begin_red}Error${end_red}: %s ${lf}" "$*"
-       printf "${begin_red}Error${end_red}: %s ${lf}" "`cat $testerrfile`"
+
+       if [ -f $testerrfile ]; then
+               printf "${begin_red}Error${end_red}: %s ${lf}" "`cat $testerrfile`"
+       fi
        reset_error
 }