Megatest

Diff
Login

Differences From Artifact [3d8dfdd127]:

To Artifact [24de2d2df6]:


44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64




65
66
67
68
69
70
71
72

73
74
75
76
77
78
79
80
81
82
83
84

85
86
87
88
89
90
91
    ;; update runs       id              => runrec
    ;; update targ-runid target/runname  => run-id
    (for-each
     (lambda (runrec)
       (let* ((run-id (simple-run-id runrec))
	      (full-targ-runname (conc (simple-run-target runrec) "/"
				       (simple-run-runname runrec))))
	 (debug:print 0 *default-log-port* "Update run  " run-id)
	 (sparse-vector-set! (dboard:rdat-runs rdat) run-id runrec)
	 (hash-table-set! (dboard:rdat-targ-runid rdat) full-targ-runname run-id)
	 (tree:add-node tb "Runs" (string-split full-targ-runname "/"))
	 ))
     data)
    numruns))

;;======================================================================
;; The "new" runs browser, this one sets up the view and registers the
;; updater
;;
(define (dashboard:runs-browse commondat tabdat #!key (tab-num 5))
  (let* ((rdat (make-dboard:rdat)))




    (dboard:commondat-add-updater
     commondat
     (lambda ()
       (dashboard:new-runs-updater commondat tabdat rdat))
     tab-num: tab-num)
    (iup:split
     #:orientation "VERTICAL"
     #:value 10

     (iup:vbox
      (dboard:runs-tree-new-view-browser commondat rdat))
     (iup:split
      #:orientation "VERTICAL"
      #:value 10
      (iup:vbox
       (dboard:runs-new-matrix commondat rdat))
      (iup:hbox
       (iup:split
	#:orientation "VERTICAL"
	#:value 10
	(dboard:runs-new-matrix commondat rdat)

	(dboard:test-info-matrix commondat rdat)
	))))))

(define (dashboard:new-runs-updater commondat tabdat rdat)
  (let* ((runnum           (dboard:rdat-runnum          rdat))
	 (start-time       (current-milliseconds))
	 (tot-runs         #f))







|












|
>
>
>
>







|
>




|
|
<
|


|
<
>







44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83

84
85
86
87

88
89
90
91
92
93
94
95
    ;; update runs       id              => runrec
    ;; update targ-runid target/runname  => run-id
    (for-each
     (lambda (runrec)
       (let* ((run-id (simple-run-id runrec))
	      (full-targ-runname (conc (simple-run-target runrec) "/"
				       (simple-run-runname runrec))))
	 ;; (debug:print 0 *default-log-port* "Update run  " run-id)
	 (sparse-vector-set! (dboard:rdat-runs rdat) run-id runrec)
	 (hash-table-set! (dboard:rdat-targ-runid rdat) full-targ-runname run-id)
	 (tree:add-node tb "Runs" (string-split full-targ-runname "/"))
	 ))
     data)
    numruns))

;;======================================================================
;; The "new" runs browser, this one sets up the view and registers the
;; updater
;;
(define (dashboard:runs-browse commondat tabdat #!key (tab-num 5))
  (let* ((rdat     (make-dboard:rdat))
	 (runsmtx  (dboard:runs-new-matrix commondat rdat))
	 (itemsmtx (dboard:runs-new-matrix commondat rdat)))
    (dboard:rdat-runs-mtx-set! rdat runsmtx)
    (dboard:rdat-items-mtx-set! rdat itemsmtx)
    (dboard:commondat-add-updater
     commondat
     (lambda ()
       (dashboard:new-runs-updater commondat tabdat rdat))
     tab-num: tab-num)
    (iup:split
     #:orientation "VERTICAL"
     #:value 100
     #:shrink "YES"
     (iup:vbox
      (dboard:runs-tree-new-view-browser commondat rdat))
     (iup:split
      #:orientation "VERTICAL"
      #:value 100
      (iup:vbox runsmtx)

      (iup:vbox
       (iup:split
	#:orientation "VERTICAL"
	#:value 500

	itemsmtx
	(dboard:test-info-matrix commondat rdat)
	))))))

(define (dashboard:new-runs-updater commondat tabdat rdat)
  (let* ((runnum           (dboard:rdat-runnum          rdat))
	 (start-time       (current-milliseconds))
	 (tot-runs         #f))
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141

142





143
144

145
146





































































147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
	    (dboard:rdat-runnum-set! rdat newrn)
	    (if (> newrn 0)
		(loop newrn)))))
    (if (>=  (dboard:rdat-runnum rdat) tot-runs)
	(dboard:rdat-runnum-set! rdat 0))
    ;; (dboard:rdat-runnum-set! rdat rn))) ;; not needed as it is set above
    ;; (dboard:rdat-last-update-set! rdat (- (current-seconds) 10))
    '()))

#;(define (make-runs-view commondat rdat tab-num)
  ;; register an updater
  (dboard:commondat-add-updater
   commondat
   (lambda ()
     (new-runs-updater commondat rdat))
   tab-num: tab-num)

  (iup:vbox
   (iup:split
    #:orientation "VERTICAL" ;; "HORIZONTAL"
    #:value 100
    (dboard:runs-tree-new-browser commondat rdat)
    (dboard:runs-new-matrix commondat rdat)
    )))

;; NOTE: runnum is NOT the run-id, it is a pointer into the runsbynum vector
;;
(define (dashboard:update-run-data runnum rdat)
  (let* ((curr-time            (current-seconds))
	 (runrec               (vector-ref (dboard:rdat-runsbynum rdat) runnum))
	 (run-id               (simple-run-id runrec))
	 (last-update          (sparse-vector-ref (dboard:rdat-last-updates rdat) run-id))
	 ;; filters
	 (testname-sql-filt    (dboard:rdat-testname-sql-filt    rdat))
	 ;; (itempath-sql-filt    (dboard:rdat-itempath-sql-filt    rdat))
	 (test-state-sql-filt  (dboard:rdat-test-state-sql-filt  rdat))  ;; not used yet
	 (test-status-sql-filt (dboard:rdat-test-status-sql-filt rdat))  ;; not used yet
	 (tests                (rmt:get-tests-for-run-state-status run-id
						      testname-sql-filt
						      last-update                ;; last-update
						      )))

    (sparse-vector-set! (dboard:rdat-last-updates rdat) run-id (- curr-time 1))





    (debug:print 0 *default-log-port* "Got " (length tests) " tests for run-id "
		 run-id " testname-sql-filt " testname-sql-filt " and last-update " last-update) 

    (length tests)))






































































(define (dboard:runs-new-matrix commondat rdat)
  (iup:matrix
   #:alignment1 "ALEFT"
   ;; #:expand "YES" ;; "HORIZONTAL"
   #:scrollbar "YES"
   #:numcol 100
   #:numlin 200
   #:numcol-visible 3 ;; (min 8)
   #:numlin-visible 1
   #:widthdef 20
   #:click-cb
   (lambda (obj row col status)
     (let* ((cell (conc row ":" col)))
       #f))
   ))








<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|

















>

>
>
>
>
>
|
|
>


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



|




|







105
106
107
108
109
110
111















112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
	    (dboard:rdat-runnum-set! rdat newrn)
	    (if (> newrn 0)
		(loop newrn)))))
    (if (>=  (dboard:rdat-runnum rdat) tot-runs)
	(dboard:rdat-runnum-set! rdat 0))
    ;; (dboard:rdat-runnum-set! rdat rn))) ;; not needed as it is set above
    ;; (dboard:rdat-last-update-set! rdat (- (current-seconds) 10))















    (dashboard:update-new-runs-view-runs-matrix commondat rdat)
    '()))

