Test-specific binary checking
authorZdeněk Šustr <sustr4@cesnet.cz>
Fri, 12 Sep 2008 09:47:33 +0000 (09:47 +0000)
committerZdeněk Šustr <sustr4@cesnet.cz>
Fri, 12 Sep 2008 09:47:33 +0000 (09:47 +0000)
org.glite.testsuites.ctb/LB/lb-common.sh
org.glite.testsuites.ctb/LB/lb-test-job-registration.sh
org.glite.testsuites.ctb/LB/lb-test-logger-local.sh
org.glite.testsuites.ctb/LB/lb-test-logger-remote.sh
org.glite.testsuites.ctb/LB/lb-test-normal-event-delivery-remote.sh
org.glite.testsuites.ctb/LB/lb-test-server-local.sh
org.glite.testsuites.ctb/LB/lb-test-server-remote.sh

index 4be088c..2a0f3fd 100755 (executable)
@@ -37,7 +37,11 @@ LB_LOGD=glite-lb-logd
 LB_INTERLOGD=glite-lb-interlogd
 LB_SERVER=glite-lb-bkserverd
 
-#grid binaries
+LB_READY_SH=glite-lb-ready.sh
+LB_RUNNING_SH=glite-lb-running.sh
+LB_DONE_SH=glite-lb-done.sh
+
+#general grid binaries
 GRIDPROXYINFO=grid-proxy-info
 
 # default LB ports
@@ -60,6 +64,7 @@ SYS_PIDOF=pidof
 SYS_MYSQLD=mysqld
 SYS_MYSQLADMIN=mysqladmin
 SYS_PING=ping
+SYS_AWK=awk
 
 # not used at the moment
 DEBUG=2
@@ -73,7 +78,7 @@ function ping_host()
        fi
        PING_HOST=$1
        # XXX: there might be a better way to test the network reachability
-       result=`ping -c 3 $PING_HOST 2>/dev/null | grep " 0% packet loss"| wc -l`
+       result=`${SYS_PING} -c 3 $PING_HOST 2>/dev/null | ${SYS_GREP} " 0% packet loss"| wc -l`
        if [ $result -gt 0 ]; then
                return $TEST_OK
        else 
@@ -102,7 +107,7 @@ function check_binaries()
 {
 # TODO: test only the binaries that are needed - it can differ in each test
        local ret=$TEST_OK
-       for file in $LBLOGEVENT $LBJOBLOG $LBJOBREG $LBUSERJOBS $LBJOBSTATUS $LBCHANGEACL $TEST_SOCKET $SYS_LSOF $SYS_GREP $SYS_SED $SYS_PS
+       for file in $@
        do      
                check_exec $file 
                if [ $? -gt 0 ]; then
@@ -180,3 +185,9 @@ function check_socket_listener()
 }
 
 #df /var/lib/mysql/ | tail -n 1 | awk '{ print $4 }'
+
+function test_args()
+{
+        echo $@
+}
+
index 074fb8b..6da1981 100755 (executable)
@@ -73,7 +73,7 @@ test_start
 
 # check_binaries
 printf "Testing if all binaries are available"
-check_binaries
+check_binaries $GRIDPROXYINFO $SYS_GREP $SYS_SED $SYS_AWK
 if [ $? -gt 0 ]; then
        test_failed
 else
@@ -82,35 +82,39 @@ fi
 
 printf "Testing credentials"
 
-proxysubject=`${GRIDPROXYINFO} | ${SYS_GREP} -E "^subject" | ${SYS_SED} "s/subject\s*:\s//"`
-if [ "$proxysubject" = "" ]; then
-       test_failed
-       print_error "No credentials"
-else
-       test_done
-
-
-       # Register job:
-       printf "Registering testing job "
-       jobid=`${LBJOBREG} -m ${EDG_WL_QUERY_SERVER} -s application | grep "new jobid" | awk '{ print $3 }'`
+timeleft=`${GRIDPROXYINFO} | ${SYS_GREP} -E "^timeleft" | ${SYS_SED} "s/timeleft\s*:\s//"`
 
