Megatest

Check-in [9d422f5846]
Login
Overview
Comment:more done
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v1.60
Files: files | file ages | folders
SHA1: 9d422f58462a49653a4fd22f88babea5d64dacdd
User & Date: matt on 2015-06-22 21:42:12
Other Links: branch diff | manifest | tags
Context
2015-06-22
23:12
tidied up schema/db check-in: 46f8753ee7 user: matt tags: v1.60
21:42
more done check-in: 9d422f5846 user: matt tags: v1.60
18:52
Added nanomsg server to mdboard check-in: 8291808639 user: matt tags: v1.60
Changes

Modified multi-dboard.scm from [63551672c3] to [3e59d034b9].

182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
  testpatt  ;; the testpatt widget
  )

;;======================================================================
;; D B
;;======================================================================

;; These are all using sqlite and independent of area so cannot use stuff 
;; from db.scm

;; NB// run-id=#f => return dbdir only
;;
(define (areadb:dbfile-path areadat run-id)
  (let* ((cfgdat  (areadat-configdat areadat))
	 (dbdir   (or (configf:lookup cfgdat "setup" "dbdir")







|







182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
  testpatt  ;; the testpatt widget
  )

;;======================================================================
;; D B
;;======================================================================

;; These are all using sql-de-lite and independent of area so cannot use stuff 
;; from db.scm

;; NB// run-id=#f => return dbdir only
;;
(define (areadb:dbfile-path areadat run-id)
  (let* ((cfgdat  (areadat-configdat areadat))
	 (dbdir   (or (configf:lookup cfgdat "setup" "dbdir")
250
251
252
253
254
255
256
257










































258
259
260
261
262
263
264
			   (let ((id  (list-ref row 0))
				 (dat (apply make-rundat (append row (list #f #f))))) ;; add placeholders for tests and db
			     (hash-table-set! runs id dat)))
			 (sql maindb (conc "SELECT id,"
					   (string-intersperse keys "'||/||'")
					   ",runname,state,status,event_time FROM runs WHERE state != 'DELETED';"))))
    areadat))
					   











































;;======================================================================
;; T R E E 
;;======================================================================

;; <area> - <target - ... > - <runname> - <test> - <itempath - ...>








|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
			   (let ((id  (list-ref row 0))
				 (dat (apply make-rundat (append row (list #f #f))))) ;; add placeholders for tests and db
			     (hash-table-set! runs id dat)))
			 (sql maindb (conc "SELECT id,"
					   (string-intersperse keys "'||/||'")
					   ",runname,state,status,event_time FROM runs WHERE state != 'DELETED';"))))
    areadat))
			
;;======================================================================
;; D A S H B O A R D   D B 
;;======================================================================
		
(define (mddb:open-db)
  (let* ((db (open-database (conc (get-environment-variable "HOME") "/.dashboard.db"))))
    (set-busy-handler! db (busy-timeout 10000))
    (for-each
     (lambda (qry)
       (exec (sql db qry)))
     (list 
      "CREATE TABLE IF NOT EXISTS vars       (id INTEGER PRIMARY KEY,key TEXT, val TEXT, CONSTRAINT varsconstraint UNIQUE (key));"
      "CREATE TABLE IF NOT EXISTS dashboards (
          id   INTEGER PRIMARY KEY,
          pid  INTEGER,
          user TEXT,
          host TEXT,
          port INTEGER,
          start_time TIMESTAMP DEFAULT (strftime('%s','now'))
        );"
      ))
    db))

   
;; register a dashboard 
;;
(define (mddb:register-dashboard port)
  (let* ((pid      (current-process-id))
	 (hostname (get-host-name))
	 (username (current-user-name)) ;; (car userinfo)))
	 (db      (mddb:open-db)))
    (print "Register monitor, pid: " pid ", hostname: " hostname ", port: " port ", username: " username)
    (exec (sql db "INSERT OR REPLACE INTO dashboards (pid,user,host,port) VALUES (?,?,?,?);")
	   pid hostname port username)))

;; unregister a monitor
;;
(define (mddb:unregister-dashboard areadat host port)
  (let* ((db      (mddb:open-db)))
    (print "Register unregister monitor, host:port=" host ":" port)
    (exec (sql db "DELETE FROM monitors WHERE host=? AND port=?;")
	   host port)))

;;======================================================================
;; T R E E 
;;======================================================================

;; <area> - <target - ... > - <runname> - <test> - <itempath - ...>

574
575
576
577
578
579
580


581
582

583
584
;; ease debugging by loading ~/.dashboardrc
(let ((debugcontrolf (conc (get-environment-variable "HOME") "/.dashboardrc")))
  (if (file-exists? debugcontrolf)
      (load debugcontrolf)))

(let-values 
 (((con port)(dboard:server-start #f)))


 (thread-start! (make-thread (lambda ()(dboard:server-service con port)) "server service"))
 (dboard:make-window 0)

 (dboard:server-close con port))








>
>


>


616
617
618
619
620
621
622
623
624
625
626
627
628
629
;; ease debugging by loading ~/.dashboardrc
(let ((debugcontrolf (conc (get-environment-variable "HOME") "/.dashboardrc")))
  (if (file-exists? debugcontrolf)
      (load debugcontrolf)))

(let-values 
 (((con port)(dboard:server-start #f)))
 ;; got here, monitor/dashboard was started
 (mddb:register-dashboard port)
 (thread-start! (make-thread (lambda ()(dboard:server-service con port)) "server service"))
 (dboard:make-window 0)
 (mddb:unregister-dashboard (get-host-name) port)
 (dboard:server-close con port))

Modified tasks.scm from [a2f9968b1b] to [7cea7f81b2].

495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
     (lambda (id pid host last-update delta)
       (print "Going to delete stale record for monitor with pid " pid " on host " host " last updated " delta " seconds ago")
       (set! deadlist (cons id deadlist)))
     mdb 
     "SELECT id,pid,hostname,last_update,strftime('%s','now')-last_update AS delta FROM monitors WHERE delta > 700;")
    (sqlite3:execute mdb (conc "DELETE FROM monitors WHERE id IN ('" (string-intersperse (map conc deadlist) "','") "');")))
  )
(define (tasks:register-monitor db mdb)
  (let* ((pid (current-process-id))
	 (hostname (get-host-name))
	 (userinfo (user-information (current-user-id)))
	 (username (car userinfo)))
    (print "Register monitor, pid: " pid ", hostname: " hostname ", username: " username)
    (sqlite3:execute mdb "INSERT INTO monitors (pid,start_time,last_update,hostname,username) VALUES (?,strftime('%s','now'),strftime('%s','now'),?,?);"
		     pid hostname username)))

(define (tasks:get-num-alive-monitors mdb)
  (let ((res 0))
    (sqlite3:for-each-row 
     (lambda (count)
       (set! res count))







|




|
|







495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
     (lambda (id pid host last-update delta)
       (print "Going to delete stale record for monitor with pid " pid " on host " host " last updated " delta " seconds ago")
       (set! deadlist (cons id deadlist)))
     mdb 
     "SELECT id,pid,hostname,last_update,strftime('%s','now')-last_update AS delta FROM monitors WHERE delta > 700;")
    (sqlite3:execute mdb (conc "DELETE FROM monitors WHERE id IN ('" (string-intersperse (map conc deadlist) "','") "');")))
  )
(define (tasks:register-monitor db port)
  (let* ((pid (current-process-id))
	 (hostname (get-host-name))
	 (userinfo (user-information (current-user-id)))
	 (username (car userinfo)))
    (print "Register monitor, pid: " pid ", hostname: " hostname ", port: " port ", username: " username)
    (sqlite3:execute db "INSERT INTO monitors (pid,start_time,last_update,hostname,username) VALUES (?,strftime('%s','now'),strftime('%s','now'),?,?);"
		     pid hostname username)))

(define (tasks:get-num-alive-monitors mdb)
  (let ((res 0))
    (sqlite3:for-each-row 
     (lambda (count)
       (set! res count))