;; NOTE: runnum is NOT the run-id, it is a pointer into the runsbynum vector
;;
(define (dashboard:update-run-data runnum rdat)
  (let* ((curr-time            (current-seconds))
	 (runrec               (vector-ref (dboard:rdat-runsbynum rdat) runnum))
	 (run-id               (simple-run-id runrec))
	 (last-update          (sparse-vector-ref (dboard:rdat-last-updates rdat) run-id))
	 ;; filters
	 (testname-sql-filt    (dboard:rdat-testname-sql-filt    rdat))
	 ;; (itempath-sql-filt    (dboard:rdat-itempath-sql-filt    rdat))
	 (test-state-sql-filt  (dboard:rdat-test-state-sql-filt  rdat))  ;; not used yet
	 (test-status-sql-filt (dboard:rdat-test-status-sql-filt rdat))  ;; not used yet
	 (tests                (rmt:get-tests-for-run-state-status run-id
						      testname-sql-filt
						      last-update                ;; last-update
						      )))
    ;; (debug:print 0 *default-log-port* "tests: " tests)
    (sparse-vector-set! (dboard:rdat-last-updates rdat) run-id (- curr-time 1))
    (sparse-vector-set! (dboard:rdat-run-tests rdat) run-id
			(delete-duplicates
			 (append tests (sparse-vector-ref (dboard:rdat-run-tests rdat) run-id))
			 (lambda (a b)
			   (eq? (vector-ref a 0)(vector-ref b 0))))) ;; de-duplicate based on test id
    #;(debug:print 0 *default-log-port* "Got " (length tests) " tests for run-id "
		 run-id " testname-sql-filt " testname-sql-filt " and last-update " last-update
		 " first test info: " tests) ;; (if (not (null? tests))(car tests) '()))
    (length tests)))