-       if [ -z $jobid  ]; then
-               test_failed
-               print_error "Failed to register job"
-       else
-               test_done
-       fi
-
-       jobstate=`${LBJOBSTATUS} ${jobid} | grep "state :" | awk '{print $3}'`
-       printf "Is the testing job ($jobid) in a correct state? $jobstate"
-
-       if [ "${jobstate}" = "Submitted" ]; then
-               test_done
-       else
-               test_failed
-               print_error "Job has not been submitted"
+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
+
+               # Register job:
+               printf "Registering testing job "
+               jobid=`${LBJOBREG} -m ${EDG_WL_QUERY_SERVER} -s application | $SYS_GREP "new jobid" | ${SYS_AWK} '{ print $3 }'`
+
+               if [ -z $jobid  ]; then
+                       test_failed
+                       print_error "Failed to register job"
+               else
+                       test_done
+               fi
+
+               jobstate=`${LBJOBSTATUS} ${jobid} | $SYS_GREP "state :" | ${SYS_AWK} '{print $3}'`
+               printf "Is the testing job ($jobid) in a correct state? $jobstate"
+
+               if [ "${jobstate}" = "Submitted" ]; then
+                       test_done
+               else
+                       test_failed
+                       print_error "Job has not been submitted"
+               fi
        fi
-
 fi
 
 test_end
index 034742c..9a8f9dc 100755 (executable)
@@ -76,7 +76,7 @@ test_start
 
 # check_binaries
 printf "Testing if all binaries are available"
-check_binaries
+check_binaries $SYS_LSOF $SYS_GREP $SYS_SED $SYS_PS $SYS_MYSQLADMIN $SYS_PIDOF
 if [ $? -gt 0 ]; then
        test_failed
 else
@@ -85,7 +85,7 @@ fi
 
 # logger running:
 printf "Testing if LB logger is running"
-if [ "$(pidof ${LB_LOGD})" ]; then
+if [ "$(${SYS_PIDOF} ${LB_LOGD})" ]; then
        test_done
 else
        test_failed
@@ -104,7 +104,7 @@ fi
 
 # interlogger running:
 printf "Testing if Interlogger is running"
-if [ "$(pidof ${LB_INTERLOGD})" ]; then
+if [ "$(${SYS_PIDOF} ${LB_INTERLOGD})" ]; then
        test_done
 else
        test_failed
index b4259e5..28ebd84 100755 (executable)
@@ -82,7 +82,7 @@ test_start
 
 # check_binaries
 printf "Testing if all binaries are available"
-check_binaries
+check_binaries $TEST_SOCKET $SYS_PING $SYS_GREP
 if [ $? -gt 0 ]; then
         test_failed
        print_error "Some binaries are missing"
index b38ffd7..20085fb 100755 (executable)
@@ -77,7 +77,7 @@ test_start
 
 # check_binaries
 printf "Testing if all binaries are available"
-check_binaries
+check_binaries $GRIDPROXYINFO $SYS_GREP $SYS_SED $LBJOBREG $SYS_AWK $LB_READY_SH $LB_RUNNING_SH $LB_DONE_SH $SYS_AWK 
 if [ $? -gt 0 ]; then
        test_failed
 else
@@ -86,64 +86,69 @@ fi
 
 printf "Testing credentials"
 
-proxysubject=`${GRIDPROXYINFO} | ${SYS_GREP} -E "^subject" | ${SYS_SED} "s/subject\s*:\s//"`
-if [ "$proxysubject" = "" ]; then
+timeleft=`${GRIDPROXYINFO} | ${SYS_GREP} -E "^timeleft" | ${SYS_SED} "s/timeleft\s*:\s//"`
+
+if [ "$timeleft" = "" ]; then
        test_failed
        print_error "No credentials"
 else
-       test_done
-
-
-       # Register job:
-       printf "Registering testing job "
-       jobid=`${LBJOBREG} -m ${EDG_WL_QUERY_SERVER} -s application | grep "new jobid" | awk '{ print $3 }'`
-
-       if [ -z $jobid  ]; then
+       if [ "$timeleft" = "0:00:00" ]; then
                test_failed
-               print_error "Failed to register job"
+               print_error "Credentials expired"
        else
                test_done
-               printf "\nRegistered job: $jobid\n"
-       fi
 
-       # log events:
-       printf "Logging events resulting in READY state\n"
-       glite-lb-ready.sh -j ${jobid} > /dev/null 2> /dev/null
 
