Index: Makefile
==================================================================
--- Makefile
+++ Makefile
@@ -105,10 +105,14 @@
chmod a+x $@
$(PREFIX)/bin/nbfind : utils/nbfind
$(INSTALL) $< $@
chmod a+x $@
+
+$(PREFIX)/bin/loadrunner : utils/loadrunner
+ $(INSTALL) $< $@
+ chmod a+x $@
$(PREFIX)/bin/refdb : refdb
$(INSTALL) $< $@
chmod a+x $@
@@ -126,11 +130,11 @@
$(INSTALL) dboard $(PREFIX)/bin/dboard
utils/mk_wrapper $(PREFIX) dboard > $(PREFIX)/bin/dashboard
chmod a+x $(PREFIX)/bin/dashboard
install : bin $(PREFIX)/bin/mtest $(PREFIX)/bin/megatest $(PREFIX)/bin/dboard $(PREFIX)/bin/dashboard $(HELPERS) $(PREFIX)/bin/nbfake \
- $(PREFIX)/bin/nbfind $(PREFIX)/bin/newdboard $(PREFIX)/bin/refdb $(PREFIX)/bin/mt_xterm $(PREFIX)/bin/revtagfsl
+ $(PREFIX)/bin/nbfind $(PREFIX)/bin/loadrunner $(PREFIX)/bin/newdboard $(PREFIX)/bin/refdb $(PREFIX)/bin/mt_xterm $(PREFIX)/bin/revtagfsl
deploytarg/apropos.so : Makefile
for i in apropos base64 canvas-draw csv-xml directory-utils dot-locking extras fmt format hostinfo http-client intarweb json md5 message-digest posix posix-extras readline regex regex-case s11n spiffy spiffy-request-vars sqlite3 srfi-1 srfi-18 srfi-69 tcp test uri-common check-errors synch matchable sql-null tcp-server rpc blob-utils string-utils variable-item defstruct uri-generic sendfile opensll openssl lookup-table list-utils stack; do \
chicken-install -prefix deploytarg -deploy $$i;done
Index: TODO
==================================================================
--- TODO
+++ TODO
@@ -1,4 +1,12 @@
-1. Confirm that branch transaction-for-sequential-writes content was added to trunk/development
-2. Add a host chooser for ssh to launch-tests
-3. Try making static executable
+TODO
+====
+
+Migration to inmem db plus per run db
+-------------------------------------
+
+. Re-work the dbstruct data structure?
+.. Move main.db to global?
+.. [ run-id.db inmemdb last-mod last-read last-sync inuse ]
+. Re-work all queries to use run-id to dereference server
+. Open main.db directly in calls to -runtests etc. No need to talk remote?
Index: api.scm
==================================================================
--- api.scm
+++ api.scm
@@ -50,10 +50,11 @@
((get-test-id) (apply db:get-test-id dbstruct params))
((get-tests-for-runs-mindata) (apply db:get-tests-for-runs-mindata dbstruct params))
((get-run-name-from-id) (apply db:get-run-name-from-id dbstruct params))
((delete-run) (apply db:delete-run dbstruct params))
((get-runs) (apply db:get-runs dbstruct params))
+ ((get-all-run-ids) (db:get-all-run-ids dbstruct))
((get-runs-by-patt) (apply db:get-runs-by-patt dbstruct params))
((lock/unlock-run) (apply db:lock/unlock-run dbstruct params))
((update-run-event_time) (apply db:update-run-event_time dbstruct params))
;; STEPS
@@ -70,28 +71,28 @@
(run-id (cadr params))
(realparams (cddr params)))
(db:with-db dbstruct run-id #t ;; these are all for modifying the db
(lambda (db)
(db:general-call db stmtname realparams)))))
- ((sync-inmem->db) (db:sync-touched dbstruct force-sync: #t))
- ((kill-server)
- (db:sync-tables (db:tbls *inmemdb*) *inmemdb* *db*) ;; (db:sync-to *inmemdb* *db*)
- (let ((hostname (car *runremote*))
- (port (cadr *runremote*))
- (pid (if (null? params) #f (car params)))
- (th1 (make-thread (lambda ()(thread-sleep! 3)(debug:print 0 "Server exiting!")(exit 0)) "Server exit thread")))
- (debug:print 0 "WARNING: Server on " hostname ":" port " going down by user request!")
- (debug:print-info 1 "current pid=" (current-process-id))
- (open-run-close tasks:server-deregister tasks:open-db
- hostname
- port: port)
- (set! *server-run* #f)
- (thread-sleep! 3)
- (if pid
- (process-signal pid signal/kill)
- (thread-start! th1))
- '(#t "exit process started")))
+ ((sync-inmem->db) (db:sync-touched dbstruct run-id force-sync: #t))
+ ;; ((kill-server)
+ ;; (db:sync-tables (db:tbls *inmemdb*) *inmemdb* *db*) ;; (db:sync-to *inmemdb* *db*)
+ ;; (let ((hostname (car *runremote*))
+ ;; (port (cadr *runremote*))
+ ;; (pid (if (null? params) #f (car params)))
+ ;; (th1 (make-thread (lambda ()(thread-sleep! 3)(debug:print 0 "Server exiting!")(exit 0)) "Server exit thread")))
+ ;; (debug:print 0 "WARNING: Server on " hostname ":" port " going down by user request!")
+ ;; (debug:print-info 1 "current pid=" (current-process-id))
+ ;; (open-run-close tasks:server-deregister tasks:open-db
+ ;; hostname
+ ;; port: port)
+ ;; (set! *server-run* #f)
+ ;; (thread-sleep! 3)
+ ;; (if pid
+ ;; (process-signal pid signal/kill)
+ ;; (thread-start! th1))
+ ;; '(#t "exit process started")))
((sdb-qry) (apply sdb:qry params))
;; TESTMETA
((testmeta-get-record) (apply db:testmeta-get-record dbstruct params))
((testmeta-add-record) (apply db:testmeta-add-record dbstruct params))
Index: client.scm
==================================================================
--- client.scm
+++ client.scm
@@ -50,43 +50,57 @@
;; 1. We are a test manager and we received *transport-type* and *runremote* via cmdline
;; 2. We are a run tests, list runs or other interactive process and we must figure out
;; *transport-type* and *runremote* from the monitor.db
;;
;; client:setup
-(define (client:setup #!key (numtries 3))
+(define (client:setup run-id #!key (remaining-tries 3))
(if (not *toppath*)
(if (not (setup-for-run))
(begin
(debug:print 0 "ERROR: failed to find megatest.config, exiting")
(exit))))
- (push-directory *toppath*) ;; This is probably NOT needed
+ ;; (push-directory *toppath*) ;; This is probably NOT needed
;; clients get the sdb:qry proc created here
;; (if (not sdb:qry)
;; (begin
;; (set! sdb:qry (make-sdb:qry (conc *toppath* "/db/strings.db"))) ;; we open the normalization helpers here
;; (sdb:qry 'setup #f)))
-
- (debug:print-info 11 "*transport-type* is " *transport-type* ", *runremote* is " *runremote*)
- (let* ((hostinfo (open-run-close tasks:get-best-server tasks:open-db)))
- (debug:print-info 11 "CLIENT SETUP, hostinfo=" hostinfo)
- (set! *transport-type* (if hostinfo
- (string->symbol (tasks:hostinfo-get-transport hostinfo))
- 'fs))
- (debug:print-info 11 "Using transport type of " *transport-type* (if hostinfo (conc " to connect to " hostinfo) ""))
- (case *transport-type*
- ;; ((fs)(if (not *megatest-db*)(set! *megatest-db* (open-db))))
- ((http)
- (http-transport:client-connect (tasks:hostinfo-get-interface hostinfo)
- (tasks:hostinfo-get-port hostinfo)))
- ((zmq)
- (zmq-transport:client-connect (tasks:hostinfo-get-interface hostinfo)
- (tasks:hostinfo-get-port hostinfo)
- (tasks:hostinfo-get-pubport hostinfo)))
- (else ;; default to fs
- (debug:print 0 "ERROR: unrecognised transport type " *transport-type* " exiting now.")
- (exit)))
- (pop-directory)))
+ (let ((hostinfo (and run-id (hash-table-ref/default *runremote* run-id #f))))
+ (debug:print-info 11 "for run-id=" run-id ", *transport-type* is " *transport-type*)
+ (if hostinfo
+ hostinfo ;; have hostinfo - just return it
+ (let* ((hostinfo (open-run-close tasks:get-server tasks:open-db run-id))
+ (transport (if hostinfo
+ (string->symbol (tasks:hostinfo-get-transport hostinfo))
+ 'http)))
+ (if (not hostinfo)
+ (if (> remaining-tries 0)
+ (begin
+ (server:ensure-running run-id)
+ (client:setup run-id remaining-tries: (- remaining-tries 1)))
+ (begin
+ (debug:print 0 "ERROR: Expected to be able to connect to a server by now. No server available for run-id = " run-id)
+ (exit 1)))
+ (begin
+ (hash-table-set! *runremote* run-id hostinfo)
+ (debug:print-info 11 "CLIENT SETUP, hostinfo=" hostinfo)
+ (debug:print-info 11 "Using transport type of " transport (if hostinfo (conc " to connect to " hostinfo) ""))
+ (case *transport-type*
+ ;; ((fs)(if (not *megatest-db*)(set! *megatest-db* (open-db))))
+ ((http)
+ ;; this saves the hostinfo in the *runremote* hash and returns it
+ (http-transport:client-connect run-id
+ (tasks:hostinfo-get-interface hostinfo)
+ (tasks:hostinfo-get-port hostinfo)))
+ ((zmq)
+ (zmq-transport:client-connect (tasks:hostinfo-get-interface hostinfo)
+ (tasks:hostinfo-get-port hostinfo)
+ (tasks:hostinfo-get-pubport hostinfo)))
+ (else ;; default to fs
+ (debug:print 0 "ERROR: unrecognised transport type " *transport-type* " exiting now.")
+ (exit)))))))))
+ ;; (pop-directory)))
;; client:signal-handler
(define (client:signal-handler signum)
(handle-exceptions
exn
@@ -103,13 +117,16 @@
(thread-start! th2)
(thread-start! th1)
(thread-join! th2))))
;; client:launch
-(define (client:launch)
+;; Need to set the signal handler somewhere other than here as this
+;; routine will go away.
+;;
+(define (client:launch run-id)
(set-signal-handler! signal/int client:signal-handler)
- (if (client:setup)
- (debug:print-info 2 "connected as client")
- (begin
- (debug:print 0 "ERROR: Failed to connect as client")
- (exit))))
+ (if (client:setup run-id)
+ (debug:print-info 2 "connected as client")
+ (begin
+ (debug:print 0 "ERROR: Failed to connect as client")
+ (exit))))
Index: common.scm
==================================================================
--- common.scm
+++ common.scm
@@ -43,14 +43,14 @@
;; DATABASE
(define *open-dbs* (vector #f (make-hash-table))) ;; megatestdb run-id-dbs
;; SERVER
(define *my-client-signature* #f)
-(define *transport-type* 'fs)
+(define *transport-type* 'http)
(define *megatest-db* #f)
(define *rpc:listener* #f) ;; if set up for server communication this will hold the tcp port
-(define *runremote* #f) ;; if set up for server communication this will hold
+(define *runremote* (make-hash-table)) ;; if set up for server communication this will hold
(define *last-db-access* (current-seconds)) ;; update when db is accessed via server
(define *max-cache-size* 0)
(define *logged-in-clients* (make-hash-table))
(define *client-non-blocking-mode* #f)
(define *server-id* #f)
@@ -59,10 +59,11 @@
(define *received-response* #f)
(define *default-numtries* 10)
(define *server-run* #t)
(define *db-write-access* #t)
(define *inmemdb* #f)
+(define *run-id* #f)
(define *target* (make-hash-table)) ;; cache the target here; target is keyval1/keyval2/.../keyvalN
(define *keys* (make-hash-table)) ;; cache the keys here
(define *keyvals* (make-hash-table))
(define *toptest-paths* (make-hash-table)) ;; cache toptest path settings here
@@ -346,11 +347,11 @@
"unknown"
(caar uname-res))))
(define (save-environment-as-files fname #!key (ignorevars (list "DISPLAY" "LS_COLORS" "XKEYSYMDB" "EDITOR")))
(let ((envvars (get-environment-variables))
- (whitesp (regexp "[^a-zA-Z0-9_\\-:;,.\\/%$]")))
+ (whitesp (regexp "[^a-zA-Z0-9_\\-:,.\\/%$]")))
(with-output-to-file (conc fname ".csh")
(lambda ()
(for-each (lambda (key)
(if (not (member key ignorevars))
(let* ((val (cdr key))
Index: dashboard-tests.scm
==================================================================
--- dashboard-tests.scm
+++ dashboard-tests.scm
@@ -76,12 +76,18 @@
lbl)
(store-label "testcomment"
(iup:label "TestComment "
#:expand "HORIZONTAL")
(lambda (testdat)
- ;; (sdb:qry 'getstr
- (db:test-get-comment testdat))) ;; )
+ (let ((newcomment (db:test-get-comment testdat)))
+ (if *dashboard-comment-share-slot*
+ (if (not (equal? (iup:attribute *dashboard-comment-share-slot* "VALUE")
+ newcomment))
+ (iup:attribute-set! *dashboard-comment-slot*
+ "VALUE"
+ newcomment)))
+ newcomment)))
(store-label "testid"
(iup:label "TestId "
#:expand "HORIZONTAL")
(lambda (testdat)
(db:test-get-id testdat)))
@@ -140,11 +146,11 @@
;;======================================================================
(define (run-info-panel db keydat testdat runname)
(let* ((run-id (db:test-get-run_id testdat))
(rundat (db:get-run-info db run-id))
(header (db:get-header rundat))
- (event_time (db:get-value-by-header (db:get-row rundat)
+ (event_time (db:get-value-by-header (db:get-rows rundat)
(db:get-header rundat)
"event_time")))
(iup:frame
#:title "Megatest Run Info" ; #:expand "YES"
(iup:hbox ; #:expand "YES"
@@ -216,28 +222,34 @@
(color (car (gutils:get-color-for-state-status state status))))
((vector-ref *state-status* 0) state color)
((vector-ref *state-status* 1) status color)))
(define *dashboard-test-db* #t)
+(define *dashboard-comment-share-slot* #f)
;;======================================================================
;; Set fields
;;======================================================================
(define (set-fields-panel dbstruct run-id test-id testdat #!key (db #f))
(let ((newcomment #f)
(newstatus #f)
- (newstate #f))
+ (newstate #f)
+ (wtxtbox #f))
(iup:frame
#:title "Set fields"
(iup:vbox
(iup:hbox (iup:label "Comment:")
- (iup:textbox #:action (lambda (val a b)
- (rmt:test-set-state-status-by-id run-id test-id #f #f b)
- ;; IDEA: Just set a variable with the proc to call?
- (set! newcomment b))
- #:value (db:test-get-comment testdat)
- #:expand "HORIZONTAL"))
+ (let ((txtbox (iup:textbox #:action (lambda (val a b)
+ (rmt:test-set-state-status-by-id run-id test-id #f #f b)
+ ;; IDEA: Just set a variable with the proc to call?
+ (rmt:test-set-state-status-by-id run-id test-id #f #f b)
+ (set! newcomment b))
+ #:value (db:test-get-comment testdat)
+ #:expand "HORIZONTAL")))
+ (set! wtxtbox txtbox)
+ txtbox))
+
(apply iup:hbox
(iup:label "STATE:" #:size "30x")
(let* ((btns (map (lambda (state)
(let ((btn (iup:button state
#:expand "HORIZONTAL" #:size "50x" #:font "Courier New, -10"
@@ -262,14 +274,22 @@
(let ((btn (iup:button status
#:expand "HORIZONTAL" #:size "50x" #:font "Courier New, -10"
#:action (lambda (x)
(let ((t (iup:attribute x "TITLE")))
(if (equal? t "WAIVED")
- (iup:show (dashboard-tests:waiver testdat (lambda (c)
- (set! newcomment c))))
+ (iup:show (dashboard-tests:waiver testdat
+ (if wtxtbox (iup:attribute wtxtbox "VALUE") #f)
+ (lambda (c)
+ (set! newcomment c)
+ (if wtxtbox
+ (begin
+ (iup:attribute-set! wtxtbox "VALUE" c)
+ (if (not *dashboard-comment-share-slot*)
+ (set! *dashboard-comment-share-slot* wtxtbox)))
+ ))))
(begin
- (open-run-close db:test-set-state-status-by-id db test-id #f status #f)
+ (rmt:test-set-state-status-by-id run-id test-id #f status #f)
(db:test-set-status! testdat status))))))))
btn))
(map cadr *common:std-statuses*)))) ;; (list "PASS" "WARN" "FAIL" "CHECK" "n/a" "WAIVED" "SKIP"))))
(vector-set! *state-status* 1
(lambda (status color)
@@ -314,21 +334,21 @@
;; #:expand "HORIZONTAL"
;; #:action (lambda (obj)
;; (print "Refresh test data " stepname))
)))
-(define (dashboard-tests:waiver testdat cmtcmd)
+(define (dashboard-tests:waiver testdat ovrdval cmtcmd)
(let* ((wpatt (configf:lookup *configdat* "setup" "waivercommentpatt"))
(wregx (if (string? wpatt)(regexp wpatt) #f))
(wmesg (iup:label (if wpatt (conc "Comment must match pattern " wpatt) "")))
(comnt (iup:textbox #:action (lambda (val a b)
(if wpatt
(if (string-match wregx b)
(iup:attribute-set! wmesg "TITLE" (conc "Comment matches " wpatt))
(iup:attribute-set! wmesg "TITLE" (conc "Comment does not match " wpatt))
)))
- #:value (db:test-get-comment testdat)
+ #:value (if ovrdval ovrdval (db:test-get-comment testdat))
#:expand "HORIZONTAL"))
(dlog #f))
(set! dlog (iup:dialog ;; #:close_cb (lambda (a)(exit)) ; #:expand "YES"
#:title "SET WAIVER"
(iup:vbox ; #:expand "YES"
@@ -346,11 +366,11 @@
(let ((comment (iup:attribute comnt "VALUE"))
(test-id (db:test-get-id testdat)))
(if (or (not wpatt)
(string-match wregx comment))
(begin
- (open-run-close db:test-set-state-status-by-id #f test-id #f "WAIVED" comment)
+ (rmt:test-set-state-status-by-id run-id test-id #f "WAIVED" comment)
(db:test-set-status! testdat "WAIVED")
(cmtcmd comment)
(iup:destroy! dlog))))))
(iup:button "Cancel"
#:expand "HORIZONTAL"
@@ -462,11 +482,11 @@
(debug:print 2 "ERROR: No test data found for test " test-id ", exiting")
(exit 1))
(let* (;; (run-id (if testdat (db:test-get-run_id testdat) #f))
(keydat (if testdat (db:get-key-val-pairs dbstruct run-id) #f))
(rundat (if testdat (db:get-run-info dbstruct run-id) #f))
- (runname (if testdat (db:get-value-by-header (db:get-row rundat)
+ (runname (if testdat (db:get-value-by-header (db:get-rows rundat)
(db:get-header rundat)
"runname") #f))
(tdb (tdb:open-test-db-by-test-id-local dbstruct run-id test-id))
;; These next two are intentional bad values to ensure errors if they should not
;; get filled in properly.
Index: dashboard.scm
==================================================================
--- dashboard.scm
+++ dashboard.scm
@@ -44,11 +44,11 @@
(include "megatest-fossil-hash.scm")
(define help (conc
"Megatest Dashboard, documentation at http://www.kiatoa.com/fossils/megatest
version " megatest-version "
- license GPL, Copyright (C) Matt Welland 2013
+ license GPL, Copyright (C) Matt Welland 2012-2014
Usage: dashboard [options]
-h : this help
-server host:port : connect to host:port instead of db access
-test run-id,test-id : control test identified by testid
@@ -86,11 +86,11 @@
(if (not (setup-for-run))
(begin
(print "Failed to find megatest.config, exiting")
(exit 1)))
-(define *db* (make-dbr:dbstruct path: *toppath* local: #t))
+(define *dbstruct-local* (make-dbr:dbstruct path: *toppath* local: #t))
;; (define sdb:qry (make-sdb:qry)) ;; 'init #f)
;; (if (args:get-arg "-host")
;; (begin
@@ -99,19 +99,19 @@
;; (if (not (args:get-arg "-use-server"))
;; (set! *transport-type* 'fs) ;; force fs access
;; (client:launch)))
;; HACK ALERT: this is a hack, please fix.
-(define *read-only* (not (file-read-access? (conc *toppath* "/megatest.db"))))
-;; (client:setup *db*)
+(define *read-only* (not (file-read-access? (conc *toppath* "db/main.db"))))
+;; (client:setup *dbstruct-local*)
(define toplevel #f)
(define dlg #f)
(define max-test-num 0)
-(define *keys* (db:get-keys *db*))
+(define *keys* (db:get-keys *dbstruct-local*))
;; (define *keys* (cdb:remote-run db:get-keys #f))
-;; (define *keys* (db:get-keys *db*))
+;; (define *keys* (db:get-keys *dbstruct-local*))
(define *dbkeys* (append *keys* (list "runname")))
(define *header* #f)
(define *allruns* '())
@@ -120,12 +120,12 @@
(define *buttondat* (make-hash-table)) ;;
(define *alltestnamelst* '())
(define *searchpatts* (make-hash-table))
(define *num-runs* 8)
-(define *tot-run-count* (db:get-num-runs *db* "%"))
-;; (define *tot-run-count* (db:get-num-runs *db* "%"))
+(define *tot-run-count* (db:get-num-runs *dbstruct-local* "%"))
+;; (define *tot-run-count* (db:get-num-runs *dbstruct-local* "%"))
;; Update management
;;
(define *last-update* (current-seconds))
(define *last-db-update-time* 0)
@@ -207,11 +207,11 @@
(null? (filter (lambda (x)(> x 3)) delta))))
;; keypatts: ( (KEY1 "abc%def")(KEY2 "%") )
(define (update-rundat runnamepatt numruns testnamepatt keypatts)
(let* ((referenced-run-ids '())
- (allruns (db:get-runs *db* runnamepatt numruns ;; (+ numruns 1) ;; (/ numruns 2))
+ (allruns (db:get-runs *dbstruct-local* runnamepatt numruns ;; (+ numruns 1) ;; (/ numruns 2))
*start-run-offset* keypatts))
(header (db:get-header allruns))
(runs (db:get-rows allruns))
(result '())
(maxtests 0)
@@ -226,19 +226,19 @@
;;
;; trim runs to only those that are changing often here
;;
(for-each (lambda (run)
(let* ((run-id (db:get-value-by-header run header "id"))
- (tests (db:get-tests-for-run *db* run-id testnamepatt states statuses
+ (tests (db:get-tests-for-run *dbstruct-local* run-id testnamepatt states statuses
#f #f
*hide-not-hide*
sort-by
sort-order
'shortlist))
;; NOTE: bubble-up also sets the global *all-item-test-names*
;; (tests (bubble-up tmptests priority: bubble-type))
- (key-vals (db:get-key-vals *db* run-id)))
+ (key-vals (db:get-key-vals *dbstruct-local* run-id)))
;; NOTE: 11/01/2013 This routine is *NOT* getting called excessively.
;; (debug:print 0 "Getting data for run " run-id " with key-vals=" key-vals)
;; Not sure this is needed?
(set! referenced-run-ids (cons run-id referenced-run-ids))
(if (> (length tests) maxtests)
@@ -561,11 +561,11 @@
(iup:attribute-set! lb "VALUE" newval)
newval))))))
(define (dashboard:update-target-selector key-lbs #!key (action-proc #f))
(let* ((runconf-targs (common:get-runconfig-targets))
- (db-target-dat (db:get-targets *db*))
+ (db-target-dat (db:get-targets *dbstruct-local*))
(header (vector-ref db-target-dat 0))
(db-targets (vector-ref db-target-dat 1))
(all-targets (append db-targets
(map (lambda (x)
(list->vector
@@ -826,11 +826,11 @@
(iup:attribute-set! tb "VALUE" val)
(dboard:data-set-run-name! *data* val)
(dashboard:update-run-command))))
(refresh-runs-list (lambda ()
(let* ((target (dboard:data-get-target-string *data*))
- (runs-for-targ (db:get-runs-by-patt *db* *keys* "%" target #f #f))
+ (runs-for-targ (db:get-runs-by-patt *dbstruct-local* *keys* "%" target #f #f))
(runs-header (vector-ref runs-for-targ 0))
(runs-dat (vector-ref runs-for-targ 1))
(run-names (cons default-run-name
(map (lambda (x)
(db:get-value-by-header x runs-header "runname"))
@@ -1219,11 +1219,11 @@
(iup:attribute-set! obj "TITLE" (if *hide-not-hide* "HideTests" "NotHide"))
(mark-for-update)))))
(set! *hide-not-hide-button* hideit)
hideit))
(iup:hbox
- (iup:button "Quit" #:action (lambda (obj)(if *db* (db:close-all *db*))(exit)))
+ (iup:button "Quit" #:action (lambda (obj)(if *dbstruct-local* (db:close-all *dbstruct-local*))(exit)))
(iup:button "Refresh" #:action (lambda (obj)
(mark-for-update)))
(iup:button "Collapse" #:action (lambda (obj)
(let ((myname (iup:attribute obj "TITLE")))
(if (equal? myname "Collapse")
@@ -1438,12 +1438,17 @@
;; Force creation of the db in case it isn't already there.
(let ((db (tasks:open-db)))
(sqlite3:finalize! db))
+(define (dashboard:get-youngest-run-db-mod-time)
+ (apply max (map (lambda (filen)
+ (file-modification-time filen))
+ (glob (conc *toppath* "/db/*.db")))))
+
(define (dashboard:run-update x)
- (let* ((modtime (file-modification-time *db-file-path*))
+ (let* ((modtime (dashboard:get-youngest-run-db-mod-time)) ;; (file-modification-time *db-file-path*))
(monitor-modtime (file-modification-time *monitor-db-path*))
(run-update-time (current-seconds))
(recalc (dashboard:recalc modtime *please-update-buttons* *last-db-update-time*)))
(if (and (eq? *current-tab-number* 0)
(> monitor-modtime *last-monitor-update-time*))
@@ -1491,12 +1496,12 @@
(let ((runid (string->number (args:get-arg "-run"))))
(if runid
(begin
(lambda (x)
(on-exit (lambda ()
- (if *db* (db:close-all *db*))))
- (examine-run *db* runid)))
+ (if *dbstruct-local* (db:close-all *dbstruct-local*))))
+ (examine-run *dbstruct-local* runid)))
(begin
(print "ERROR: runid is not a number " (args:get-arg "-run"))
(exit 1)))))
((args:get-arg "-test") ;; run-id,test-id
(let* ((dat (map string->number (string-split (args:get-arg "-test") ",")))
@@ -1508,13 +1513,13 @@
(examine-test run-id test-id)
(begin
(debug:print 3 "INFO: tried to open test with invalid run-id,test-id. " (args:get-arg "-test"))
(exit 1)))))
((args:get-arg "-guimonitor")
- (gui-monitor *db*))
+ (gui-monitor *dbstruct-local*))
(else
- (set! uidat (make-dashboard-buttons *db* *num-runs* *num-tests* *dbkeys*))
+ (set! uidat (make-dashboard-buttons *dbstruct-local* *num-runs* *num-tests* *dbkeys*))
(iup:callback-set! *tim*
"ACTION_CB"
(lambda (x)
(let ((update-is-running #f))
(mutex-lock! *update-mutex*)
@@ -1529,6 +1534,6 @@
(set! *update-is-running* #f)
(mutex-unlock! *update-mutex*))))
1))))
(iup:main-loop)
-(db:close-all *db*)
+(db:close-all *dbstruct-local*)
Index: db.scm
==================================================================
--- db.scm
+++ db.scm
@@ -68,13 +68,13 @@
(define (db:done-with dbstruct run-id mod-read)
(if (not (sqlite3:database? dbstruct))
(begin
(mutex-lock! *rundb-mutex*)
(if (eq? mod-read 'mod)
- (dbr:dbstruct-set-runvec-val! dbstruct run-id 'mtime (current-milliseconds))
- (dbr:dbstruct-set-runvec-val! dbstruct run-id 'rtime (current-milliseconds)))
- (dbr:dbstruct-set-runvec-val! dbstruct run-id 'inuse #f)
+ (dbr:dbstruct-set-mtime! dbstruct (current-milliseconds))
+ (dbr:dbstruct-set-rtime! dbstruct (current-milliseconds)))
+ (dbr:dbstruct-set-inuse! dbstruct #f)
(mutex-unlock! *rundb-mutex*))))
;; (db:with-db dbstruct run-id sqlite3:exec "select blah from blaz;")
;; r/w is a flag to indicate if the db is modified by this query #t = yes, #f = no
;;
@@ -109,18 +109,21 @@
;; (filedb:get-path db id)))
;; This routine creates the db. It is only called if the db is not already opened
;;
(define (db:open-rundb dbstruct run-id) ;; (conc *toppath* "/megatest.db") (car *configinfo*)))
- (let ((rdb (dbr:dbstruct-get-runrec dbstruct run-id 'inmem)))
+ (let* ((local (dbr:dbstruct-get-local dbstruct))
+ (rdb (if local
+ (dbr:dbstruct-get-localdb dbstruct run-id)
+ (dbr:dbstruct-get-inmem dbstruct)))) ;; (dbr:dbstruct-get-runrec dbstruct run-id 'inmem)))
(if rdb
rdb
- (let* ((local (dbr:dbstruct-get-local dbstruct))
- (toppath (dbr:dbstruct-get-path dbstruct))
+ (let* ((toppath (dbr:dbstruct-get-path dbstruct))
(dbpath (conc toppath "/db/" run-id ".db"))
(dbexists (file-exists? dbpath))
(inmem (if local #f (db:open-inmem-db)))
+ (refdb (if local #f (db:open-inmem-db)))
(db (sqlite3:open-database dbpath))
(write-access (file-write-access? dbpath))
(handler (make-busy-timeout 136000)))
(if (and dbexists (not write-access))
(set! *db-write-access* #f)) ;; only unset so other db's also can use this control
@@ -130,20 +133,22 @@
(begin
(db:initialize-run-id-db db)
;; (sdb:initialize db)
)) ;; add strings db to rundb, not in use yet
(sqlite3:set-busy-handler! db handler)
- (sqlite3:execute db "PRAGMA synchronous = 0;")))
- (dbr:dbstruct-set-runvec-val! dbstruct run-id 'rundb db)
- (dbr:dbstruct-set-runvec-val! dbstruct run-id 'inuse #t)
+ (sqlite3:execute db "PRAGMA synchronous = 1;"))) ;; was 0 but 0 is a gamble
+ (dbr:dbstruct-set-rundb! dbstruct db)
+ (dbr:dbstruct-set-inuse! dbstruct #t)
(if local
(begin
- (dbr:dbstruct-set-runvec-val! dbstruct run-id 'inmem db) ;; direct access ...
+ (dbr:dbstruct-set-localdb! dbstruct run-id db) ;; (dbr:dbstruct-set-inmem! dbstruct db) ;; direct access ...
db)
(begin
- (dbr:dbstruct-set-runvec-val! dbstruct run-id 'inmem inmem)
+ (dbr:dbstruct-set-inmem! dbstruct inmem)
(db:sync-tables db:sync-tests-only db inmem)
+ (dbr:dbstruct-set-refdb! dbstruct refdb)
+ (db:sync-tables db:sync-tests-only db refdb)
inmem))))))
;; This routine creates the db. It is only called if the db is not already opened
;;
(define (db:open-main dbstruct) ;; (conc *toppath* "/megatest.db") (car *configinfo*)))
@@ -170,23 +175,13 @@
(dbr:dbstruct-set-main! dbstruct db)
db))))
;; Make the dbstruct, setup up auxillary db's and call for main db at least once
;;
-(define (db:setup #!key (local #f))
+(define (db:setup run-id #!key (local #f))
(let ((dbstruct (make-dbr:dbstruct path: *toppath* local: local)))
(db:get-db dbstruct #f) ;; force one call to main
- ;; (if (not sdb:qry)
- ;; (begin
- ;; (set! sdb:qry (make-sdb:qry (conc *toppath* "/db/strings.db"))) ;; we open the normalization helpers here
- ;; (sdb:qry 'setup #f)
- ;; ;; Initialize with some known needed strings, NOTE: set this up to only execute on first db initialization
- ;; (for-each
- ;; (lambda (str)
- ;; (sdb:qry 'get-id str))
- ;; (list "" "logs/final.log"))))
- ;; (set! *fdb* (filedb:open-db (conc *toppath* "/db/paths.db")))
dbstruct))
;; Open the classic megatest.db file in toppath
;;
(define (db:open-megatest-db)
@@ -206,40 +201,60 @@
(db:initialize-main-db db)
(db:initialize-run-id-db db)))
db))
;; sync all touched runs to disk
+;;
(define (db:sync-touched dbstruct #!key (force-sync #f))
(let ((tot-synced 0))
(for-each
(lambda (runvec)
(let ((mtime (vector-ref runvec (dbr:dbstruct-field-name->num 'mtime)))
(stime (vector-ref runvec (dbr:dbstruct-field-name->num 'stime)))
(rundb (vector-ref runvec (dbr:dbstruct-field-name->num 'rundb)))
- (inmem (vector-ref runvec (dbr:dbstruct-field-name->num 'inmem))))
+ (inmem (vector-ref runvec (dbr:dbstruct-field-name->num 'inmem)))
+ (refdb (vector-ref runvec (dbr:dbstruct-field-name->num 'refdb))))
(if (or (> mtime stime) force-sync)
- (let ((num-synced (db:sync-tables db:sync-tests-only inmem rundb)))
+ (let ((num-synced (db:sync-tables db:sync-tests-only inmem refdb rundb)))
(set! tot-synced (+ tot-synced num-synced))
(vector-set! runvec (dbr:dbstruct-field-name->num 'stime) (current-milliseconds))))))
(hash-table-values (vector-ref dbstruct 1)))
tot-synced))
+
+;; sync run to disk if touched
+;;
+(define (db:sync-touched dbstruct #!key (force-sync #f))
+ (let ((mtime (dbr:dbstruct-get-mtime dbstruct))
+ (stime (dbr:dbstruct-get-stime dbstruct))
+ (rundb (dbr:dbstruct-get-rundb dbstruct))
+ (inmem (dbr:dbstruct-get-inmem dbstruct))
+ (refdb (dbr:dbstruct-get-refdb dbstruct)))
+ (if (or (not (number? mtime))
+ (not (number? stime))
+ (> mtime stime)
+ force-sync)
+ (let ((num-synced (db:sync-tables db:sync-tests-only inmem refdb rundb)))
+ (dbr:dbstruct-set-stime! dbstruct (current-milliseconds))
+ num-synced)
+ 0)))
;; close all opened run-id dbs
(define (db:close-all dbstruct)
;; finalize main.db
(db:sync-touched dbstruct force-sync: #t)
(sqlite3:finalize! (db:get-db dbstruct #f))
- (for-each
- (lambda (runvec)
- (let ((rundb (vector-ref runvec (dbr:dbstruct-field-name->num 'rundb))))
- (if (sqlite3:database? rundb)
- (sqlite3:finalize! rundb)
- (debug:print 0 "WARNING: attempting to close databases but got " rundb " instead of a database"))))
- (hash-table-values (vector-ref dbstruct 1)))
- ;; (sdb:qry 'finalize! #f)
- )
- ;; (filedb:finalize-db! *fdb*))
+ (let* ((local (dbr:dbstruct-get-local dbstruct))
+ (rundb (dbr:dbstruct-get-rundb dbstruct)))
+ (if local
+ (for-each
+ (lambda (db)
+ (if (sqlite3:database? db)
+ (sqlite3:finalize! db)))
+ (hash-table-values (dbr:dbstruct-get-locdbs dbstruct)))
+ (if (sqlite3:database? rundb)
+ (sqlite3:finalize! rundb)
+ (debug:print 0 "WARNING: attempting to close databases but got " rundb " instead of a database")))))
(define (db:open-inmem-db)
(let* ((db (sqlite3:open-database ":memory:"))
(handler (make-busy-timeout 3600)))
(db:initialize-run-id-db db)
@@ -323,11 +338,11 @@
'("avg_disk" #f)
'("tags" #f)
'("jobgroup" #f)))))
;; tbls is ( ("tablename" ( "field1" [#f|proc1] ) ( "field2" [#f|proc2] ) .... ) )
-(define (db:sync-tables tbls fromdb todb)
+(define (db:sync-tables tbls fromdb todb . slave-dbs)
(cond
((not fromdb) (debug:print 0 "ERROR: db:sync-tables called with fromdb missing") -1)
((not todb) (debug:print 0 "ERROR: db:sync-tables called with todb missing") -2)
((not (sqlite3:database? fromdb))
(debug:print 0 "ERROR: db:sync-tables called with fromdb not a database " fromdb) -3)
@@ -376,32 +391,35 @@
(hash-table-set! todat a (apply vector a b)))
todb
full-sel)
;; first pass implementation, just insert all changed rows
- (let ((stmth (sqlite3:prepare todb full-ins)))
- (sqlite3:with-transaction
- todb
- (lambda ()
- (for-each ;;
- (lambda (fromrow)
- (let* ((a (vector-ref fromrow 0))
- (curr (hash-table-ref/default todat a #f))
- (same #t))
- (let loop ((i 0))
- (if (or (not curr)
- (not (equal? (vector-ref fromrow i)(vector-ref curr i))))
- (set! same #f))
- (if (and same
- (< i (- num-fields 1)))
- (loop (+ i 1))))
- (if (not same)
- (begin
- (apply sqlite3:execute stmth (vector->list fromrow))
- (hash-table-set! numrecs tablename (+ 1 (hash-table-ref/default numrecs tablename 0)))))))
- fromdat)))
- (sqlite3:finalize! stmth))))
+ (for-each
+ (lambda (targdb)
+ (let ((stmth (sqlite3:prepare targdb full-ins)))
+ (sqlite3:with-transaction
+ targdb
+ (lambda ()
+ (for-each ;;
+ (lambda (fromrow)
+ (let* ((a (vector-ref fromrow 0))
+ (curr (hash-table-ref/default todat a #f))
+ (same #t))
+ (let loop ((i 0))
+ (if (or (not curr)
+ (not (equal? (vector-ref fromrow i)(vector-ref curr i))))
+ (set! same #f))
+ (if (and same
+ (< i (- num-fields 1)))
+ (loop (+ i 1))))
+ (if (not same)
+ (begin
+ (apply sqlite3:execute stmth (vector->list fromrow))
+ (hash-table-set! numrecs tablename (+ 1 (hash-table-ref/default numrecs tablename 0)))))))
+ fromdat)))
+ (sqlite3:finalize! stmth)))
+ (append (list todb) slave-dbs))))
tbls)
(let ((runtime (- (current-milliseconds) start-time)))
(debug:print 0 "INFO: db sync, total run time " runtime " ms")
(for-each
(lambda (dat)
@@ -772,21 +790,25 @@
(db:get-db dbstruct #f)
"SELECT fieldname FROM keys ORDER BY id DESC;")))
(set! *db-keys* res)
res)))
-;;
+;; look up values in a header/data structure
(define (db:get-value-by-header row header field)
- (debug:print-info 4 "db:get-value-by-header row: " row " header: " header " field: " field)
(if (null? header) #f
(let loop ((hed (car header))
(tal (cdr header))
(n 0))
(if (equal? hed field)
(vector-ref row n)
(if (null? tal) #f (loop (car tal)(cdr tal)(+ n 1)))))))
+;; Accessors for the header/data structure
+;; get rows and header from
+(define (db:get-header vec)(vector-ref vec 0))
+(define (db:get-rows vec)(vector-ref vec 1))
+
;;======================================================================
;; R U N S
;;======================================================================
(define (db:get-run-name-from-id dbstruct run-id)
@@ -828,13 +850,14 @@
'("")
patts))
comparator)))
-;; register a test run with the db
+;; register a test run with the db, this accesses the main.db and does NOT
+;; use server api
+;;
(define (db:register-run dbstruct keyvals runname state status user)
- (debug:print 3 "runs:register-run runname: " runname " state: " state " status: " status " user: " user)
(let* ((db (db:get-db dbstruct #f))
(keys (map car keyvals))
(keystr (keys->keystr keys))
(comma (if (> (length keys) 0) "," ""))
(andstr (if (> (length keys) 0) " AND " ""))
@@ -935,10 +958,19 @@
(set! numruns count))
(db:get-db dbstruct #f)
"SELECT COUNT(id) FROM runs WHERE runname LIKE ? AND state != 'deleted';" runpatt)
(debug:print-info 11 "db:get-num-runs END " runpatt)
numruns))
+
+(define (db:get-all-run-ids dbstruct)
+ (let ((run-ids '()))
+ (sqlite3:for-each-row
+ (lambda (run-id)
+ (set! run-ids (cons run-id run-ids)))
+ (db:get-db dbstruct #f)
+ "SELECT id FROM runs WHERE state != 'deleted';")
+ run-ids))
;; get some basic run stats
;;
;; ( (runname (( state count ) ... ))
;; ( ...
@@ -975,11 +1007,11 @@
;; db:get-runs-by-patt
;; get runs by list of criteria
;; register a test run with the db
;;
-;; Use: (db-get-value-by-header (db:get-header runinfo)(db:get-row runinfo))
+;; Use: (db:get-value-by-header (db:get-header runinfo)(db:get-rows runinfo))
;; to extract info from the structure returned
;;
(define (db:get-runs-by-patt dbstruct keys runnamepatt targpatt offset limit) ;; test-name)
(let* ((tmp (runs:get-std-run-fields keys '("id" "runname" "state" "status" "owner" "event_time")))
(keystr (car tmp))
@@ -1013,11 +1045,11 @@
(db:get-db dbstruct #f)
qry-str
runnamepatt)))
(vector header res)))
-;; use (get-value-by-header (db:get-header runinfo)(db:get-row runinfo))
+;; use (get-value-by-header (db:get-header runinfo)(db:get-rows runinfo))
(define (db:get-run-info dbstruct run-id)
;;(if (hash-table-ref/default *run-info-cache* run-id #f)
;; (hash-table-ref *run-info-cache* run-id)
(let* ((res (vector #f #f #f #f))
(keys (db:get-keys dbstruct))
@@ -1316,11 +1348,11 @@
(else
(if newstate (sqlite3:execute db "UPDATE tests SET state=? WHERE id=?;" newstate test-id))
(if newstatus (sqlite3:execute db "UPDATE tests SET status=? WHERE id=?;" newstatus test-id))
(if newcomment (sqlite3:execute db "UPDATE tests SET comment=? WHERE id=?;" newcomment ;; (sdb:qry 'getid newcomment)
test-id))))
- (mt:process-triggers test-id newstate newstatus)))
+ (mt:process-triggers run-id test-id newstate newstatus)))
;; Never used, but should be?
(define (db:test-set-state-status-by-run-id-testname db run-id test-name item-path status state)
(sqlite3:execute db "UPDATE tests SET state=?,status=?,event_time=strftime('%s','now') WHERE run_id=? AND testname=? AND item_path=?;"
state status run-id test-name item-path))
@@ -1331,11 +1363,12 @@
(let ((res 0))
(sqlite3:for-each-row
(lambda (count)
(set! res count))
(db:get-db dbstruct run-id)
- "SELECT count(id) FROM tests WHERE state in ('RUNNING','LAUNCHED','REMOTEHOSTSTART');")
+ "SELECT count(id) FROM tests WHERE state in ('RUNNING','LAUNCHED','REMOTEHOSTSTART') AND run_id=?;"
+ run-id) ;; NOT IN (SELECT id FROM runs WHERE state='deleted');")
res))
;; NEW BEHAVIOR: Look only at single run with run-id
;;
;; (define (db:get-running-stats dbstruct run-id)
@@ -1349,18 +1382,28 @@
res))
(define (db:get-count-tests-running-in-jobgroup dbstruct run-id jobgroup)
(if (not jobgroup)
0 ;;
- (let ((res 0))
+ (let ((res 0)
+ (testnames '()))
+ ;; get the testnames
(sqlite3:for-each-row
- (lambda (count)
- (set! res count))
- (db:get-db dbstruct run-id)
- "SELECT count(id) FROM tests WHERE state = 'RUNNING' OR state = 'LAUNCHED' OR state = 'REMOTEHOSTSTART'
- AND testname in (SELECT testname FROM test_meta WHERE jobgroup=?);"
+ (lambda (testname)
+ (set! testnames (cons testname testnames)))
+ (db:get-db dbstruct #f)
+ "SELECT testname FROM test_meta WHERE jobgroup=?"
jobgroup)
+ ;; get the jobcount NB// EXTEND THIS TO OPPERATE OVER ALL RUNS?
+ (if (not (null? testnames))
+ (sqlite3:for-each-row
+ (lambda (count)
+ (set! res count))
+ (db:get-db dbstruct run-id)
+ (conc "SELECT count(id) FROM tests WHERE state in ('RUNNING','LAUNCHED','REMOTEHOSTSTART') AND testname in ('"
+ (string-intersperse testnames "','")
+ "');")))
res)))
;; done with run when:
;; 0 tests in LAUNCHED, NOT_STARTED, REMOTEHOSTSTART, RUNNING
(define (db:estimated-tests-remaining dbstruct run-id)
@@ -1897,14 +1940,14 @@
;; read the record given a testname
(define (db:testmeta-get-record dbstruct testname)
(let ((res #f))
(sqlite3:for-each-row
- (lambda (id testname author owner description reviewed iterated avg_runtime avg_disk tags)
- (set! res (vector id testname author owner description reviewed iterated avg_runtime avg_disk tags)))
+ (lambda (id testname author owner description reviewed iterated avg_runtime avg_disk tags jobgroup)
+ (set! res (vector id testname author owner description reviewed iterated avg_runtime avg_disk tags jobgroup)))
(db:get-db dbstruct #f)
- "SELECT id,testname,author,owner,description,reviewed,iterated,avg_runtime,avg_disk,tags FROM test_meta WHERE testname=?;"
+ "SELECT id,testname,author,owner,description,reviewed,iterated,avg_runtime,avg_disk,tags,jobgroup FROM test_meta WHERE testname=?;"
testname)
res))
;; create a new record for a given testname
(define (db:testmeta-add-record dbstruct testname)
Index: db_records.scm
==================================================================
--- db_records.scm
+++ db_records.scm
@@ -8,76 +8,112 @@
;; |-monitor.db
;; |-sdb.db
;; |-fdb.db
;; |-1.db
;; |-.db
-(define (make-dbr:dbstruct #!key (path #f)(local #f))
- (vector
- #f ;; the main db (contains runs, test_meta etc.) NOT CACHED IN MEM
- (make-hash-table) ;; run-id => [ rundb inmemdb last-mod last-read last-sync ]
- #f ;; the global string db (use for state, status etc.)
- path ;; path to database files/megatest area
- local)) ;; read-only local access
-
+;;
;;
;; Accessors for a dbstruct
;;
-;; get and set main db
-(define-inline (dbr:dbstruct-get-main vec) (vector-ref vec 0))
-(define-inline (dbr:dbstruct-set-main! vec db)(vector-set! vec 0 db))
-;; get the runs hash
-(define-inline (dbr:dbstruct-get-dbhash vec) (vector-ref vec 1))
-;; the string db
-(define-inline (dbr:dbstruct-get-strdb vec) (vector-ref vec 2))
-(define-inline (dbr:dbstruct-set-strdb! vec db)(vector-set! vec 2 db))
-;; path
-(define-inline (dbr:dbstruct-get-path vec) (vector-ref vec 3))
-(define-inline (dbr:dbstruct-set-path! vec path)(vector-set! vec 3))
-;; local
-(define-inline (dbr:dbstruct-get-local vec) (vector-ref vec 4))
-(define-inline (dbr:dbstruct-set-local! vec val)(vector-set! vec 4 val))
-
-;; get a rundb vector, create it if not already existing
-(define (dbr:dbstruct-get-rundb-rec vec run-id)
- (let* ((dbhash (dbr:dbstruct-get-dbhash vec)) ;; get the runs hash
- (runvec (hash-table-ref/default dbhash run-id #f))) ;; get the vector for run-id
- (if (vector? runvec)
- runvec ;; rundb inmemdb last-mod last-read last-sync in-use
- (let ((nvec (vector #f #f -1 -1 -1 #f)))
- (hash-table-set! dbhash run-id nvec)
- nvec))))
-
-;; [ rundb inmemdb last-mod last-read last-sync ]
-(define-inline (dbr:dbstruct-field-name->num field-name)
- (case field-name
- ((rundb) 0) ;; the on-disk db
- ((inmem) 1) ;; the in-memory db
- ((mtime) 2) ;; last modification time
- ((rtime) 3) ;; last read time
- ((stime) 4) ;; last sync time
- ((inuse) 5) ;; is the db currently in use, #t yes, #f no.
- (else -1)))
-
-;; get/set rundb fields
-(define (dbr:dbstruct-get-runvec-val vec run-id field-name)
- (let ((runvec (dbr:dbstruct-get-rundb-rec vec run-id))
- (fieldnum (dbr:dbstruct-field-name->num field-name)))
- ;; (vector-set! runvec (dbr:dbstruct-field-name->num 'inuse) #t)
- (vector-ref runvec fieldnum)))
-
-(define (dbr:dbstruct-set-runvec-val! vec run-id field-name val)
- (let ((runvec (dbr:dbstruct-get-rundb-rec vec run-id)))
- (vector-set! runvec (dbr:dbstruct-field-name->num field-name) val)))
-
-;; get/set inmemdb
-(define (dbr:dbstruct-get-inmemdb vec run-id)
- (let ((runvec (dbr:dbstruct-get-rundb-rec vec run-id)))
- (vector-ref runvec 1)))
-
-(define (dbr:dbstruct-set-inmemdb! vec run-id inmemdb)
- (let ((runvec (dbr:dbstruct-get-rundb-rec vec run-id)))
- (vector-set! runvec 1 inmemdb)))
+
+(define-inline (dbr:dbstruct-get-main vec) (vector-ref vec 0))
+(define-inline (dbr:dbstruct-get-strdb vec) (vector-ref vec 1))
+(define-inline (dbr:dbstruct-get-path vec) (vector-ref vec 2))
+(define-inline (dbr:dbstruct-get-local vec) (vector-ref vec 3))
+(define-inline (dbr:dbstruct-get-rundb vec) (vector-ref vec 4))
+(define-inline (dbr:dbstruct-get-inmem vec) (vector-ref vec 5))
+(define-inline (dbr:dbstruct-get-mtime vec) (vector-ref vec 6))
+(define-inline (dbr:dbstruct-get-rtime vec) (vector-ref vec 7))
+(define-inline (dbr:dbstruct-get-stime vec) (vector-ref vec 8))
+(define-inline (dbr:dbstruct-get-inuse vec) (vector-ref vec 9))
+(define-inline (dbr:dbstruct-get-refdb vec) (vector-ref vec 10))
+(define-inline (dbr:dbstruct-get-locdbs vec) (vector-ref vec 11))
+
+(define-inline (dbr:dbstruct-set-main! vec val)(vector-set! vec 0 val))
+(define-inline (dbr:dbstruct-set-strdb! vec val)(vector-set! vec 1 val))
+(define-inline (dbr:dbstruct-set-path! vec val)(vector-set! vec 2 val))
+(define-inline (dbr:dbstruct-set-local! vec val)(vector-set! vec 3 val))
+(define-inline (dbr:dbstruct-set-rundb! vec val)(vector-set! vec 4 val))
+(define-inline (dbr:dbstruct-set-inmem! vec val)(vector-set! vec 5 val))
+(define-inline (dbr:dbstruct-set-mtime! vec val)(vector-set! vec 6 val))
+(define-inline (dbr:dbstruct-set-rtime! vec val)(vector-set! vec 7 val))
+(define-inline (dbr:dbstruct-set-stime! vec val)(vector-set! vec 8 val))
+(define-inline (dbr:dbstruct-set-inuse! vec val)(vector-set! vec 9 val))
+(define-inline (dbr:dbstruct-set-refdb! vec val)(vector-set! vec 10 val))
+(define-inline (dbr:dbstruct-set-locdbs! vec val)(vector-set! vec 11 val))
+
+;; constructor for dbstruct
+;;
+(define (make-dbr:dbstruct #!key (path #f)(local #f))
+ (let ((v (make-vector 12 #f)))
+ (dbr:dbstruct-set-path! v path)
+ (dbr:dbstruct-set-local! v local)
+ (dbr:dbstruct-set-locdbs! v (make-hash-table))
+ v))
+
+(define (dbr:dbstruct-get-localdb v run-id)
+ (hash-table-ref/default (dbr:dbstruct-get-locdbs v) run-id #f))
+
+(define (dbr:dbstruct-set-localdb! v run-id db)
+ (hash-table-set! (dbr:dbstruct-get-locdbs v) run-id db))
+
+;; ;; get and set main db
+;; (define-inline (dbr:dbstruct-get-main vec) (vector-ref vec 0))
+;; (define-inline (dbr:dbstruct-set-main! vec db)(vector-set! vec 0 db))
+;; ;; get the runs hash
+;; (define-inline (dbr:dbstruct-get-dbhash vec) (vector-ref vec 1))
+;; ;; the string db
+;; (define-inline (dbr:dbstruct-get-strdb vec) (vector-ref vec 2))
+;; (define-inline (dbr:dbstruct-set-strdb! vec db)(vector-set! vec 2 db))
+;; ;; path
+;; (define-inline (dbr:dbstruct-get-path vec) (vector-ref vec 3))
+;; (define-inline (dbr:dbstruct-set-path! vec path)(vector-set! vec 3))
+;; ;; local
+;; (define-inline (dbr:dbstruct-get-local vec) (vector-ref vec 4))
+;; (define-inline (dbr:dbstruct-set-local! vec val)(vector-set! vec 4 val))
+;;
+;; ;; get a rundb vector, create it if not already existing
+;; (define (dbr:dbstruct-get-rundb-rec vec run-id)
+;; (let* ((dbhash (dbr:dbstruct-get-dbhash vec)) ;; get the runs hash
+;; (runvec (hash-table-ref/default dbhash run-id #f))) ;; get the vector for run-id
+;; (if (vector? runvec)
+;; runvec ;; rundb inmemdb last-mod last-read last-sync in-use refdb
+;; (let ((nvec (vector #f #f -1 -1 -1 #f #f)))
+;; (hash-table-set! dbhash run-id nvec)
+;; nvec))))
+;;
+;; ;; [ rundb inmemdb last-mod last-read last-sync ]
+;; (define-inline (dbr:dbstruct-field-name->num field-name)
+;; (case field-name
+;; ((rundb) 0) ;; the on-disk db
+;; ((inmem) 1) ;; the in-memory db
+;; ((mtime) 2) ;; last modification time
+;; ((rtime) 3) ;; last read time
+;; ((stime) 4) ;; last sync time
+;; ((inuse) 5) ;; is the db currently in use, #t yes, #f no.
+;; ((refdb) 6) ;; the db used for reference (can be on disk or inmem)
+;; (else -1)))
+;;
+;; ;; get/set rundb fields
+;; (define (dbr:dbstruct-get-runvec-val vec run-id field-name)
+;; (let ((runvec (dbr:dbstruct-get-rundb-rec vec run-id))
+;; (fieldnum (dbr:dbstruct-field-name->num field-name)))
+;; ;; (vector-set! runvec (dbr:dbstruct-field-name->num 'inuse) #t)
+;; (vector-ref runvec fieldnum)))
+;;
+;; (define (dbr:dbstruct-set-runvec-val! vec run-id field-name val)
+;; (let ((runvec (dbr:dbstruct-get-rundb-rec vec run-id)))
+;; (vector-set! runvec (dbr:dbstruct-field-name->num field-name) val)))
+;;
+;; ;; get/set inmemdb
+;; (define (dbr:dbstruct-get-inmemdb vec run-id)
+;; (let ((runvec (dbr:dbstruct-get-rundb-rec vec run-id)))
+;; (vector-ref runvec 1)))
+;;
+;; (define (dbr:dbstruct-set-inmemdb! vec run-id inmemdb)
+;; (let ((runvec (dbr:dbstruct-get-rundb-rec vec run-id)))
+;; (vector-set! runvec 1 inmemdb)))
(define (make-db:test)(make-vector 20))
(define-inline (db:test-get-id vec) (vector-ref vec 0))
(define-inline (db:test-get-run_id vec) (vector-ref vec 1))
@@ -109,14 +145,10 @@
(define-inline (db:test-set-state! vec val)(vector-set! vec 3 val))
(define-inline (db:test-set-status! vec val)(vector-set! vec 4 val))
(define-inline (db:test-set-run_duration! vec val)(vector-set! vec 12 val))
(define-inline (db:test-set-final_logf! vec val)(vector-set! vec 13 val))
-;; get rows and header from
-(define-inline (db:get-header vec)(vector-ref vec 0))
-(define-inline (db:get-rows vec)(vector-ref vec 1))
-
;; make-vector-record "" db mintest id run_id testname state status event_time item_path
;;
(define (make-db:mintest)(make-vector 7))
(define-inline (db:mintest-get-id vec) (vector-ref vec 0))
(define-inline (db:mintest-get-run_id vec) (vector-ref vec 1))
@@ -209,13 +241,10 @@
(define-inline (tdb:step-stable-set-start! vec val)(vector-set! vec 1 val))
(define-inline (tdb:step-stable-set-end! vec val)(vector-set! vec 2 val))
(define-inline (tdb:step-stable-set-status! vec val)(vector-set! vec 3 val))
(define-inline (tdb:step-stable-set-runtime! vec val)(vector-set! vec 4 val))
-;; use this one for db-get-run-info
-(define-inline (db:get-row vec)(vector-ref vec 1))
-
;; The data structure for handing off requests via wire
(define (make-cdb:packet)(make-vector 6))
(define-inline (cdb:packet-get-client-sig vec) (vector-ref vec 0))
(define-inline (cdb:packet-get-qtype vec) (vector-ref vec 1))
(define-inline (cdb:packet-get-immediate vec) (vector-ref vec 2))
Index: docs/html/megatest.html
==================================================================
--- docs/html/megatest.html
+++ docs/html/megatest.html
@@ -2,11 +2,11 @@
-
+
Megatest User Manual
@@ -782,11 +782,11 @@
Note: The monitor is usable but incomplete as of Megatest v1.31. Click on the “Monitor” button on the dashboard to start the monitor and give it a try.