Support for new handling of zombies (EIDRM instead of state 'Purged')
authorZdeněk Šustr <sustr4@cesnet.cz>
Tue, 8 Feb 2011 14:47:00 +0000 (14:47 +0000)
committerZdeněk Šustr <sustr4@cesnet.cz>
Tue, 8 Feb 2011 14:47:00 +0000 (14:47 +0000)
org.glite.testsuites.ctb/LB/tests/lb-test-event-delivery.sh
org.glite.testsuites.ctb/LB/tests/lb-test-job-registration.sh
org.glite.testsuites.ctb/LB/tests/lb-test-purge.pl

index 8b6291e..3bc6a2e 100755 (executable)
@@ -265,15 +265,28 @@ else
 
                        printf "Checking state of collection... " 
 
-                        jobstate=`${LBJOBSTATUS} $jobid | ${SYS_GREP} -E "^state :" | ${SYS_AWK} '{print $3}'`
-                        if [ "${jobstate}" = "Purged" ]; then
-                               printf "${jobstate}"
+                       ${LBJOBSTATUS} $jobid > $$_collstate.tmp 2> $$_collstate_err.tmp
+                        jobstate=`$SYS_CAT $$_collstate.tmp | ${SYS_GREP} -E "^state :" | ${SYS_AWK} '{print $3}' 2> $$_collstate.tmp`
+                       $SYS_GREP "Identifier removed" $$_collstate_err.tmp > /dev/null
+                        if [ "$?" = "0" -o "${jobstate}" = "Purged" ]; then
+
+                               if [ "${jobstate}" = "Purged" ]; then
+                                       printf "${jobstate}"
+                               else
+                                       printf "Identifier removed"
+                               fi
                                 test_done
 
                                printf "Checking state of subjob #1... "
-                               jobstate=`${LBJOBSTATUS} ${subjobs[0]} | ${SYS_GREP} -E "^state :" | ${SYS_AWK} '{print $3}'`
-                               if [ "${jobstate}" = "Purged" ]; then
-                                       printf "${jobstate}"
+                               ${LBJOBSTATUS} ${subjobs[0]} > $$_collstate.tmp 2> $$_collstate_err.tmp
+                               jobstate=`$SYS_CAT $$_collstate.tmp | ${SYS_GREP} -E "^state :" | ${SYS_AWK} '{print $3}' 2> $$_collstate.tmp`
+                               $SYS_GREP "Identifier removed" $$_collstate_err.tmp > /dev/null
+                               if [ "$?" = "0" -o "${jobstate}" = "Purged" ]; then
+                                       if [ "${jobstate}" = "Purged" ]; then
+                                               printf "${jobstate}"
+                                       else
+                                               printf "Identifier removed"
+                                       fi
                                        test_done
                                else
                                        test_failed
@@ -281,9 +294,15 @@ else
                                fi
 
                                printf "Checking state of subjob #2... "
-                               jobstate=`${LBJOBSTATUS} ${subjobs[1]} | ${SYS_GREP} -E "^state :" | ${SYS_AWK} '{print $3}'`
-                               if [ "${jobstate}" = "Purged" ]; then
-                                       printf "${jobstate}"
+                               ${LBJOBSTATUS} ${subjobs[1]} > $$_collstate.tmp 2> $$_collstate_err.tmp
+                               jobstate=`$SYS_CAT $$_collstate.tmp | ${SYS_GREP} -E "^state :" | ${SYS_AWK} '{print $3}' 2> $$_collstate.tmp`
+                               $SYS_GREP "Identifier removed" $$_collstate_err.tmp > /dev/null
+                               if [ "$?" = "0" -o "${jobstate}" = "Purged" ]; then
+                                       if [ "${jobstate}" = "Purged" ]; then
+                                               printf "${jobstate}"
+                                       else
+                                               printf "Identifier removed"
+                                       fi
                                        test_done
                                else
                                        test_failed
@@ -296,6 +315,8 @@ else
                         fi
 
                        $SYS_RM $$_jobs_to_purge_test.txt
