@@ -1011,55 +1011,53 @@ ;;====================================================================== ;; QUEUE UP META, TEST STATUS AND STEPS ;;====================================================================== -;; (define (db:updater db) -;; (let loop ((start-time (current-time))) -;; (thread-sleep! 0.5) ;; move save time around to minimize regular collisions? -;; (db:write-cached-data db) -;; (loop start-time))) -;; -;; (define (db:test-update-meta-info db test-id minutes cpuload diskfree tmpfree) -;; (mutex-lock! *incoming-mutex*) -;; (set! *incoming-data* (cons (vector 'meta-info -;; (current-seconds) -;; (list cpuload -;; diskfree -;; minutes -;; test-id)) ;; run-id test-name item-path minutes cpuload diskfree tmpfree) -;; *incoming-data*)) -;; (mutex-unlock! *incoming-mutex*) -;; (if *cache-on* -;; (debug:print 6 "INFO: *cache-on* is " *cache-on* ", skipping cache write as part of test-update-meta-info") -;; (db:write-cached-data db))) -;; - -;; ==> (define (db:write-cached-data db) -;; ==> (let ((meta-stmt (sqlite3:prepare db "UPDATE tests SET cpuload=?,diskfree=?,run_duration=?,state='RUNNING' WHERE id=? AND state NOT IN ('COMPLETED','KILLREQ','KILLED');")) -;; ==> (step-stmt (sqlite3:prepare db "INSERT OR REPLACE into test_steps (test_id,stepname,state,status,event_time,comment,logfile) VALUES(?,?,?,?,?,?,?);")) ;; strftime('%s','now')#f) -;; ==> (data (sort *incoming-data* (lambda (a b)(< (vector-ref a 1)(vector-ref b 1)))))) -;; ==> (if (> (length data) 0) -;; ==> (debug:print 4 "Writing cached data " data)) -;; ==> (mutex-lock! *incoming-mutex*) -;; ==> (sqlite3:with-transaction -;; ==> db -;; ==> (lambda () -;; ==> (for-each (lambda (entry) -;; ==> (case (vector-ref entry 0) -;; ==> ((meta-info) -;; ==> (apply sqlite3:execute meta-stmt (vector-ref entry 2))) -;; ==> ((step-status) -;; ==> (apply sqlite3:execute step-stmt (vector-ref entry 2))) -;; ==> (else -;; ==> (debug:print 0 "ERROR: Queued entry not recognised " entry)))) -;; ==> data))) -;; ==> (sqlite3:finalize! meta-stmt) ;; sqlite is the bottleneck, clear the statements asap? -;; ==> (sqlite3:finalize! step-stmt) -;; ==> (set! *incoming-data* '()) -;; ==> (mutex-unlock! *incoming-mutex*))) - +(define (db:updater db) + (let loop ((start-time (current-time))) + (thread-sleep! 0.5) ;; move save time around to minimize regular collisions? + (db:write-cached-data db) + (loop start-time))) + +(define (remote:test-update-meta-info db test-id minutes cpuload diskfree tmpfree) + (mutex-lock! *incoming-mutex*) + (set! *incoming-data* (cons (vector 'meta-info + (current-seconds) + (list cpuload + diskfree + minutes + test-id)) ;; run-id test-name item-path minutes cpuload diskfree tmpfree) + *incoming-data*)) + (mutex-unlock! *incoming-mutex*) + (if *cache-on* + (debug:print 6 "INFO: *cache-on* is " *cache-on* ", skipping cache write as part of test-update-meta-info") + (db:write-cached-data db))) + +(define (db:write-cached-data db) + (let ((meta-stmt (sqlite3:prepare db "UPDATE tests SET cpuload=?,diskfree=?,run_duration=?,state='RUNNING' WHERE id=? AND state NOT IN ('COMPLETED','KILLREQ','KILLED');")) + (step-stmt (sqlite3:prepare db "INSERT OR REPLACE into test_steps (test_id,stepname,state,status,event_time,comment,logfile) VALUES(?,?,?,?,?,?,?);")) ;; strftime('%s','now')#f) + (data (sort *incoming-data* (lambda (a b)(< (vector-ref a 1)(vector-ref b 1)))))) + (if (> (length data) 0) + (debug:print 4 "Writing cached data " data)) + (mutex-lock! *incoming-mutex*) + (sqlite3:with-transaction + db + (lambda () + (for-each (lambda (entry) + (case (vector-ref entry 0) + ((meta-info) + (apply sqlite3:execute meta-stmt (vector-ref entry 2))) + ((step-status) + (apply sqlite3:execute step-stmt (vector-ref entry 2))) + (else + (debug:print 0 "ERROR: Queued entry not recognised " entry)))) + data))) + (sqlite3:finalize! meta-stmt) ;; sqlite is the bottleneck, clear the statements asap? + (sqlite3:finalize! step-stmt) + (set! *incoming-data* '()) + (mutex-unlock! *incoming-mutex*))) (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") @@ -1086,11 +1084,10 @@ 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)) #f) #f)) - ;;====================================================================== ;; Tests meta data ;;====================================================================== @@ -1723,6 +1720,12 @@ (let ((host (vector-ref *runremote* 0)) (port (vector-ref *runremote* 1))) ((rpc:procedure 'rdb:test-get-paths-matching host port) keynames target fname)) (db:test-get-paths-matching db keynames target fname))) - +(define (rdb:open-run-close procname . remargs) + (if *runremote* + (let ((host (vector-ref *runremote* 0)) + (port (vector-ref *runremote* 1))) + (apply (rpc:procedure 'rdb:open-run-close host port) procname remargs)) + (apply open-run-close (eval procname) remargs))) +