Index: db.scm ================================================================== --- db.scm +++ db.scm @@ -818,10 +818,14 @@ (db:test-set-state! res "NOT_STARTED") (db:test-set-status! res "n/a"))))) (define *last-test-cache-delete* (current-seconds)) +(define (db:clean-all-caches) + (set! *test-info* (make-hash-table)) + (set! *test-id-cache* (make-hash-table))) + ;; Get test data using test_id (define (db:get-test-info-cached-by-id db test-id) ;; is all this crap really worth it? I somehow doubt it. (let* ((last-delete-str (db:get-var db "DELETED_TESTS")) (last-delete (if (string? last-delete-str)(string->number last-delete-str) #f))) @@ -834,11 +838,12 @@ (if (not test-id) (begin (debug:print 4 "INFO: db:get-test-info-by-id called with test-id=" test-id) #f) (let* ((res (hash-table-ref/default *test-info* test-id #f))) - (if res + (if (and res + (member (db:test-get-state res) '("RUNNING" "COMPLETED"))) (db:patch-tdb-data-into-test-info db test-id res) ;; if no cached value then full read and write to cache (begin (sqlite3:for-each-row (lambda (id run-id testname state status event-time host cpuload diskfree uname rundir item-path run_duration final_logf comment) @@ -864,11 +869,11 @@ db "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:get-test-info-by-id db:get-test-info-cached-by-id) +(define db:get-test-info-by-id db:get-test-info-not-cached-by-id) (define (db:get-test-info db run-id testname item-path) (db:get-test-info-by-id db (db:get-test-id db run-id testname item-path))) (define (db:test-set-comment db test-id comment) Index: runs.scm ================================================================== --- runs.scm +++ runs.scm @@ -456,11 +456,11 @@ (let* ((new-test-record (let ((newrec (make-tests:testqueue))) (vector-copy! test-record newrec) newrec)) (my-item-path (item-list->path my-itemdat))) (if (patt-list-match my-item-path item-patts) ;; yes, we want to process this item, NOTE: Should not need this check here! - (let ((newtestname (conc hed "/" my-item-path))) ;; test names are unique on testname/item-path + (let ((newtestname (runs:make-full-test-name hed my-item-path))) ;; test names are unique on testname/item-path (tests:testqueue-set-items! new-test-record #f) (tests:testqueue-set-itemdat! new-test-record my-itemdat) (tests:testqueue-set-item_path! new-test-record my-item-path) (hash-table-set! test-records newtestname new-test-record) (set! tal (cons newtestname tal)))))) ;; since these are itemized create new test names testname/itempath Index: tests/tests.scm ================================================================== --- tests/tests.scm +++ tests/tests.scm @@ -130,30 +130,60 @@ (set! *tdb* db) (sqlite3#database? db))) (sqlite3#finalize! *tdb*) ;; (test "Remove the rollup run" #t (begin (remove-runs) #t)) - +(define tconfig #f) +(test "get a testconfig" #t (let ((tconf (tests:get-testconfig "test1" 'return-procs))) + (set! tconfig tconf) + (hash-table? tconf))) +(db:clean-all-caches) ;; (set! *verbosity* 20) (test "Run a test" #t (general-run-call "-runtests" "run a test" (lambda (target runname keys keynames keyvallst) (let ((test-patts "test%")) - (runs:run-tests target runname test-patts user (make-hash-table)) - )))) + ;; (runs:run-tests target runname test-patts user (make-hash-table)) + (run:test 1 ;; run-id + (args:get-arg ":runname") + (keys:target->keyval keys target) + (vector + "test1" ;; testname + tconfig ;; testconfig + '() ;; waitons + 0 ;; priority + #f ;; items + #f ;; itemsdat + #f ;; spare + ) + args:arg-hash ;; flags (e.g. -itemspatt) + #f))))) + +(test "cache is coherent" #t (let ((cached-info (db:get-test-info-cached-by-id db 2)) + (non-cached (db:get-test-info-not-cached-by-id db 2))) + (print "\nCached: " cached-info) + (print "Noncached: " non-cached) + (equal? cached-info non-cached))) (change-directory test-work-dir) (test "Add a step" #t (begin (db:teststep-set-status! db 2 "step1" "start" 0 "This is a comment" "mylogfile.html") (sleep 2) (db:teststep-set-status! db 2 "step1" "end" "pass" "This is a different comment" "finallogfile.html") - (set! test-id (db:test-get-id (car (db:get-tests-for-run db 2 "test1" "" '() '())))) + (set! test-id (db:test-get-id (car (db:get-tests-for-run db 1 "test1" "" '() '())))) (number? test-id))) -(sleep 5) +(sleep 4) +(test "Get rundir" #t (let ((rundir (db:test-get-rundir-from-test-id db test-id))) + (print "Rundir" rundir) + (string? rundir))) +(test "Create a test db" "../simpleruns/key1/key2/myrun/test1/testdat.db" (let ((tdb (db:open-test-db-by-test-id db test-id))) + (sqlite3#finalize! tdb) + (file-exists? "../simpleruns/key1/key2/myrun/test1/testdat.db"))) +(test "Get steps for test" #t (> (length (db:get-steps-for-test db test-id)) 0)) (test "Get nice table for steps" "2s" (begin (vector-ref (hash-table-ref (db:get-steps-table db test-id) "step1") 4))) (test "Rollup the run(s)" #t (begin