Index: dashboard-tests.scm ================================================================== --- dashboard-tests.scm +++ dashboard-tests.scm @@ -62,30 +62,30 @@ (store-label "testid" (iup:label "TestId " #:expand "HORIZONTAL") (lambda (testdat) (db:test-get-id testdat))) - (store-label "testvalue" - (iup:label "TestValue " - #:expand "HORIZONTAL") - (lambda (testdat) - (db:test-get-value testdat))) - (store-label "testexpectedvalue" - (iup:label "TestExpectedValue " - #:expand "HORIZONTAL") - (lambda (testdat) - (db:test-get-expected_value testdat))) - (store-label "testtol" - (iup:label "TestTol " - #:expand "HORIZONTAL") - (lambda (testdat) - (db:test-get-tol testdat))) - (store-label "testunits" - (iup:label "TestUnits " - #:expand "HORIZONTAL") - (lambda (testdat) - (db:test-get-units testdat))) +;; (store-label "testvalue" +;; (iup:label "TestValue " +;; #:expand "HORIZONTAL") +;; (lambda (testdat) +;; (db:test-get-value testdat))) +;; (store-label "testexpectedvalue" +;; (iup:label "TestExpectedValue " +;; #:expand "HORIZONTAL") +;; (lambda (testdat) +;; (db:test-get-expected_value testdat))) +;; (store-label "testtol" +;; (iup:label "TestTol " +;; #:expand "HORIZONTAL") +;; (lambda (testdat) +;; (db:test-get-tol testdat))) +;; (store-label "testunits" +;; (iup:label "TestUnits " +;; #:expand "HORIZONTAL") +;; (lambda (testdat) +;; (db:test-get-units testdat))) ))))) ;;====================================================================== ;; Test meta panel ;;====================================================================== Index: db.scm ================================================================== --- db.scm +++ db.scm @@ -138,10 +138,11 @@ "ALTER TABLE tests ADD COLUMN first_warn TEXT;" ;; "ALTER TABLE tests ADD COLUMN units TEXT;" )))) (if (< mver 1.25) (begin + (sqlite3:execute db "DROP TABLE test_data;") (sqlite3:execute db "DROP TABLE test_meta;") (sqlite3:execute db test-meta-def) (sqlite3:execute db "CREATE TABLE IF NOT EXISTS test_data (id INTEGER PRIMARY KEY, test_id INTEGER, category TEXT DEFAULT '', Index: keys.scm ================================================================== --- keys.scm +++ keys.scm @@ -65,10 +65,14 @@ (define-inline (keys->key/field keys . additional) (string-join (map (lambda (k)(conc (key:get-fieldname k) " " (key:get-fieldtype k)))(append keys additional)) ",")) (define (args:usage . a) #f) + +;; keys->vallist is called several times (quite unnecessarily), use this hash to suppress multiple +;; reporting of missing keys on the command line. +(define keys:warning-suppress-hash (make-hash-table)) ;; Using the keys pulled from the database (initially set from the megatest.config file) ;; look for the equivalent value on the command line and add it to a list, or #f if not found. ;; default => (val1 val2 val3 ...) ;; withkey => (:key1 val1 :key2 val2 :key3 val3 ...) @@ -80,12 +84,16 @@ ;;(debug:print 0 "remargs: " remargs " newremargs: " newremargs) (apply append (map (lambda (x) (let ((val (args:get-arg x))) ;; (debug:print 0 "x: " x " val: " val) (if (not val) - ;; (debug:print 0 "WARNING: missing key " x ". Specified in database but not on command line, using \"unk\"") - (set! val "default")) + (begin + (if (not (hash-table-ref/default keys:warning-suppress-hash x #f)) + (begin + (debug:print 0 "WARNING: missing key " x ". Specified in database but not on command line, using \"unk\"") + (hash-table-set! keys:warning-suppress-hash x #t))) + (set! val "default"))) (if withkey (list x val) (list val)))) argkeys)))) ;; Given a list of keys (list of vectors) return an alist ((key argval) ...) (define (keys->alist keys defaultval) Index: runs.scm ================================================================== --- runs.scm +++ runs.scm @@ -88,11 +88,12 @@ ;; (conc "," (string-intersperse tags ",") ",") )) item-paths ))) ;; get the previous record for when this test was run where all keys match but runname -(define (test:get-previous-test-run-records db run-id test-name item-path) +;; returns #f if no such test found, returns a single test record if found +(define (test:get-previous-test-run-record db run-id test-name item-path) (let* ((keys (db:get-keys db)) (selstr (string-intersperse (map (lambda (x)(vector-ref x 0)) keys) ",")) (qrystr (string-intersperse (map (lambda (x)(conc (vector-ref x 0) "=?")) keys) " AND ")) (keyvals #f)) ;; first look up the key values from the run selected by run-id @@ -120,12 +121,13 @@ (if (and (null? results) (not (null? tal))) (loop (car tal)(cdr tal)) (car results))))))))) -;; get the previous record for when this test was run where all keys match but runname -;; NB// Merge this with test:get-previous-test-run-records +;; get the previous records for when these tests were run where all keys match but runname +;; NB// Merge this with test:get-previous-test-run-records? This one looks for all matching tests +;; can use wildcards. (define (test:get-matching-previous-test-run-records db run-id test-name item-path) (let* ((keys (db:get-keys db)) (selstr (string-intersperse (map (lambda (x)(vector-ref x 0)) keys) ",")) (qrystr (string-intersperse (map (lambda (x)(conc (vector-ref x 0) "=?")) keys) " AND ")) (keyvals #f) @@ -135,11 +137,11 @@ (lambda (a . b) (set! keyvals (cons a b))) db (conc "SELECT " selstr " FROM runs WHERE id=? ORDER BY event_time DESC;") run-id) (if (not keyvals) - #f + '() (let ((prev-run-ids '())) (apply sqlite3:for-each-row (lambda (id) (set! prev-run-ids (cons id prev-run-ids))) db @@ -146,11 +148,11 @@ (conc "SELECT id FROM runs WHERE " qrystr " AND id != ?;") (append keyvals (list run-id))) ;; collect all matching tests for the runs then ;; extract the most recent test and return that. (debug:print 4 "selstr: " selstr ", qrystr: " qrystr ", keyvals: " keyvals ", previous run ids found: " prev-run-ids) - (if (null? prev-run-ids) #f ;; no previous runs? return #f + (if (null? prev-run-ids) '() ;; no previous runs? return null (let loop ((hed (car prev-run-ids)) (tal (cdr prev-run-ids))) (let ((results (db-get-tests-for-run db hed test-name item-path))) (debug:print 4 "Got tests for run-id " run-id ", test-name " test-name ", item-path " item-path " results: " (intersperse results "\n")) @@ -174,11 +176,11 @@ (item-path (if (string? itemdat-or-path) itemdat-or-path (item-list->path itemdat-or-path))) (otherdat (if dat dat (make-hash-table))) ;; before proceeding we must find out if the previous test (where all keys matched except runname) ;; was WAIVED if this test is FAIL (waived (if (equal? status "FAIL") - (let ((prev-test (test:get-previous-test-run-records db run-id test-name item-path))) + (let ((prev-test (test:get-previous-test-run-record db run-id test-name item-path))) (if prev-test ;; true if we found a previous test in this run series (let ((prev-status (db:test-get-status prev-test)) (prev-state (db:test-get-state prev-test)) (prev-comment (db:test-get-comment prev-test))) (debug:print 4 "prev-status " prev-status ", prev-state " prev-state ", prev-comment " prev-comment) @@ -227,28 +229,31 @@ ;; need to update the top test record if PASS or FAIL and this is a subtest (if (and (not (equal? item-path "")) (or (equal? status "PASS") (equal? status "WARN") (equal? status "FAIL") - (equal? status "WAIVED"))) + (equal? status "WAIVED") + (equal? status "RUNNING"))) (begin (sqlite3:execute db "UPDATE tests SET fail_count=(SELECT count(id) FROM tests WHERE run_id=? AND testname=? AND item_path != '' AND status='FAIL'), pass_count=(SELECT count(id) FROM tests WHERE run_id=? AND testname=? AND item_path != '' AND (status='PASS' OR status='WARN' OR status='WAIVED')) WHERE run_id=? AND testname=? AND item_path='';" run-id test-name run-id test-name run-id test-name) - (sqlite3:execute - db - "UPDATE tests - SET state=CASE WHEN (SELECT count(id) FROM tests WHERE run_id=? AND testname=? AND item_path != '' AND state in ('RUNNING','NOT_STARTED')) > 0 THEN + (if (equal? status "RUNNING") ;; running takes priority over all other states, force the test state to RUNNING + (sqlite3:execute db "UPDATE tests SET state=? WHERE run_id=? AND testname=? AND item_path='';" run-id test-name) + (sqlite3:execute + db + "UPDATE tests + SET state=CASE WHEN (SELECT count(id) FROM tests WHERE run_id=? AND testname=? AND item_path != '' AND state in ('RUNNING','NOT_STARTED')) > 0 THEN 'RUNNING' ELSE 'COMPLETED' END, - status=CASE WHEN fail_count > 0 THEN 'FAIL' WHEN pass_count > 0 AND fail_count=0 THEN 'PASS' ELSE 'UNKNOWN' END - WHERE run_id=? AND testname=? AND item_path='';" - run-id test-name run-id test-name))) + status=CASE WHEN fail_count > 0 THEN 'FAIL' WHEN pass_count > 0 AND fail_count=0 THEN 'PASS' ELSE 'UNKNOWN' END + WHERE run_id=? AND testname=? AND item_path='';" + run-id test-name run-id test-name)))) (if (or (and (string? comment) (string-match (regexp "\\S+") comment)) waived) (sqlite3:execute db "UPDATE tests SET comment=? WHERE run_id=? AND testname=? AND item_path=?;" (if waived waived comment) run-id test-name item-path)) @@ -866,13 +871,13 @@ (runs:update-test_meta db test-name test-conf))) test-names))) ;; This could probably be refactored into one complex query ... (define (runs:rollup-run db keys) - (let* ((new-run-id (register-run db keys)) - (prev-tests (test:get-matching-previous-test-run-records db new-run-id "%" "%")) - (curr-tests (db-get-tests-for-run db new-run-id "%" "%")) + (let* ((new-run-id (register-run db keys)) + (prev-tests (test:get-matching-previous-test-run-records db new-run-id "%" "%")) + (curr-tests (db-get-tests-for-run db new-run-id "%" "%")) (curr-tests-hash (make-hash-table))) ;; index the already saved tests by testname and itempath in curr-tests-hash (for-each (lambda (testdat) (let* ((testname (db:test-get-testname testdat)) @@ -892,12 +897,12 @@ (test-steps (db:get-steps-for-test db (db:test-get-id testdat))) (new-test-record #f)) ;; replace these with insert ... select (apply sqlite3:execute db - (conc "INSERT OR REPLACE INTO tests (run_id,testname,state,status,event_time,host,cpuload,diskfree,uname,rundir,item_path,run_duration,final_logf,comment,value,expected_value,tol,units,first_err,first_warn) " - "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);") + (conc "INSERT OR REPLACE INTO tests (run_id,testname,state,status,event_time,host,cpuload,diskfree,uname,rundir,item_path,run_duration,final_logf,comment,first_err,first_warn) " + "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);") new-run-id (cddr (vector->list testdat))) (set! new-testdat (car (db-get-tests-for-run db new-run-id testname item-path))) (hash-table-set! curr-tests-hash full-name new-testdat) ;; this could be confusing, which record should go into the lookup table? ;; Now duplicate the test steps (debug:print 4 "Copying records in test_steps from test_id=" (db:test-get-id testdat) " to " (db:test-get-id new-testdat)) @@ -908,12 +913,12 @@ (db:test-get-id testdat)) ;; Now duplicate the test data (debug:print 4 "Copying records in test_data from test_id=" (db:test-get-id testdat) " to " (db:test-get-id new-testdat)) (sqlite3:execute db - (conc "INSERT OR REPLACE INTO test_data (test_id,category,variable,value,comment) " - "SELECT " (db:test-get-id new-testdat) ",category,variable,value,comment FROM test_data WHERE test_id=?;") + (conc "INSERT OR REPLACE INTO test_data (test_id,category,variable,value,expected_value,tol,units,comment) " + "SELECT " (db:test-get-id new-testdat) ",category,variable,value,expected_value,tol,units,comment FROM test_data WHERE test_id=?;") (db:test-get-id testdat)) )) prev-tests)))