Index: db.scm ================================================================== --- db.scm +++ db.scm @@ -1297,17 +1297,25 @@ (set! res count)) db "SELECT count(id) FROM tests WHERE state in ('RUNNING','LAUNCHED','REMOTEHOSTSTART') AND run_id NOT IN (SELECT id FROM runs WHERE state='deleted') AND NOT (uname = 'n/a' AND item_path = '');") res)) -(define (db:get-count-tests-running-for-run-id db run-id) - (let ((res 0)) +;; override states to count with list of strings. +;; +(define (db:get-count-tests-running-for-run-id db run-id states) + (let ((res 0) + (sqrystr (conc "SELECT count(id) FROM tests WHERE state in ('" + (if states + (string-intersperse states "','") + "RUNNING','LAUNCHED','REMOTEHOSTSTART") + "') AND run_id=? AND NOT (uname = 'n/a' AND item_path = '');"))) (sqlite3:for-each-row (lambda (count) (set! res count)) ;; select * from tests where run_id=1 and uname = 'n/a' and item_path=''; db - "SELECT count(id) FROM tests WHERE state in ('RUNNING','LAUNCHED','REMOTEHOSTSTART') AND run_id=? AND NOT (uname = 'n/a' AND item_path = '');" run-id) + sqrystr run-id) + ;; "SELECT count(id) FROM tests WHERE state in ('RUNNING','LAUNCHED','REMOTEHOSTSTART') AND run_id=? AND NOT (uname = 'n/a' AND item_path = '');" run-id) res)) (define (db:get-running-stats db) (let ((res '())) (sqlite3:for-each-row Index: runs.scm ================================================================== --- runs.scm +++ runs.scm @@ -879,11 +879,11 @@ (items (tests:testqueue-get-items test-record)) (item-path (item-list->path itemdat)) (tfullname (runs:make-full-test-name test-name item-path)) (newtal (append tal (list hed))) (regfull (>= (length reg) reglen)) - (num-running (cdb:remote-run db:get-count-tests-running-for-run-id #f run-id))) + (num-running (cdb:remote-run db:get-count-tests-running-for-run-id #f run-id #f))) (if (> num-running 0) (set! last-time-some-running (current-seconds))) (if (> (current-seconds)(+ last-time-some-running 240)) @@ -1040,12 +1040,20 @@ ((not (null? reg)) ;; could we get here with leftovers? (debug:print-info 0 "Have leftovers!") (loop (car reg)(cdr reg) '() reruns)) (else (debug:print-info 4 "Exiting loop with...\n hed=" hed "\n tal=" tal "\n reruns=" reruns)) - ))) ;; LET* ((test-record - + )) + ;; now *if* -run-wait we wait for all tests to be done + (let loop ((num-running (cdb:remote-run db:get-count-tests-running-for-run-id #f run-id #f))) + (if (and (args:get-arg "-run-wait") + (> num-running 0)) + (begin + (debug:print-info 0 "-run-wait specified, waiting on " num-running " tests in RUNNING, REMOTEHOSTSTART or LAUNCHED state.") + (thread-sleep! 15) + (loop (cdb:remote-run db:get-count-tests-running-for-run-id #f run-id #f))))) + ) ;; LET* ((test-record ;; we get here on "drop through". All done! (debug:print-info 1 "All tests launched"))) (define (runs:calc-fails prereqs-not-met) (filter (lambda (test) Index: utils/loadrunner ================================================================== --- utils/loadrunner +++ utils/loadrunner @@ -45,10 +45,11 @@ # NB// max_load is in units of percent. # lperc=$(echo "100 * $load / $numcpu"|bc) lperc2=$(echo "100 * $load2 / $numcpu"|bc) +let "lperc2adj=$lperc2 + $numcpu" if [[ "x$MAX_ALLOWED_LOAD" == "x" ]]; then max_load=100 else max_load=$MAX_ALLOWED_LOAD fi @@ -55,22 +56,23 @@ lfile=/tmp/loadrunner-$USER.lockfile lockfile -r 5 -l 60 $lfile &> /dev/null if [[ $lperc -lt $max_load ]];then - if [[ $lperc -le $lperc2 ]];then + if [[ $lperc -le $lperc2adj ]];then # echo "Load acceptable: lperc=$lperc %, max_load=$max_load %, load=$load, numcpu=$numcpu, MAX_ALLOWED_LOAD=$MAX_ALLOWED_LOAD % and $lperc2 < $lperc" # echo "Starting command: \"$@\"" launchjob "$@" # we sleep ten seconds here to keep the lock a little longer and give time for # the uptime to show a response - sleep 10 + # sleep 2 else echo "$LOADRUNNER $@" | at now + 2 minutes &> /dev/null + # sleep 5 fi else # echo "Load too high: lperc=$lperc, max_load=$max_load, waiting two minutes before trying to run command: \"$@\"" echo "$LOADRUNNER $@" | at now + 2 minutes &> /dev/null fi -sleep $(get_delay_time 10) +sleep $(get_delay_time 3) rm -f $lfile