;; NB// start at 1.
;;
(define (dashboard:get-row-num mtrx rownames tname)
  (or (hash-table-ref/default rownames tname #f)
      (let* ((numentries (hash-table-size rownames))
	     (nextnum    (+ numentries 1)))
	(hash-table-set! rownames tname nextnum)
	(iup:attribute-set! mtrx (conc nextnum ":0") tname)
	nextnum)))

(define (dashboard:update-new-runs-view-runs-matrix commondat rdat)
  (let* ((run-tests-data (dboard:rdat-run-tests rdat)) ;; from dbmod.scm (define-record simple-run target id runname state status owner event_time)
	 (run-tests-mtx  (dboard:rdat-runs-mtx  rdat))
	 (runs-by-num    (dboard:rdat-runsbynum rdat)) ;; this is the sequence num
	 (num-runs       (vector-length runs-by-num))
	 )
    (debug:print 0 *default-log-port* "num-runs: " num-runs)
    (let loop ((col-num 1))
      (let* ((runrec    (vector-ref runs-by-num (- col-num 1)))
	     (run-id    (simple-run-id runrec))
	     (target    (simple-run-target runrec))
	     (runname   (simple-run-runname runrec))
	     (vert-targ (string-translate (conc target "/" runname) "/" "\n"))
	     (run-tests (sparse-vector-ref run-tests-data run-id))
	     (changed   #f))  ;; manage redraws on a column by column basis
	(debug:print 0 *default-log-port* "run-tests: " run-tests)
	(if (null? run-tests) ;; empty run
	    (if (< col-num num-runs) ;; NOT CORRECT
		(loop (+ col-num)))
	    (begin
	      (set! changed (dcommon:modifiy-if-different ;; set the col header
			     run-tests-mtx
			     (conc "0:" col-num)
			     vert-targ
			     changed))
	      (let testloop ((inum    0)
			     (tail    run-tests))
		(let* ((test-dat   (car tail))
		       (tname      (db:test-get-testname test-dat))
		       (state      (db:test-get-state    test-dat))
		       (status     (db:test-get-status   test-dat))
		       (item-path  (db:test-get-item-path test-dat))
		       (color      (gutils:get-color-for-state-status state status))
		       (is-deleted (equal? state "DELETED"))
		       (row-num    (if is-deleted
				       #f
				       (dashboard:get-row-num run-tests-mtx
							      (dboard:rdat-rownames rdat) tname)))
		       (cell-name (conc row-num ":" col-num)))
		  (if (or (not is-deleted)
			  (equal? item-path ""))
		      (begin
 			(set! changed (dcommon:modifiy-if-different 
 				       run-tests-mtx
 				       (conc "BGCOLOR" row-num ":" col-num)
 				       (car color)
 				       changed))
			(set! changed (dcommon:modifiy-if-different 
 				       run-tests-mtx
 				       cell-name
 				       (cadr color)
 				       changed))))
		  (if (not (null? (cdr tail)))
		      (testloop (+ inum 1)(cdr tail))
		      (begin
			(iup:attribute-set! run-tests-mtx (conc "C" col-num) "REDRAW")
			(if (< col-num num-runs)
			    (loop (+ col-num 1)))))))))))))

(define (dboard:runs-new-matrix commondat rdat)
  (iup:matrix
   #:alignment1 "ALEFT"
   #:expand "YES" ;; "HORIZONTAL"
   #:scrollbar "YES"
   #:numcol 100
   #:numlin 200
   #:numcol-visible 3 ;; (min 8)
   #:numlin-visible 10
   #:widthdef 20
   #:click-cb
   (lambda (obj row col status)
     (let* ((cell (conc row ":" col)))
       #f))
   ))

182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206

207
208
209
210
211
212
213
214
215
216
217
218
219
220
221



222

223
224
225
226

227
228
229
230
231
232
233
	  '(("Test Meta Data" . 1)
	    ("Author"    . 2)
	    ("Owner"     . 3)
	    ("Reviewed"  . 4)
	    ("Tags"      . 5)
	    ("Description" . 6)))
	 (remhost-run-info-fields
	  '(("Remote host/Run info" . 1)
	    ("Hostname"  . 2)
	    ("Disk free" . 3)
	    ("CPU Load"  . 4)
	    ("Run duration" . 5)
	    ("Logfile"   . 6)
	    ("Process ID" . 7)
	    ("Machine info" . 8)))
	 (mk-matrix (lambda (cfgdat)
		      (let ((mtx (iup:matrix
				  #:alignment1 "ALEFT"
				  ;; #:expand "YES" ;; "HORIZONTAL"
				  #:scrollbar "YES"
				  #:numcol 1
				  #:numlin (length cfgdat)
				  #:numcol-visible 1 ;; (min 8)
				  #:numlin-visible 1
				  #:widthdef 50

				  #:click-cb
				  (lambda (obj row col status)
				    (let* ((cell (conc row ":" col)))
				      #f)))))
			(for-each (lambda (finfo)
				    (match finfo
				      ((fieldname . rownum)
				       (iup:attribute-set! mtx (conc rownum":0") fieldname))
				      (else (debug:print 0 *default-log-port* "ERROR: bad finfo "finfo))))
				  cfgdat)
			mtx)))
	 (runmtx  (mk-matrix run-fields))
	 (testmtx (mk-matrix test-fields))
	 (metamtx (mk-matrix test-meta-fields))
	 (remhostmtx (mk-matrix remhost-run-info-fields)))



    (iup:vbox

     (iup:hbox
      runmtx testmtx)
     (iup:hbox
      metamtx remhostmtx))))


;; browse runs as a tree. Used in both "Runs" tab and
;; in the runs control panel.
;;
;;  THIS IS THE NEW ONE
;;
(define (dboard:runs-tree-new-view-browser commondat rdat)







|















|

>















>
>
>

>
|
|
<
|
>







247
248
249
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
	  '(("Test Meta Data" . 1)
	    ("Author"    . 2)
	    ("Owner"     . 3)
	    ("Reviewed"  . 4)
	    ("Tags"      . 5)
	    ("Description" . 6)))
	 (remhost-run-info-fields
	  '(("Host/run info" . 1)
	    ("Hostname"  . 2)
	    ("Disk free" . 3)
	    ("CPU Load"  . 4)
	    ("Run duration" . 5)
	    ("Logfile"   . 6)
	    ("Process ID" . 7)
	    ("Machine info" . 8)))
	 (mk-matrix (lambda (cfgdat)
		      (let ((mtx (iup:matrix
				  #:alignment1 "ALEFT"
				  ;; #:expand "YES" ;; "HORIZONTAL"
				  #:scrollbar "YES"
				  #:numcol 1
				  #:numlin (length cfgdat)
				  #:numcol-visible 1 ;; (min 8)
				  #:numlin-visible (length cfgdat)
				  #:widthdef 50
				  #:width0 50
				  #:click-cb
				  (lambda (obj row col status)
				    (let* ((cell (conc row ":" col)))
				      #f)))))
			(for-each (lambda (finfo)
				    (match finfo
				      ((fieldname . rownum)
				       (iup:attribute-set! mtx (conc rownum":0") fieldname))
				      (else (debug:print 0 *default-log-port* "ERROR: bad finfo "finfo))))
				  cfgdat)
			mtx)))
	 (runmtx  (mk-matrix run-fields))
	 (testmtx (mk-matrix test-fields))
	 (metamtx (mk-matrix test-meta-fields))
	 (remhostmtx (mk-matrix remhost-run-info-fields)))
    ;; (dboard:rdat-runs-mtx-set! rdat runmtx)
    ;; (dboard:rdat-items-mtx-set! rdat testmtx)
    ;; (
    (iup:vbox
     #:expandchildren #t
     #:expand #f
     runmtx testmtx

     metamtx remhostmtx
     )))

;; browse runs as a tree. Used in both "Runs" tab and
;; in the runs control panel.
;;
;;  THIS IS THE NEW ONE
;;
(define (dboard:runs-tree-new-view-browser commondat rdat)
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
				(if b (dboard:rdat-targ-sql-filt-set! rdat
								 (string-split b "/")))
				#;(dashboard:update-run-command tabdat))
			      "command-testname-selector tb action"))
		  ;; #:value (dboard:test-patt->lines  ;; This seems like it was wrong, BUG in code where it was copied from?
	          ;;		   (dboard:tabdat-test-patts-use tabdat))
		  #:expand "HORIZONTAL"
		  ;; #:size "10x30"
		  ))
	 (tb
          (iup:treebox
           #:value 0
           #:title "Runs"     ;;  was #:name -- iup 3.19 changed
			      ;;  this... "Changed: [DEPRECATED
			      ;;  REMOVED] removed the old attribute
			      ;;  NAMEid from IupTree to avoid
			      ;;  conflict with the common attribute
			      ;;  NAME. Use the TITLEid attribute."
           #:expand "YES"
           #:addexpanded "YES"
           #:size "10x"
           #:selection-cb
           (lambda (obj id state)
             (debug:catch-and-dump
              (lambda ()
                (let* ((run-path (tree:node->path obj id))
                       (run-id    (new-tree-path->run-id rdat (cdr run-path))))
                  ;; (dboard:tabdat-view-changed-set! tabdat #t) ;; ??







|












|







312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
				(if b (dboard:rdat-targ-sql-filt-set! rdat
								 (string-split b "/")))
				#;(dashboard:update-run-command tabdat))
			      "command-testname-selector tb action"))
		  ;; #:value (dboard:test-patt->lines  ;; This seems like it was wrong, BUG in code where it was copied from?
	          ;;		   (dboard:tabdat-test-patts-use tabdat))
		  #:expand "HORIZONTAL"
		  ;; #:size "10x"
		  ))
	 (tb
          (iup:treebox
           #:value 0
           #:title "Runs"     ;;  was #:name -- iup 3.19 changed
			      ;;  this... "Changed: [DEPRECATED
			      ;;  REMOVED] removed the old attribute
			      ;;  NAMEid from IupTree to avoid
			      ;;  conflict with the common attribute
			      ;;  NAME. Use the TITLEid attribute."
           #:expand "YES"
           #:addexpanded "YES"
           #:size "120x"
           #:selection-cb
           (lambda (obj id state)
             (debug:catch-and-dump
              (lambda ()
                (let* ((run-path (tree:node->path obj id))
                       (run-id    (new-tree-path->run-id rdat (cdr run-path))))
                  ;; (dboard:tabdat-view-changed-set! tabdat #t) ;; ??