Index: db.scm ================================================================== --- db.scm +++ db.scm @@ -481,15 +481,15 @@ "SELECT id,run_id,testname,state,status,event_time,host,cpuload,diskfree,uname,rundir,item_path,run_duration,final_logf,comment FROM tests WHERE id=?;" test-id) res)) -(define (db:test-set-comment db run-id testname item-path comment) +(define (db:test-set-comment db run-id test-name item-path comment) (sqlite3:execute db "UPDATE tests SET comment=? WHERE run_id=? AND testname=? AND item_path=?;" - comment run-id testname item-path)) + comment run-id test-name item-path)) ;; (define (db:test-set-rundir! db run-id testname item-path rundir) (sqlite3:execute db @@ -587,10 +587,37 @@ diskfree minutes run-id testname item-path)) + +(define (db:roll-up-pass-fail-counts db run-id test-name item-path status) + (if (and (not (equal? item-path "")) + (or (equal? status "PASS") + (equal? status "WARN") + (equal? status "FAIL") + (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) + (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='';" "RUNNING" 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))))) ;;====================================================================== ;; Tests meta data ;;====================================================================== @@ -1055,5 +1082,29 @@ (let ((host (vector-ref *runremote* 0)) (port (vector-ref *runremote* 1))) ((rpc:procedure 'rdb:test-set-state-status-by-run-id-testname host port) run-id test-name item-path status state)) (db:test-set-state-status-by-run-id-testname db run-id test-name item-path status state))) + +(define (rdb:csv->test-data db test-id csvdata) + (if *runremote* + (let ((host (vector-ref *runremote* 0)) + (port (vector-ref *runremote* 1))) + ((rpc:procedure 'rdb:csv->test-data host port) + test-id csvdata)) + (db:csv->test-data db test-id csvdata))) + +(define (rdb:roll-up-pass-fail-counts db run-id test-name item-path status) + (if *runremote* + (let ((host (vector-ref *runremote* 0)) + (port (vector-ref *runremote* 1))) + ((rpc:procedure 'rdb:roll-up-pass-fail-counts host port) + run-id test-name item-path status)) + (db:roll-up-pass-fail-counts db run-id test-name item-path status))) + +(define (rdb:test-set-comment db run-id test-name item-path comment) + (if *runremote* + (let ((host (vector-ref *runremote* 0)) + (port (vector-ref *runremote* 1))) + ((rpc:procedure 'rdb:test-set-comment host port) + run-id test-name item-path comment)) + (db:test-set-comment db run-id test-name item-path comment))) Index: server.scm ================================================================== --- server.scm +++ server.scm @@ -68,10 +68,25 @@ (rpc:publish-procedure! 'rdb:test-set-state-status-by-run-id-testname (lambda (run-id test-name item-path status state) (db:test-set-state-status-by-run-id-testname db run-id test-name item-path status state))) + (rpc:publish-procedure! + 'rdb:csv->test-data + (lambda (test-id csvdata) + (db:csv->data db test-id csvdata))) + + (rpc:publish-procedure! + 'rdb:roll-up-pass-fail-counts + (lambda (run-id test-name item-path status) + (db:roll-up-pass-fail-counts db run-id test-name item-path status))) + + (rpc:publish-procedure! + 'rdb:test-set-comment + (lambda (run-id test-name item-path comment) + (db:test-set-comment db run-id test-name item-path comment))) + (set! *rpc:listener* rpc:listener) (on-exit (lambda () (sqlite3:execute db "DELETE FROM metadat WHERE var='SERVER' and val=?;" host:port) (sqlite3:finalize! db))) (thread-start! th1) Index: tests.scm ================================================================== --- tests.scm +++ tests.scm @@ -135,13 +135,14 @@ (if waived (set! real-status "WAIVED")) (debug:print 4 "real-status " real-status ", waived " waived ", status " status) ;; update the primary record IF state AND status are defined (if (and state status) - (db:test-set-state-status-by-run-id-testname db run-id test-name item-path real-status state)) + (rdb:test-set-state-status-by-run-id-testname db run-id test-name item-path real-status state)) - ;; if status is "AUTO" then call rollup + ;; if status is "AUTO" then call rollup (note, this one modifies data in test + ;; run area, do not rpc it (yet) (if (and test-id state status (equal? status "AUTO")) (db:test-data-rollup db test-id status)) ;; add metadata (need to do this way to avoid SQL injection issues) @@ -165,11 +166,11 @@ (dcomment (hash-table-ref/default otherdat ":comment" ""))) (debug:print 4 "category: " category ", variable: " variable ", value: " value ", expected: " expected ", tol: " tol ", units: " units) (if (and value expected tol) ;; all three required - (db:csv->test-data db test-id + (rdb:csv->test-data db test-id (conc category "," variable "," value "," expected "," tol "," @@ -176,40 +177,16 @@ units "," dcomment ",," ;; extra comma for status type )))) ;; 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 "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) - (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='';" "RUNNING" 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)))) + (rdb:roll-up-pass-fail-counts db run-id test-name item-path status) + (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)) + (rdb:test-set-comment db run-id test-name item-path (if waived waived comment))) )) (define (test-set-log! db run-id test-name itemdat logf) (let ((item-path (item-list->path itemdat))) (sqlite3:execute db "UPDATE tests SET final_logf=? WHERE run_id=? AND testname=? AND item_path=?;"