Skip to content

Commit 2e8472f

Browse files
author
matt
committed
Partially working launch on more than 100 registered tests
1 parent a280f22 commit 2e8472f

File tree

2 files changed

+45
-36
lines changed

2 files changed

+45
-36
lines changed

megatest-version.scm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33

44
(declare (unit megatest-version))
55

6-
(define megatest-version 1.5418)
6+
(define megatest-version 1.5419)
77

runs.scm

Lines changed: 44 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@
341341
(if (not (null? sorted-test-names))
342342
(let loop ((hed (car sorted-test-names))
343343
(tal (cdr sorted-test-names))
344+
(reg '()) ;; registered, put these at the head of tal
344345
(reruns '()))
345346
(if (not (null? reruns))(debug:print-info 4 "reruns=" reruns))
346347
;; (print "Top of loop, hed=" hed ", tal=" tal " ,reruns=" reruns)
@@ -354,8 +355,13 @@
354355
(itemdat (tests:testqueue-get-itemdat test-record)) ;; itemdat can be a string, list or #f
355356
(items (tests:testqueue-get-items test-record))
356357
(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))
357364
(newtal (append tal (list hed))))
358-
359365
(debug:print 6
360366
"test-name: " test-name
361367
"\n hed: " hed
@@ -372,7 +378,7 @@
372378
(if (member test-name waitons)
373379
(begin
374380
(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))))
376382

377383
(cond ;; OUTER COND
378384
((not items) ;; when false the test is ok to be handed off to launch (but not before)
@@ -392,7 +398,7 @@
392398
(conc (db:test-get-state t) "/" (db:test-get-status t))
393399
(conc " WARNING: t is not a vector=" t )))
394400
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)
396402

397403
;; Don't know at this time if the test have been launched at some time in the past
398404
;; i.e. is this a re-launch?
@@ -405,7 +411,7 @@
405411
(debug:print-info 1 "Skipping " (tests:testqueue-get-testname test-record) " " item-path " as it doesn't match " test-patts)
406412
;; (thread-sleep! *global-delta*)
407413
(if (not (null? tal))
408-
(loop (car tal)(cdr tal) reruns)))
414+
(loop (car tal)(cdr tal) reg reruns)))
409415
;; Registery has been started for this test but has not yet completed
410416
;; this should be rare, the case where there are only a couple of tests and the db is slow
411417
;; delay a short while and continue
@@ -432,23 +438,26 @@
432438
(thread-start! th))
433439
;; TRY (thread-sleep! *global-delta*)
434440
(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))
436442
;; 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+
", "))
443452
(thread-sleep! 0.1)
444-
(loop hed tal reruns))
453+
(loop newhed tal reg reruns))
445454
((not have-resources) ;; simply try again after waiting a second
446455
(debug:print-info 1 "no resources to run new tests, waiting ...")
447456
;; Have gone back and forth on this but db starvation is an issue.
448457
;; wait one second before looking again to run jobs.
449458
(thread-sleep! 1) ;; (+ 2 *global-delta*))
450459
;; 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))
452461
((and have-resources
453462
(or (null? prereqs-not-met)
454463
(and (eq? testmode 'toplevel)
@@ -458,7 +467,7 @@
458467
(runs:shrink-can-run-more-tests-count) ;; DELAY TWEAKER (still needed?)
459468
;; (thread-sleep! *global-delta*)
460469
(if (not (null? tal))
461-
(loop (car tal)(cdr tal) reruns)))
470+
(loop (car tal)(cdr tal) reg reruns)))
462471
(else ;; must be we have unmet prerequisites
463472
(debug:print 4 "FAILS: " fails)
464473
;; If one or more of the prereqs-not-met are FAIL then we can issue
@@ -469,22 +478,22 @@
469478
(debug:print-info 4 "Shouldn't really get here, race condition? Unable to launch more tests at this moment, killing time ...")
470479
;; (thread-sleep! (+ 0.01 *global-delta*)) ;; long sleep here - no resources, may as well be patient
471480
;; 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))
473482
;; the waiton is FAIL so no point in trying to run hed ever again
474483
(if (not (null? tal))
475-
(if (vector? hed)
484+
(if (vector? newhed)
476485
(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)
478487
" from the launch list as it has prerequistes that are FAIL")
479488
(runs:shrink-can-run-more-tests-count) ;; DELAY TWEAKER (still needed?)
480489
;; (thread-sleep! *global-delta*)
481490
(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)))
483492
(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)")
485494
(runs:shrink-can-run-more-tests-count) ;; DELAY TWEAKER (still needed?)
486495
;; (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
488497

489498
;; case where an items came in as a list been processed
490499
((and (list? items) ;; thus we know our items are already calculated
@@ -499,8 +508,8 @@
499508
(vector-copy! test-record newrec)
500509
newrec))
501510
(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
504513
(tests:testqueue-set-items! new-test-record #f)
505514
(tests:testqueue-set-itemdat! new-test-record my-itemdat)
506515
(tests:testqueue-set-item_path! new-test-record my-item-path)
@@ -511,7 +520,7 @@
511520
(begin
512521
(debug:print-info 4 "End of items list, looping with next after short delay")
513522
;; (thread-sleep! (+ 0.01 *global-delta*))
514-
(loop (car tal)(cdr tal) reruns))))
523+
(loop (car tal)(cdr tal) reg reruns))))
515524

