Index: client.scm ================================================================== --- client.scm +++ client.scm @@ -60,10 +60,11 @@ (if (not *toppath*) (if (not (setup-for-run)) (begin (debug:print 0 "ERROR: failed to find megatest.config, exiting") (exit)))) + (change-directory *toppath*) ;; This is probably NOT needed (debug:print-info 11 "*transport-type* is " *transport-type* ", *runremote* is " *runremote*) (let* ((hostinfo (if (not *transport-type*) ;; If we dont' already have transport type set then figure it out (open-run-close tasks:get-best-server tasks:open-db) #f))) ;; if have hostinfo then extract the transport type Index: db.scm ================================================================== --- db.scm +++ db.scm @@ -459,10 +459,47 @@ ((< mver 1.37) (db:set-var db "MEGATEST_VERSION" 1.37) (sqlite3:execute db "ALTER TABLE tests ADD COLUMN archived INTEGER DEFAULT 0;")) ((< mver megatest-version) (db:set-var db "MEGATEST_VERSION" megatest-version)))))) + +;; Clean out old junk and vacuum the database +;; +;; Ultimately do something like this: +;; +;; 1. Look at test records either deleted or part of deleted run: +;; a. If test dir exists, set the the test to state='UNKNOWN', Set the run to 'unknown' +;; b. If test dir gone, delete the test record +;; 2. Look at run records +;; a. If have tests that are not deleted, set state='unknown' +;; b. .... +;; +(define (db:clean-up db) + (let ((statements + (map (lambda (stmt) + (sqlite3:prepare db stmt)) + (list + ;; delete all tests that belong to runs that are 'deleted' + "DELETE FROM tests WHERE run_id in (SELECT run_id FROM runs WHERE state='deleted');" + ;; delete all tests that are 'DELETED' + "DELETE FROM tests WHERE state='DELETED';" + ;; delete all tests that have no run + "DELETE FROM tests WHERE run_id NOT IN (SELECT run_id FROM runs);" + ;; delete all runs that are state='deleted' + "DELETE FROM runs WHERE state='deleted';" + ;; delete empty runs + "DELETE FROM runs WHERE id NOT IN (SELECT DISTINCT r.id FROM runs AS r INNER JOIN tests AS t ON t.run_id=r.id);" + )))) + (sqlite3:with-transaction + db + (lambda () + (map sqlite3:execute statements))) + (map sqlite3:finalize! statements) + (sqlite3:execute db "VACUUM;"))) + +;; (define (db:report-junk-records db) + ;;====================================================================== ;; meta get and set vars ;;====================================================================== @@ -772,14 +809,20 @@ (debug:print-info 11 "db:set-comment-for-run END run-id: " run-id " comment: " comment)) ;; does not (obviously!) removed dependent data. But why not!!? (define (db:delete-run db run-id) (common:clear-caches) ;; don't trust caches after doing any deletion - (sqlite3:execute db "UPDATE runs SET state='deleted' WHERE id=?;" run-id)) + ;; First set any related tests to DELETED + (let ((stmt1 (sqlite3:prepare db "UPDATE tests SET state='DELETED' WHERE run_id=?;")) + (stmt2 (sqlite3:prepare db "UPDATE runs SET state='deleted' WHERE id=?;"))) + (sqlite3:with-transaction + db (lambda () + (sqlite3:execute stmt1 run-id) + (sqlite3:execute stmt2 run-id))) + (sqlite3:finalize! stmt1) + (sqlite3:finalize! stmt2))) ;; (sqlite3:execute db "DELETE FROM runs WHERE id=?;" run-id)) - - (define (db:update-run-event_time db run-id) (debug:print-info 11 "db:update-run-event_time START run-id: " run-id) (sqlite3:execute db "UPDATE runs SET event_time=strftime('%s','now') WHERE id=?;" run-id) (debug:print-info 11 "db:update-run-event_time END run-id: " run-id)) @@ -1345,15 +1388,17 @@ (define (db:string->obj msg) (case *transport-type* ((fs) msg) ((http) - (with-input-from-string - (base64:base64-decode - (string-substitute - (regexp "_") "=" msg #t)) - (lambda ()(deserialize)))) + (if (string? msg) + (with-input-from-string + (base64:base64-decode + (string-substitute + (regexp "_") "=" msg #t)) + (lambda ()(deserialize))) + (vector #f #f #f))) ;; crude reply for when things go awry ((zmq)(with-input-from-string msg (lambda ()(deserialize)))) (else msg))) (define (cdb:use-non-blocking-mode proc) (set! *client-non-blocking-mode* #t) Index: launch.scm ================================================================== --- launch.scm +++ launch.scm @@ -327,26 +327,35 @@ (thread-join! th2) (mutex-lock! m) (let* ((item-path (item-list->path itemdat)) (testinfo (cdb:get-test-info-by-id *runremote* test-id))) ;; )) ;; run-id test-name item-path))) ;; Am I completed? - (if (not (equal? (db:test-get-state testinfo) "COMPLETED")) - (begin - (debug:print 2 "Test NOT logged as COMPLETED, (state=" (db:test-get-state testinfo) "), updating result, rollup-status is " rollup-status) - (tests:test-set-status! test-id - (if kill-job? "KILLED" "COMPLETED") - (cond + (if (equal? (db:test-get-state testinfo) "RUNNING") ;; (not (equal? (db:test-get-state testinfo) "COMPLETED")) + (let ((new-state (if kill-job? "KILLED" "COMPLETED") ;; (if (eq? (vector-ref exit-info 2) 0) ;; exited with "good" status + ;; "COMPLETED" + ;; (db:test-get-state testinfo))) ;; else preseve the state as set within the test + ) + (new-status (cond ((not (vector-ref exit-info 1)) "FAIL") ;; job failed to run ((eq? rollup-status 0) ;; if the current status is AUTO the defer to the calculated value (i.e. leave this AUTO) (if (equal? (db:test-get-status testinfo) "AUTO") "AUTO" "PASS")) ((eq? rollup-status 1) "FAIL") ((eq? rollup-status 2) ;; if the current status is AUTO the defer to the calculated value but qualify (i.e. make this AUTO-WARN) (if (equal? (db:test-get-status testinfo) "AUTO") "AUTO-WARN" "WARN")) - (else "FAIL")) - (args:get-arg "-m") #f))) + (else "FAIL")))) ;; (db:test-get-status testinfo))) + (debug:print-info 2 "Test NOT logged as COMPLETED, (state=" (db:test-get-state testinfo) "), updating result, rollup-status is " rollup-status) + (tests:test-set-status! test-id + new-state + new-status + (args:get-arg "-m") #f) + ;; need to update the top test record if PASS or FAIL and this is a subtest + (if (not (equal? item-path "")) + (cdb:roll-up-pass-fail-counts *runremote* run-id test-name item-path new-status)) + + )) ;; for automated creation of the rollup html file this is a good place... (if (not (equal? item-path "")) (tests:summarize-items #f run-id test-name #f)) ;; don't force - just update if no ) (mutex-unlock! m) Index: megatest.scm ================================================================== --- megatest.scm +++ megatest.scm @@ -108,10 +108,11 @@ -dumpmode json : dump in json format instead of sexpr -show-cmdinfo : dump the command info for a test (run in test environment) Misc -rebuild-db : bring the database schema up to date + -cleanup-db : remove any orphan records, vacuum the db -update-meta : update the tests metadata for all tests -env2file fname : write the environment to fname.csh and fname.sh -setvars VAR1=val1,VAR2=val2 : Add environment variables to a run NB// these are overwritten by values set in config files. -server -|hostname : start the server (reduces contention on megatest.db), use @@ -228,10 +229,11 @@ "-test-paths" ;; get path(s) to a test, ordered by youngest first "-runall" ;; run all tests "-remove-runs" "-rebuild-db" + "-cleanup-db" "-rollup" "-update-meta" "-gen-megatest-area" "-logging" @@ -1007,11 +1009,11 @@ (let ((testname (args:get-arg "-gen-megatest-test"))) (genexample:mk-megatest-test testname) (set! *didsomething* #t))) ;;====================================================================== -;; Update the database schema on request +;; Update the database schema, clean up the db ;;====================================================================== (if (args:get-arg "-rebuild-db") (begin (if (not (setup-for-run)) @@ -1019,10 +1021,20 @@ (debug:print 0 "Failed to setup, exiting") (exit 1))) ;; keep this one local (open-run-close patch-db #f) (set! *didsomething* #t))) + +(if (args:get-arg "-cleanup-db") + (begin + (if (not (setup-for-run)) + (begin + (debug:print 0 "Failed to setup, exiting") + (exit 1))) + ;; keep this one local + (open-run-close db:clean-up #f) + (set! *didsomething* #t))) ;;====================================================================== ;; Wait on a run to complete ;;====================================================================== Index: runs.scm ================================================================== --- runs.scm +++ runs.scm @@ -518,11 +518,12 @@ ;; If one or more of the prereqs-not-met are FAIL then we can issue ;; a message and drop hed from the items to be processed. (if (null? fails) (begin ;; couldn't run, take a breather - (debug:print-info 4 "Shouldn't really get here, race condition? Unable to launch more tests at this moment, killing time ...") + (debug:print-info 0 "Shouldn't really get here, race condition? Unable to launch more tests at this moment, killing time ...") + (debug:print-info 0 " test is " hed ", prereqs-not-met is " prereqs-not-met) ;; (thread-sleep! (+ 0.01 *global-delta*)) ;; long sleep here - no resources, may as well be patient ;; we made new tal by sticking hed at the back of the list (list (car newtal)(cdr newtal) reg reruns)) ;; the waiton is FAIL so no point in trying to run hed ever again (if (or (not (null? reg))(not (null? tal))) @@ -536,13 +537,15 @@ (list (runs:queue-next-hed tal reg reglen regfull) (runs:queue-next-tal tal reg reglen regfull) (runs:queue-next-reg tal reg reglen regfull) (cons hed reruns))) (begin - (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)") + (debug:print 0 "WARNING: Test not processed correctly. Could be a race condition in your test implementation? Dropping test " hed) ;; " as it has prerequistes that are FAIL. (NOTE: hed is not a vector)") (runs:shrink-can-run-more-tests-count) ;; DELAY TWEAKER (still needed?) - (list hed tal reg reruns))))))))) + ;; (list hed tal reg reruns) + (list (car newtal)(cdr newtal) reg reruns) + )))))))) ;; test-records is a hash table testname:item_path => vector < testname testconfig waitons priority items-info ... > (define (runs:run-tests-queue run-id runname test-records keyvals flags test-patts required-tests reglen-in all-tests-registry) ;; At this point the list of parent tests is expanded ;; NB// Should expand items here and then insert into the run queue. Index: tests/fullrun/config/mt_include_1.config ================================================================== --- tests/fullrun/config/mt_include_1.config +++ tests/fullrun/config/mt_include_1.config @@ -1,8 +1,8 @@ [setup] # exectutable /path/to/megatest -max_concurrent_jobs 8 +max_concurrent_jobs 15 linktree #{getenv MT_RUN_AREA_HOME}/tmp/mt_links [jobtools] useshell yes ADDED tests/fullrun/tests/blocktestxz/main.sh Index: tests/fullrun/tests/blocktestxz/main.sh ================================================================== --- /dev/null +++ tests/fullrun/tests/blocktestxz/main.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +$MT_MEGATEST -test-status :state $THESTATE :status $THESTATUS -setlog "nada.html" + +# By exiting with non-zero we tell Megatest to preseve the state and status +exit 1 ADDED tests/fullrun/tests/blocktestxz/testconfig Index: tests/fullrun/tests/blocktestxz/testconfig ================================================================== --- /dev/null +++ tests/fullrun/tests/blocktestxz/testconfig @@ -0,0 +1,17 @@ +[setup] +runscript main.sh + +[items] +THESTATE UNKNOWN INCOMPLETE KILLED KILLREQ STUCK BOZZLEBLONKED STUCK/DEAD +THESTATUS PASS FAIL STUCK/DEAD SKIP + +[test_meta] +author matt +owner bob +description This test will fail causing the dependent test "testxz" + to never run. This triggers the code that must determine + that a test will never be run and thus remove it from + the queue of tests to be run. + +tags first,single +reviewed 1/1/1965 Index: tests/fullrun/tests/runfirst/main.sh ================================================================== --- tests/fullrun/tests/runfirst/main.sh +++ tests/fullrun/tests/runfirst/main.sh @@ -23,9 +23,14 @@ $MT_MEGATEST -load-test-data << EOF cat, var, val, exp, comp, units, comment, status, type ameas,iout,1.2,1.9,>,Amps,Comment,,meas EOF +loadstatus=$? -$MT_MEGATEST -test-status :state COMPLETED :status $? -m "This is a test level comment" :value 10e6 :expected_value 1.1e6 :tol 100e3 :category nada :variable sillyvar :units mFarks :comment "This is the value/expected comment" +if [[ `basename $PWD` == "mustfail" ]];then + $MT_MEGATEST -test-status :state COMPLETED :status FAIL +else + $MT_MEGATEST -test-status :state COMPLETED :status $loadstatus -m "This is a test level comment" :value 10e6 :expected_value 1.1e6 :tol 100e3 :category nada :variable sillyvar :units mFarks :comment "This is the value/expected comment" +fi # $MT_MEGATEST -test-status :state COMPLETED :status FAIL Index: tests/fullrun/tests/runfirst/testconfig ================================================================== --- tests/fullrun/tests/runfirst/testconfig +++ tests/fullrun/tests/runfirst/testconfig @@ -6,11 +6,11 @@ # host. This can be used to control remote launch tools, e.g. to # to choose the target host, select the launch tool etc. SPECIAL_ENV_VAR override with everything after the first space. [items] -SEASON summer winter fall spring +SEASON summer winter fall spring [itemstable] BLOCK a b TOCK 1 2 ADDED tests/fullrun/tests/testxz/testconfig Index: tests/fullrun/tests/testxz/testconfig ================================================================== --- /dev/null +++ tests/fullrun/tests/testxz/testconfig @@ -0,0 +1,15 @@ +# Add additional steps here. Format is "stepname script" +[ezsteps] +listfiles ls + +# Test requirements are specified here +[requirements] +waiton blocktestxz + +# test_meta is a section for storing additional data on your test +[test_meta] +author mrwellan +owner mrwellan +description This test should never get run due to blocktestxz failing +tags tagone,tagtwo +reviewed never Index: tests/installall/runconfigs.config ================================================================== --- tests/installall/runconfigs.config +++ tests/installall/runconfigs.config @@ -5,25 +5,29 @@ [default] ALLTESTS see this variable PREFIX #{getenv MT_RUN_AREA_HOME}/#{getenv BUILD_TAG}/#{getenv MT_RUNNAME} DOWNLOADS #{getenv MT_RUN_AREA_HOME}/downloads IUPLIB 26g4 -IUP_VERSION na PLATFORM linux LOGPRO_VERSION v1.05 BUILDSQLITE yes SQLITE3_VERSION 3071401 ZEROMQ_VERSION 2.2.0 [include configs/hicken-#{getenv CHICKEN_VERSION}.config] +# Currently must have at least one variable in a section [4.8.0/trunk/bin/std] +IUP_VERSION na [4.8.0.4/trunk/src/std] +IUP_VERSION na [4.8.1/trunk/src/std] +IUP_VERSION na [4.8.0/v1.5508/opt] +IUP_VERSION na PREFIX /opt/chicken/4.8.0 [4.8.0/trunk/centos5.7vm] BUILDSQLITE no