|
341 | 341 | (if (not (null? sorted-test-names))
|
342 | 342 | (let loop ((hed (car sorted-test-names))
|
343 | 343 | (tal (cdr sorted-test-names))
|
| 344 | + (reg '()) ;; registered, put these at the head of tal |
344 | 345 | (reruns '()))
|
345 | 346 | (if (not (null? reruns))(debug:print-info 4 "reruns=" reruns))
|
346 | 347 | ;; (print "Top of loop, hed=" hed ", tal=" tal " ,reruns=" reruns)
|
|
354 | 355 | (itemdat (tests:testqueue-get-itemdat test-record)) ;; itemdat can be a string, list or #f
|
355 | 356 | (items (tests:testqueue-get-items test-record))
|
356 | 357 | (item-path (item-list->path itemdat))
|
| 358 | + (newhed (if (> (length reg) 100) |
| 359 | + (let ((newh (car reg))) |
| 360 | + (set! reg (cdr reg)) |
| 361 | + (set! tal (cons hed tal)) |
| 362 | + newh) |
| 363 | + hed)) |
357 | 364 | (newtal (append tal (list hed))))
|
358 |
| - |
359 | 365 | (debug:print 6
|
360 | 366 | "test-name: " test-name
|
361 | 367 | "\n hed: " hed
|
|
372 | 378 | (if (member test-name waitons)
|
373 | 379 | (begin
|
374 | 380 | (debug:print 0 "ERROR: test " test-name " has listed itself as a waiton, please correct this!")
|
375 |
| - (set! waiton (filter (lambda (x)(not (equal? x hed))) waitons)))) |
| 381 | + (set! waiton (filter (lambda (x)(not (equal? x newhed))) waitons)))) |
376 | 382 |
|
377 | 383 | (cond ;; OUTER COND
|
378 | 384 | ((not items) ;; when false the test is ok to be handed off to launch (but not before)
|
|
392 | 398 | (conc (db:test-get-state t) "/" (db:test-get-status t))
|
393 | 399 | (conc " WARNING: t is not a vector=" t )))
|
394 | 400 | prereqs-not-met) ", ") " fails: " fails)
|
395 |
| - (debug:print-info 4 "hed=" hed "\n test-record=" test-record "\n test-name: " test-name "\n item-path: " item-path "\n test-patts: " test-patts) |
| 401 | + (debug:print-info 4 "newhed=" newhed "\n test-record=" test-record "\n test-name: " test-name "\n item-path: " item-path "\n test-patts: " test-patts) |
396 | 402 |
|
397 | 403 | ;; Don't know at this time if the test have been launched at some time in the past
|
398 | 404 | ;; i.e. is this a re-launch?
|
|
405 | 411 | (debug:print-info 1 "Skipping " (tests:testqueue-get-testname test-record) " " item-path " as it doesn't match " test-patts)
|
406 | 412 | ;; (thread-sleep! *global-delta*)
|
407 | 413 | (if (not (null? tal))
|
408 |
| - (loop (car tal)(cdr tal) reruns))) |
| 414 | + (loop (car tal)(cdr tal) reg reruns))) |
409 | 415 | ;; Registery has been started for this test but has not yet completed
|
410 | 416 | ;; this should be rare, the case where there are only a couple of tests and the db is slow
|
411 | 417 | ;; delay a short while and continue
|
|
432 | 438 | (thread-start! th))
|
433 | 439 | ;; TRY (thread-sleep! *global-delta*)
|
434 | 440 | (runs:shrink-can-run-more-tests-count) ;; DELAY TWEAKER (still needed?)
|
435 |
| - (loop (car newtal)(cdr newtal) reruns)) |
| 441 | + (loop (car newtal)(cdr newtal)(append reg (list newhed)) reruns)) |
436 | 442 | ;; At this point *all* test registrations must be completed.
|
437 |
| - ((not (null? (filter (lambda (x)(eq? 'start x))(hash-table-values test-registery)))) |
438 |
| - (debug:print-info 0 "Waiting on test registrations: " (string-intersperse |
439 |
| - (filter (lambda (x) |
440 |
| - (eq? (hash-table-ref/default test-registery x #f) 'start)) |
441 |
| - (hash-table-keys test-registery)) |
442 |
| - ", ")) |
| 443 | + ;; NO! Only the registration for *this* test |
| 444 | + (;; (not (null? (filter (lambda (x)(eq? 'start x))(hash-table-values test-registery)))) |
| 445 | + (eq? (hash-table-ref/default test-registery (runs:make-full-test-name test-name item-path) #f) |
| 446 | + 'start) |
| 447 | + (debug:print-info 0 "Waiting on test registration(s): " (string-intersperse |
| 448 | + (filter (lambda (x) |
| 449 | + (eq? (hash-table-ref/default test-registery x #f) 'start)) |
| 450 | + (hash-table-keys test-registery)) |
| 451 | + ", ")) |
443 | 452 | (thread-sleep! 0.1)
|
444 |
| - (loop hed tal reruns)) |
| 453 | + (loop newhed tal reg reruns)) |
445 | 454 | ((not have-resources) ;; simply try again after waiting a second
|
446 | 455 | (debug:print-info 1 "no resources to run new tests, waiting ...")
|
447 | 456 | ;; Have gone back and forth on this but db starvation is an issue.
|
448 | 457 | ;; wait one second before looking again to run jobs.
|
449 | 458 | (thread-sleep! 1) ;; (+ 2 *global-delta*))
|
450 | 459 | ;; could have done hed tal here but doing car/cdr of newtal to rotate tests
|
451 |
| - (loop (car newtal)(cdr newtal) reruns)) |
| 460 | + (loop (car newtal)(cdr newtal) reg reruns)) |
452 | 461 | ((and have-resources
|
453 | 462 | (or (null? prereqs-not-met)
|
454 | 463 | (and (eq? testmode 'toplevel)
|
|
458 | 467 | (runs:shrink-can-run-more-tests-count) ;; DELAY TWEAKER (still needed?)
|
459 | 468 | ;; (thread-sleep! *global-delta*)
|
460 | 469 | (if (not (null? tal))
|
461 |
| - (loop (car tal)(cdr tal) reruns))) |
| 470 | + (loop (car tal)(cdr tal) reg reruns))) |
462 | 471 | (else ;; must be we have unmet prerequisites
|
463 | 472 | (debug:print 4 "FAILS: " fails)
|
464 | 473 | ;; If one or more of the prereqs-not-met are FAIL then we can issue
|
|
469 | 478 | (debug:print-info 4 "Shouldn't really get here, race condition? Unable to launch more tests at this moment, killing time ...")
|
470 | 479 | ;; (thread-sleep! (+ 0.01 *global-delta*)) ;; long sleep here - no resources, may as well be patient
|
471 | 480 | ;; we made new tal by sticking hed at the back of the list
|
472 |
| - (loop (car newtal)(cdr newtal) reruns)) |
| 481 | + (loop (car newtal)(cdr newtal) reg reruns)) |
473 | 482 | ;; the waiton is FAIL so no point in trying to run hed ever again
|
474 | 483 | (if (not (null? tal))
|
475 |
| - (if (vector? hed) |
| 484 | + (if (vector? newhed) |
476 | 485 | (begin
|
477 |
| - (debug:print 1 "WARN: Dropping test " (db:test-get-testname hed) "/" (db:test-get-item-path hed) |
| 486 | + (debug:print 1 "WARN: Dropping test " (db:test-get-testname newhed) "/" (db:test-get-item-path newhed) |
478 | 487 | " from the launch list as it has prerequistes that are FAIL")
|
479 | 488 | (runs:shrink-can-run-more-tests-count) ;; DELAY TWEAKER (still needed?)
|
480 | 489 | ;; (thread-sleep! *global-delta*)
|
481 | 490 | (hash-table-set! test-registery (runs:make-full-test-name test-name item-path) 'removed)
|
482 |
| - (loop (car tal)(cdr tal) (cons hed reruns))) |
| 491 | + (loop (car tal)(cdr tal) reg (cons newhed reruns))) |
483 | 492 | (begin
|
484 |
| - (debug:print 1 "WARN: Test not processed correctly. Could be a race condition in your test implementation? " hed) ;; " as it has prerequistes that are FAIL. (NOTE: hed is not a vector)") |
| 493 | + (debug:print 1 "WARN: Test not processed correctly. Could be a race condition in your test implementation? " newhed) ;; " as it has prerequistes that are FAIL. (NOTE: newhed is not a vector)") |
485 | 494 | (runs:shrink-can-run-more-tests-count) ;; DELAY TWEAKER (still needed?)
|
486 | 495 | ;; (thread-sleep! (+ 0.01 *global-delta*))
|
487 |
| - (loop hed tal reruns))))))))) ;; END OF INNER COND |
| 496 | + (loop newhed tal reg reruns))))))))) ;; END OF INNER COND |
488 | 497 |
|
489 | 498 | ;; case where an items came in as a list been processed
|
490 | 499 | ((and (list? items) ;; thus we know our items are already calculated
|
|
499 | 508 | (vector-copy! test-record newrec)
|
500 | 509 | newrec))
|
501 | 510 | (my-item-path (item-list->path my-itemdat)))
|
502 |
| - (if (tests:match test-patts hed my-item-path) ;; (patt-list-match my-item-path item-patts) ;; yes, we want to process this item, NOTE: Should not need this check here! |
503 |
| - (let ((newtestname (runs:make-full-test-name hed my-item-path))) ;; test names are unique on testname/item-path |
| 511 | + (if (tests:match test-patts newhed my-item-path) ;; (patt-list-match my-item-path item-patts) ;; yes, we want to process this item, NOTE: Should not need this check here! |
| 512 | + (let ((newtestname (runs:make-full-test-name newhed my-item-path))) ;; test names are unique on testname/item-path |
504 | 513 | (tests:testqueue-set-items! new-test-record #f)
|
505 | 514 | (tests:testqueue-set-itemdat! new-test-record my-itemdat)
|
506 | 515 | (tests:testqueue-set-item_path! new-test-record my-item-path)
|
|
511 | 520 | (begin
|
512 | 521 | (debug:print-info 4 "End of items list, looping with next after short delay")
|
513 | 522 | ;; (thread-sleep! (+ 0.01 *global-delta*))
|
514 |
| - (loop (car tal)(cdr tal) reruns)))) |
| 523 | + (loop (car tal)(cdr tal) reg reruns)))) |
515 | 524 |
|
516 | 525 | ;; if items is a proc then need to run items:get-items-from-config, get the list and loop
|
517 | 526 | ;; - but only do that if resources exist to kick off the job
|
|
523 | 532 | (fails (runs:calc-fails prereqs-not-met))
|
524 | 533 | (non-completed (runs:calc-not-completed prereqs-not-met)))
|
525 | 534 | (debug:print-info 8 "can-run-more: " can-run-more
|
526 |
| - "\n testname: " hed |
| 535 | + "\n testname: " newhed |
527 | 536 | "\n prereqs-not-met: " (runs:pretty-string prereqs-not-met)
|
528 | 537 | "\n non-completed: " (runs:pretty-string non-completed)
|
529 | 538 | "\n fails: " (runs:pretty-string fails)
|
|
549 | 558 | (begin
|
550 | 559 | (tests:testqueue-set-items! test-record items-list)
|
551 | 560 | ;; (thread-sleep! *global-delta*)
|
552 |
| - (loop hed tal reruns)) |
| 561 | + (loop newhed tal reg reruns)) |
553 | 562 | (begin
|
554 | 563 | (debug:print 0 "ERROR: The proc from reading the setup did not yield a list - please report this")
|
555 | 564 | (exit 1))))))
|
556 | 565 | ((null? fails)
|
557 |
| - (debug:print-info 4 "fails is null, moving on in the queue but keeping " hed " for now") |
| 566 | + (debug:print-info 4 "fails is null, moving on in the queue but keeping " newhed " for now") |
558 | 567 | ;; only increment num-retries when there are no tests runing
|
559 | 568 | (if (eq? 0 (list-ref can-run-more 1))
|
560 | 569 | (begin
|
|
564 | 573 | (set! num-retries (+ num-retries 1))))
|
565 | 574 | (if (> num-retries max-retries)
|
566 | 575 | (if (not (null? tal))
|
567 |
| - (loop (car tal)(cdr tal) reruns)) |
568 |
| - (loop (car newtal)(cdr newtal) reruns))) ;; an issue with prereqs not yet met? |
| 576 | + (loop (car tal)(cdr tal) reg reruns)) |
| 577 | + (loop (car newtal)(cdr newtal) reg reruns))) ;; an issue with prereqs not yet met? |
569 | 578 | ((and (not (null? fails))(eq? testmode 'normal))
|
570 |
| - (debug:print-info 1 "test " hed " (mode=" testmode ") has failed prerequisite(s); " |
| 579 | + (debug:print-info 1 "test " newhed " (mode=" testmode ") has failed prerequisite(s); " |
571 | 580 | (string-intersperse (map (lambda (t)(conc (db:test-get-testname t) ":" (db:test-get-state t)"/"(db:test-get-status t))) fails) ", ")
|
572 | 581 | ", removing it from to-do list")
|
573 | 582 | (if (not (null? tal))
|
574 | 583 | (begin
|
575 | 584 | ;; (thread-sleep! *global-delta*)
|
576 |
| - (loop (car tal)(cdr tal)(cons hed reruns))))) |
| 585 | + (loop (car tal)(cdr tal) reg (cons newhed reruns))))) |
577 | 586 | (else
|
578 | 587 | (debug:print 8 "ERROR: No handler for this condition.")
|
579 | 588 | ;; TRY (thread-sleep! (+ 1 *global-delta*))
|
580 |
| - (loop (car newtal)(cdr newtal) reruns)))) ;; END OF IF CAN RUN MORE |
| 589 | + (loop (car newtal)(cdr newtal) reg reruns)))) ;; END OF IF CAN RUN MORE |
581 | 590 |
|
582 | 591 | ;; if can't run more just loop with next possible test
|
583 | 592 | (begin
|
584 |
| - (debug:print-info 4 "processing the case with a lambda for items or 'have-procedure. Moving through the queue without dropping " hed) |
| 593 | + (debug:print-info 4 "processing the case with a lambda for items or 'have-procedure. Moving through the queue without dropping " newhed) |
585 | 594 | ;; (thread-sleep! (+ 2 *global-delta*))
|
586 |
| - (loop (car newtal)(cdr newtal) reruns))))) ;; END OF (or (procedure? items)(eq? items 'have-procedure)) |
| 595 | + (loop (car newtal)(cdr newtal) reg reruns))))) ;; END OF (or (procedure? items)(eq? items 'have-procedure)) |
587 | 596 |
|
588 | 597 | ;; this case should not happen, added to help catch any bugs
|
589 | 598 | ((and (list? items) itemdat)
|
|
599 | 608 | ;; (thread-sleep! (+ 1 *global-delta*))
|
600 | 609 | (if (not (null? newlst))
|
601 | 610 | ;; since reruns have been tacked on to newlst create new reruns from junked
|
602 |
| - (loop (car newlst)(cdr newlst)(delete-duplicates junked))))) |
| 611 | + (loop (car newlst)(cdr newlst) reg (delete-duplicates junked))))) |
603 | 612 | ((not (null? tal))
|
604 | 613 | (debug:print-info 4 "I'm pretty sure I shouldn't get here."))
|
605 | 614 | (else
|
606 |
| - (debug:print-info 4 "Exiting loop with...\n hed=" hed "\n tal=" tal "\n reruns=" reruns)) |
| 615 | + (debug:print-info 4 "Exiting loop with...\n newhed=" newhed "\n tal=" tal "\n reruns=" reruns)) |
607 | 616 | )))) ;; LET* ((test-record
|
608 | 617 |
|
609 | 618 | ;; we get here on "drop through" - loop for next test in queue
|
|
0 commit comments