516525
;; if items is a proc then need to run items:get-items-from-config, get the list and loop
517526
;; - but only do that if resources exist to kick off the job
@@ -523,7 +532,7 @@
523532
(fails (runs:calc-fails prereqs-not-met))
524533
(non-completed (runs:calc-not-completed prereqs-not-met)))
525534
(debug:print-info 8 "can-run-more: " can-run-more
526-
"\n testname: " hed
535+
"\n testname: " newhed
527536
"\n prereqs-not-met: " (runs:pretty-string prereqs-not-met)
528537
"\n non-completed: " (runs:pretty-string non-completed)
529538
"\n fails: " (runs:pretty-string fails)
@@ -549,12 +558,12 @@
549558
(begin
550559
(tests:testqueue-set-items! test-record items-list)
551560
;; (thread-sleep! *global-delta*)
552-
(loop hed tal reruns))
561+
(loop newhed tal reg reruns))
553562
(begin
554563
(debug:print 0 "ERROR: The proc from reading the setup did not yield a list - please report this")
555564
(exit 1))))))
556565
((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")
558567
;; only increment num-retries when there are no tests runing
559568
(if (eq? 0 (list-ref can-run-more 1))
560569
(begin
@@ -564,26 +573,26 @@
564573
(set! num-retries (+ num-retries 1))))
565574
(if (> num-retries max-retries)
566575
(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?
569578
((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); "
571580
(string-intersperse (map (lambda (t)(conc (db:test-get-testname t) ":" (db:test-get-state t)"/"(db:test-get-status t))) fails) ", ")
572581
", removing it from to-do list")
573582
(if (not (null? tal))
574583
(begin
575584
;; (thread-sleep! *global-delta*)
576-
(loop (car tal)(cdr tal)(cons hed reruns)))))
585+
(loop (car tal)(cdr tal) reg (cons newhed reruns)))))
577586
(else
578587
(debug:print 8 "ERROR: No handler for this condition.")
579588
;; 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
581590

582591
;; if can't run more just loop with next possible test
583592
(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)
585594
;; (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))
587596

588597
;; this case should not happen, added to help catch any bugs
589598
((and (list? items) itemdat)
@@ -599,11 +608,11 @@
599608
;; (thread-sleep! (+ 1 *global-delta*))
600609
(if (not (null? newlst))
601610
;; 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)))))
603612
((not (null? tal))
604613
(debug:print-info 4 "I'm pretty sure I shouldn't get here."))
605614
(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))
607616
)))) ;; LET* ((test-record
608617

609618
;; we get here on "drop through" - loop for next test in queue

0 commit comments

Comments
 (0)