-       printf "Sleeping for 10 seconds (waiting for events to deliver)...\n"
+               # Register job:
+               printf "Registering testing job "
+               jobid=`${LBJOBREG} -m ${EDG_WL_QUERY_SERVER} -s application | ${SYS_GREP} "new jobid" | ${SYS_AWK} '{ print $3 }'`
 
-       sleep 10
+               if [ -z $jobid  ]; then
+                       test_failed
+                       print_error "Failed to register job"
+               else
+                       test_done
+                       printf "\nRegistered job: $jobid\n"
+               fi
 
-       jobstate=`${LBJOBSTATUS} ${jobid} | grep "state :" | awk '{print $3}'`
-       printf "Is the testing job ($jobid) in a correct state? $jobstate"
+               # log events:
+               printf "Logging events resulting in READY state\n"
+               $LB_READY_SH -j ${jobid} > /dev/null 2> /dev/null
 
-       if [ "${jobstate}" = "Ready" ]; then
-               test_done
-       else
-               test_failed
-               print_error "Job is not in appropriate state"
-       fi
+               printf "Sleeping for 10 seconds (waiting for events to deliver)...\n"
 
-       printf "Logging events resulting in RUNNING state\n"
-       glite-lb-running.sh -j ${jobid} > /dev/null 2> /dev/null
+               sleep 10
 
-       printf "Logging events resulting in DONE state\n"
-       glite-lb-done.sh -j ${jobid} > /dev/null 2> /dev/null
+               jobstate=`${LBJOBSTATUS} ${jobid} | ${SYS_GREP} "state :" | ${SYS_AWK} '{print $3}'`
+               printf "Is the testing job ($jobid) in a correct state? $jobstate"
 
-       printf "Sleeping for 10 seconds (waiting for events to deliver)...\n"
+               if [ "${jobstate}" = "Ready" ]; then
+                       test_done
+               else
+                       test_failed
+                       print_error "Job is not in appropriate state"
+               fi
 
-       sleep 10
+               printf "Logging events resulting in RUNNING state\n"
+               $LB_RUNNING_SH -j ${jobid} > /dev/null 2> /dev/null
 
-       jobstate=`${LBJOBSTATUS} ${jobid} | grep "state :" | awk '{print $3}'`
-       printf "Testing job ($jobid) is in state: $jobstate\n"
+               printf "Logging events resulting in DONE state\n"
+               $LB_DONE_SH -j ${jobid} > /dev/null 2> /dev/null
 
-       if [ "${jobstate}" = "Done" ]; then
-               test_done
-       else
-               test_failed
-               print_error "Job is not in appropriate state"
-       fi
+               printf "Sleeping for 10 seconds (waiting for events to deliver)...\n"
+
+               sleep 10
 
+               jobstate=`${LBJOBSTATUS} ${jobid} | ${SYS_GREP} "state :" | ${SYS_AWK} '{print $3}'`
+               printf "Testing job ($jobid) is in state: $jobstate\n"
+
+               if [ "${jobstate}" = "Done" ]; then
+                       test_done
+               else
+                       test_failed
+                       print_error "Job is not in appropriate state"
+               fi
+       fi
 fi
 
 test_end
index da45f24..8a095a5 100755 (executable)
@@ -76,7 +76,7 @@ test_start
 
 # check_binaries
 printf "Testing if all binaries are available"
-check_binaries
+check_binaries $SYS_LSOF $SYS_GREP $SYS_SED $SYS_PS $SYS_MYSQLADMIN $SYS_PIDOF
 if [ $? -gt 0 ]; then
        test_failed
 else
@@ -143,7 +143,7 @@ fi
 
 # Interlogger running:
 printf "Testing if Interlogger is running"
-if [ "$(pidof ${LB_INTERLOGD})" ]; then
+if [ "$(${SYS_PIDOF} ${LB_INTERLOGD})" ]; then
        test_done
 else
        test_failed
index 2fabbf0..d558f16 100755 (executable)
@@ -83,7 +83,7 @@ test_start
 
 # check_binaries
 printf "Testing if all binaries are available"
-check_binaries
+check_binaries $TEST_SOCKET $SYS_PING $SYS_GREP
 if [ $? -gt 0 ]; then
        test_failed
        print_error "Some binaries are missing"