+                       $SYS_RM $$_collstate.tmp
+                       $SYS_RM $$_collstate_err.tmp
                        
                 fi
 
index 82b21f1..dd3bee4 100755 (executable)
@@ -178,13 +178,13 @@ else
                        ${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
+                        printf "Test job purged. Testing state..."
+                        ${LBJOBSTATUS} $jobid > $$_jobreg.tmp 2> $$_jobreg_err.tmp
+                        jobstate=`$SYS_CAT $$_jobreg.tmp | ${SYS_GREP} -E "^state :" | ${SYS_AWK} '{print $3}' 2> $$_jobreg.tmp`
+                        $SYS_GREP "Identifier removed" $$_jobreg_err.tmp > /dev/null
+                        if [ "$?" = "0" -o "${jobstate}" = "Purged" ]; then
                                 test_done
 
-
                                ${LBJOBREG} -h 2>&1 | $SYS_GREP '\-E' > /dev/null
 
                                if [ $? = 0 ]; then
@@ -198,10 +198,11 @@ else
                                                test_done
                                        fi
 
-                                       printf "Checking state (expecting state 'Purged'). "
-                                       jobstate=`${LBJOBSTATUS} ${jobid} | $SYS_GREP "state :" | ${SYS_AWK} '{print $3}'`
-
-                                       if [ "${jobstate}" = "Purged" ]; then
+                                       printf "Checking state (expecting state 'Purged' or EIDRM). "
+                                       ${LBJOBSTATUS} $jobid > $$_jobreg.tmp 2> $$_jobreg_err.tmp
+                                       jobstate=`$SYS_CAT $$_jobreg.tmp | ${SYS_GREP} -E "^state :" | ${SYS_AWK} '{print $3}' 2> $$_jobreg.tmp`
+                                       $SYS_GREP "Identifier removed" $$_jobreg_err.tmp > /dev/null
+                                       if [ "$?" = "0" -o "${jobstate}" = "Purged" ]; then
                                                test_done
                                        else
                                                printf " Option may be off on server side"
@@ -247,6 +248,8 @@ else
                                test_skipped
                         fi
 
+                        $SYS_RM $$_jobreg.tmp
+                        $SYS_RM $$_jobreg_err.tmp
 
                fi
 
@@ -256,11 +259,12 @@ else
 fi
 
 test_end
-} &> $logfile
+}
+#} &> $logfile
 
-if [ $flag -ne 1 ]; then
-       cat $logfile
-       $SYS_RM $logfile
-fi
+#if [ $flag -ne 1 ]; then
+#      cat $logfile
+#      $SYS_RM $logfile
+#fi
 exit $TEST_OK
 
index be0240a..4958ee1 100755 (executable)
@@ -280,18 +280,25 @@ test_done();
 test_printf ("** Check zombies\n");
 $failed = 0;
 
+$errfile = $prefix . "_stat_err.tmp";
+$statfile = $prefix . "_stat.tmp";
+
 for (values(%old),values(%new)) {
+               $jobid = $_;
                $stat = 'nic moc';
-               $stat = `$status $_ | head -2 | tail -1`;
+               system("$status $jobid > $statfile 2> $errfile");
+               $stat = `cat $statfile | head -2 | tail -1`;
                chomp $stat;
                $stat =~ s/state :\s*//;
-
-               print "$_ $stat ";
-               if ($stat ne 'Purged') { $failed = 1; test_failed(); }
+       
+               $exitcode = system("grep \"Identifier removed\" $errfile > /dev/null");
+               if ( ! $exitcode ) { print "$jobid returned EIDRM"; }
+               else { print "$jobid $stat "; }
+               if ($stat ne 'Purged' && $exitcode ne 0) { $failed = 1; test_failed(); }
                else { test_done(); }
 }
 
-die "Jobs should be known and purged\n" if $failed;
+die "EIDRM or state Purged should have been returned for zombies\n" if $failed;
 
 test_printf ("\n** All tests passed **");
 test_done();