Megatest

Check-in [30e0b9adfd]
Login
Overview
Comment:Refactored again (broke gui into pieces, IUP seems to be having problems with nested containers
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | refactor-dashboard
Files: files | file ages | folders
SHA1: 30e0b9adfde54604658b87b2c44ad6da620585ae
User & Date: mrwellan on 2011-06-26 14:14:34
Other Links: branch diff | manifest | tags
Context
2011-06-26
14:45
more-refactoring-eh check-in: 0a77e08281 user: mrwellan tags: refactor-dashboard
14:14
Refactored again (broke gui into pieces, IUP seems to be having problems with nested containers check-in: 30e0b9adfd user: mrwellan tags: refactor-dashboard
12:46
Basics for test control panel refactored check-in: ab9ec27636 user: mrwellan tags: refactor-dashboard
Changes

Modified dashboard-tests.scm from [ef1812a26a] to [0efdf685df].

1
2
3
4
5
6
7
8
9
10
































































































































































11
12
13
14
15
16
17
;;======================================================================
;; Copyright 2006-2011, Matthew Welland.
;; 
;;  This program is made available under the GNU GPL version 2.0 or
;;  greater. See the accompanying file COPYING for details.
;; 
;;  This program is distributed WITHOUT ANY WARRANTY; without even the
;;  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
;;  PURPOSE.
;;======================================================================

































































































































































;;======================================================================
;;
;;======================================================================
(define (examine-test db test-id mx1) ;; run-id run-key origtest)
  (let* ((testdat       (db:get-test-data-by-id db test-id))
	 (run-id        (if testdat (db:test-get-run_id testdat) #f))










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







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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
96
97
98
99
100
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
;;======================================================================
;; Copyright 2006-2011, Matthew Welland.
;; 
;;  This program is made available under the GNU GPL version 2.0 or
;;  greater. See the accompanying file COPYING for details.
;; 
;;  This program is distributed WITHOUT ANY WARRANTY; without even the
;;  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
;;  PURPOSE.
;;======================================================================

;;======================================================================
;; Test info panel
;;======================================================================
(define (test-info-panel testdat store-label widgets)
  (iup:frame 
   #:title "Test Info" ; #:expand "YES"
   (iup:hbox ; #:expand "YES"
    (apply iup:vbox ; #:expand "YES"
	   (append (map (lambda (val)
			  (iup:label val ; #:expand "HORIZONTAL"
				     ))
			(list "Testname: "
			      "Item path: "
			      "Current state: "
			      "Current status: "
			      "Test comment: "
			      "Test id: "))
		   (list (iup:label "" #:expand "VERTICAL"))))
    (apply iup:vbox  ; #:expand "YES"
	   (list 
	    (iup:label (db:test-get-testname  testdat) #:expand "HORIZONTAL")
	    (iup:label (db:test-get-item-path testdat) #:expand "HORIZONTAL")
	    (store-label "teststate" 
			 (iup:label (db:test-get-state testdat) #:expand "HORIZONTAL")
			 (lambda (testdat)
			   (db:test-get-state testdat)))
	    (let ((lbl   (iup:label (db:test-get-status testdat) #:expand "HORIZONTAL")))
	      (hash-table-set! widgets "teststatus"
			       (lambda (testdat)
				 (let ((newstatus (db:test-get-status testdat))
				       (oldstatus (iup:attribute lbl "TITLE")))
				   (if (not (equal? oldstatus newstatus))
				       (begin
					 (iup:attribute-set! lbl "FGCOLOR" (get-color-for-state-status (db:test-get-state testdat)
												       (db:test-get-status testdat)))
					 (iup:attribute-set! lbl "TITLE" (db:test-get-status testdat)))))))
	      lbl)
	    (store-label "testcomment"
			 (iup:label "TestComment                             "
				    #:expand "HORIZONTAL")
			 (lambda (testdat)
			   (db:test-get-comment testdat)))
	    (store-label "testid"
			 (iup:label "TestId                             "
				    #:expand "HORIZONTAL")
			 (lambda (testdat)
			   (db:test-get-id testdat))))))))

;;======================================================================
;; Run info panel
;;======================================================================
(define (run-info-panel keydat testdat runname)
  (iup:frame 
   #:title "Megatest Run Info" ; #:expand "YES"
   (iup:hbox ; #:expand "YES"
    (apply iup:vbox ; #:expand "YES"
	   (append (map (lambda (keyval)
			  (iup:label (conc (car keyval) " ") ; #:expand "HORIZONTAL"
				     ))
			keydat)
		   (list (iup:label "runname "))))
    (apply iup:vbox
	   (append (map (lambda (keyval)
			  (iup:label (cadr keyval) #:expand "HORIZONTAL"))
			keydat)
		   (list (iup:label runname)(iup:label "" #:expand "VERTICAL")))))))
  
;;======================================================================
;; Host info panel
;;======================================================================
(define (host-info-panel testdat store-label)
  (iup:frame
   #:title "Remote host and Test Run Info" ; #:expand "YES"
   (iup:hbox ; #:expand "YES"
    (apply iup:vbox ; #:expand "YES" ;; The heading labels
	   (append (map (lambda (val)
			  (iup:label val ; #:expand "HORIZONTAL"
				     ))
			(list "Hostname: "
			      "Uname -a: "
			      "Disk free: "
			      "CPU Load: "
			      "Run duration: "
			      "Logfile: "))
		   (iup:label "" #:expand "VERTICAL")))
    (apply iup:vbox ; #:expand "YES"
	   (list
	    ;; NOTE: Yes, the host can change!
	    (store-label "HostName"
			 (iup:label (db:test-get-host testdat) #:expand "HORIZONTAL")
			 (lambda (testdat)(db:test-get-host testdat)))
	    (store-label "Uname"
			 (iup:label "                                                   " #:expand "HORIZONTAL")
			 (lambda (testdat)(db:test-get-uname testdat)))
	    (store-label "DiskFree"
			 (iup:label (conc (db:test-get-diskfree testdat)) #:expand "HORIZONTAL")
			 (lambda (testdat)(conc (db:test-get-diskfree testdat))))
	    (store-label "CPULoad"
			 (iup:label (conc (db:test-get-cpuload testdat)) #:expand "HORIZONTAL")
			 (lambda (testdat)(conc (db:test-get-cpuload testdat))))
	    (store-label "RunDuration"
			 (iup:label (conc (db:test-get-run_duration testdat)) #:expand "HORIZONTAL")
			 (lambda (testdat)(conc (db:test-get-run_duration testdat))))
	    (store-label "CPULoad"
			 (iup:label (conc (db:test-get-final_logf testdat)) #:expand "HORIZONTAL")
			 (lambda (testdat)(conc (db:test-get-final_logf testdat)))))))))

;;======================================================================
;; Set fields 
;;======================================================================
(define (set-fields-panel test-id testdat)
  (let ((newcomment #f)
	(newstatus  #f)
	(newstate   #f))
    (iup:frame
     #:title "Set fields"
     (iup:vbox
      (iup:hbox (iup:label "Comment:")
		(iup:textbox #:action (lambda (val a b)
					(set! newcomment b))
			     #:value (db:test-get-comment testdat)
			     #:expand "YES"))
      (iup:hbox
       (iup:label "STATE:")
       (let ((lb (iup:listbox #:action (lambda (val a b c)
					 (set! newstate a))
			      #:dropdown "YES"
			      )))
	 (iuplistbox-fill-list lb
			       (list "Set state" "COMPLETED" "NOT_STARTED" "RUNNING" "REMOTEHOSTSTART" "KILLED" "KILLREQ")
			       "Set state" )
	 lb))
      (iup:hbox 
       (iup:label "STATUS:")
       (let ((lb (iup:listbox #:action (lambda (val a b c)
					 (set! newstatus a))
			      #:dropdown "YES"
			      )))
	 (iuplistbox-fill-list lb
			       (list "Set status" "PASS" "WARN" "FAIL" "CHECK" "n/a")
			       "Set status" )
	 lb))
      ;; The control buttons
      (iup:vbox
       (iup:button "Apply"
		   #:expand "YES"
		   #:action (lambda (x)
			      (db:test-set-state-status-by-id *db* test-id newstate newstatus newcomment)
			      ))
       (iup:hbox
	(iup:vbox
	 (iup:button "Apply and close"
		     #:action (lambda (x)
				(db:test-set-state-status-by-id *db* test-id newstate newstatus newcomment)
				(exit))))
	(iup:vbox
	 (iup:button "Cancel and close"
		     #:action (lambda (x)
				(exit))))))))))

;;======================================================================
;;
;;======================================================================
(define (examine-test db test-id mx1) ;; run-id run-key origtest)
  (let* ((testdat       (db:get-test-data-by-id db test-id))
	 (run-id        (if testdat (db:test-get-run_id testdat) #f))
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
96
97
98
99
100
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
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
			     (begin
			       (sqlite3:finalize! db)
			       (exit 0))))))
	 (widgets      (make-hash-table))
	 (self         #f)
	 (store-label  (lambda (name lbl cmd)
			 (hash-table-set! widgets name 
					  (lambda ()
					    (let ((newval (cmd))
						  (oldval (iup:attribute lbl "TITLE")))
					      (if (not (equal? newval oldval))
						  (begin
						    (mutex-lock! mx1)
						    (iup:attribute-set! lbl "TITLE" (cmd))
						    (mutex-unlock! mx1))))))
			 lbl))
	 (store-button store-label)
	 ;; Place for new values from the gui
	 (newstatus     #f)
	 (newstate      #f)
	 (newcomment    #f)
	 
	 )
    (cond
     ((not testdat)(begin (print "ERROR: bad test info for " test-id)(exit 1)))
     ((not rundat)(begin (print "ERROR: found test info but there is a problem with the run info for " run-id)(exit 1)))
     (else
      ;;  (test-set-status! db run-id test-name state status itemdat)
      (set! self ; 
	    (iup:dialog #:close_cb (lambda (a)(exit)) ; #:expand "YES"
	     #:title testfullname
	     (iup:hbox ; #:expand "YES" ;; Need a full height box for all the test steps
	      (iup:vbox ; #:expand "YES"
               ;; The run and test info
	       (iup:hbox  ; #:expand "YES"
		(iup:frame #:title "Megatest Run Info" ; #:expand "YES"
			   (iup:hbox ; #:expand "YES"
			    (apply iup:vbox ; #:expand "YES"
				   (append (map (lambda (keyval)
						  (iup:label (conc (car keyval) " ") ; #:expand "HORIZONTAL"
							     ))
						keydat)
					   (list (iup:label "runname "))))
			    (apply iup:vbox
				   (append (map (lambda (keyval)
						  (iup:label (cadr keyval) #:expand "HORIZONTAL"))
						keydat)
					   (list (iup:label runname)(iup:label "" #:expand "VERTICAL"))))))
		(iup:frame #:title "Test Info" ; #:expand "YES"
			   (iup:hbox ; #:expand "YES"
			    (apply iup:vbox ; #:expand "YES"
				   (append (map (lambda (val)
						  (iup:label val ; #:expand "HORIZONTAL"
							     ))
						(list "Testname: "
						      "Item path: "
						      "Current state: "
						      "Current status: "
						      "Test comment: "
						      "Test id: "))
					   (list (iup:label "" #:expand "VERTICAL"))))
			    (apply iup:vbox  ; #:expand "YES"
				   (list 
				    (iup:label (db:test-get-testname  testdat) #:expand "HORIZONTAL")
				    (iup:label (db:test-get-item-path testdat) #:expand "HORIZONTAL")
				    (store-label "teststate" 
						 (iup:label (db:test-get-state testdat) #:expand "HORIZONTAL")
						 (lambda ()
						   (db:test-get-state testdat)))
				    (let ((lbl   (iup:label (db:test-get-status testdat) #:expand "HORIZONTAL")))
				      (hash-table-set! widgets "teststatus"
						       (lambda ()
							 (let ((newstatus (db:test-get-status testdat))
							       (oldstatus (iup:attribute lbl "TITLE")))
							   (if (not (equal? oldstatus newstatus))
							       (begin
								 (iup:attribute-set! lbl "FGCOLOR" (get-color-for-state-status (db:test-get-state testdat)
															       (db:test-get-status testdat)))
								 (iup:attribute-set! lbl "TITLE" (db:test-get-status testdat)))))))
				      lbl)
				    (store-label "testcomment"
						 (iup:label "TestComment                             "
							    #:expand "HORIZONTAL")
						 (lambda ()
						   (db:test-get-comment testdat)))
				    (store-label "testid"
						 (iup:label "TestId                             "
							    #:expand "HORIZONTAL")
						 (lambda ()
						   (db:test-get-id testdat))))))))
	       ;; The run host info
	       (iup:frame #:title "Remote host and Test Run Info" ; #:expand "YES"
	        (iup:hbox ; #:expand "YES"
                 (apply iup:vbox ; #:expand "YES" ;; The heading labels
			(append (map (lambda (val)
				       (iup:label val ; #:expand "HORIZONTAL"
						  ))
				     (list "Hostname: "
					   "Uname -a: "
					   "Disk free: "
					   "CPU Load: "
					   "Run duration: "
					   "Logfile: "))
				(iup:label "" #:expand "VERTICAL")))
		 (apply iup:vbox ; #:expand "YES"
			(list
			 ;; NOTE: Yes, the host can change!
			 (store-label "HostName"
				      (iup:label (db:test-get-host testdat) #:expand "HORIZONTAL")
				      (lambda ()(db:test-get-host testdat)))
			 (store-label "Uname"
				      (iup:label "                                                   " #:expand "HORIZONTAL")
				      (lambda ()(db:test-get-uname testdat)))
			 (store-label "DiskFree"
				      (iup:label (conc (db:test-get-diskfree testdat)) #:expand "HORIZONTAL")
				      (lambda ()(conc (db:test-get-diskfree testdat))))
			 (store-label "CPULoad"
				      (iup:label (conc (db:test-get-cpuload testdat)) #:expand "HORIZONTAL")
				      (lambda ()(conc (db:test-get-cpuload testdat))))
			 (store-label "RunDuration"
				      (iup:label (conc (db:test-get-run_duration testdat)) #:expand "HORIZONTAL")
				      (lambda ()(conc (db:test-get-run_duration testdat))))
			 (store-label "CPULoad"
				      (iup:label (conc (db:test-get-final_logf testdat)) #:expand "HORIZONTAL")
				      (lambda ()(conc (db:test-get-final_logf testdat))))))))
	       ;; The controls
	       (iup:frame #:title "Actions" ; #:expand "HORIZONTAL"
			  (iup:hbox ; #:expand "HORIZONTAL" ;; the actions box
			   (iup:button "View Log"    #:action viewlog #:expand "YES"
				       )
			   (iup:button "Start Xterm" #:action xterm  #:expand "YES")))
	       (iup:frame #:title "Set fields"
			  (iup:vbox
			   ;(iup:hbox ; #:expand "HORIZONTAL"
			   (iup:hbox (iup:label "Comment:")
				     (iup:textbox #:action (lambda (val a b)
							     (set! newcomment b))
						  #:value (db:test-get-comment testdat)
						  #:expand "YES"
						  ))
			   (iup:hbox 
			    (iup:vbox ; for the state and status controls
			     (iup:hbox ; #:expand "HORIZONTAL" ;; the state
			      (iup:label "STATE:" ; #:size "30x" ; #:expand "HORIZONTAL"
					 )
			      (let ((lb (iup:listbox #:action (lambda (val a b c)
								;; (print val " a: " a " b: " b " c: " c)
								(set! newstate a))
						     ;; #:editbox "YES"
						     #:dropdown "YES"
						     ;#:expand "HORIZONTAL"
						     )))
			       (iuplistbox-fill-list lb
						     (list "Set state" "COMPLETED" "NOT_STARTED" "RUNNING" "REMOTEHOSTSTART" "KILLED" "KILLREQ")
						     "Set state" ) ; (db:test-get-state testdat))
			       lb))
			     (iup:hbox ; #:expand "HORIZONTAL" ;; the status
			      (iup:label "STATUS:" ; #:size "30x" #:expand "HORIZONTAL"
					 )
			      (let ((lb (iup:listbox #:action (lambda (val a b c)
								(set! newstatus a))
						     ;; #:editbox "YES"
						     ;; #:value currstatus
						     #:dropdown "YES"
						     ;#:expand "HORIZONTAL"
						     )))
				(iuplistbox-fill-list lb
						      (list "Set status" "PASS" "WARN" "FAIL" "CHECK" "n/a")
						      "Set status" ) ; (db:test-get-status testdat))
				lb)))
			    (iup:vbox
			     (iup:button "Apply"
					 #:expand "YES"
					 #:action (lambda (x)
						    (db:test-set-state-status-by-id *db* test-id newstate newstatus newcomment)
						    ))
			     (iup:hbox;  #:expand "YES"
			      (iup:vbox
			       (iup:button "Apply and close"
					; #:expand "YES"
					   #:action (lambda (x)
						      (db:test-set-state-status-by-id *db* test-id newstate newstatus newcomment)
						      (exit))))
			      (iup:vbox
			       (iup:button "Cancel and close"
					; #:expand "YES"
					   #:action (lambda (x)
						      (exit)))))))
			     ))))))
      (iup:show self)
      ;; Now start keeping the gui updated from the db
      (let loop ((i 0))
	(thread-sleep! 0.1)
	(refreshdat) ;; update from the db here
	;(thread-suspend! other-thread)
	;; update the gui elements here
	(for-each 
	 (lambda (key)
	   ;; (print "Updating " key)
	   ((hash-table-ref widgets key)))
	 (hash-table-keys widgets))
	;(thread-resume! other-thread)
	; (iup:refresh self)
	(iup:main-loop-flush)
	(if *exit-started*
	    (set! *exit-started* 'ok)
	    (loop i)))))))







|
|




|


|
<
<
<
<
<
<








<
|


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



|
<

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










|







210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226






227
228
229
230
231
232
233
234

235
236
237






238











































239
























240














241
242
243
244

245






246



















































247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
			     (begin
			       (sqlite3:finalize! db)
			       (exit 0))))))
	 (widgets      (make-hash-table))
	 (self         #f)
	 (store-label  (lambda (name lbl cmd)
			 (hash-table-set! widgets name 
					  (lambda (testdat)
					    (let ((newval (cmd testdat))
						  (oldval (iup:attribute lbl "TITLE")))
					      (if (not (equal? newval oldval))
						  (begin
						    (mutex-lock! mx1)
						    (iup:attribute-set! lbl "TITLE" newval)
						    (mutex-unlock! mx1))))))
			 lbl))
	 (store-button store-label))






    (cond
     ((not testdat)(begin (print "ERROR: bad test info for " test-id)(exit 1)))
     ((not rundat)(begin (print "ERROR: found test info but there is a problem with the run info for " run-id)(exit 1)))
     (else
      ;;  (test-set-status! db run-id test-name state status itemdat)
      (set! self ; 
	    (iup:dialog #:close_cb (lambda (a)(exit)) ; #:expand "YES"
	     #:title testfullname

	     (iup:vbox ; #:expand "YES"
               ;; The run and test info
	       (iup:hbox  ; #:expand "YES"






		(run-info-panel keydat testdat runname)











































		(test-info-panel testdat store-label widgets))
























	       (host-info-panel testdat store-label)














	       ;; The controls
	       (iup:frame #:title "Actions" ; #:expand "HORIZONTAL"
			  (iup:hbox ; #:expand "HORIZONTAL" ;; the actions box
			   (iup:button "View Log"    #:action viewlog #:expand "YES")

			   (iup:button "Start Xterm" #:action xterm  #:expand "YES")))






	       (set-fields-panel test-id testdat))))



















































      (iup:show self)
      ;; Now start keeping the gui updated from the db
      (let loop ((i 0))
	(thread-sleep! 0.1)
	(refreshdat) ;; update from the db here
	;(thread-suspend! other-thread)
	;; update the gui elements here
	(for-each 
	 (lambda (key)
	   ;; (print "Updating " key)
	   ((hash-table-ref widgets key) testdat))
	 (hash-table-keys widgets))
	;(thread-resume! other-thread)
	; (iup:refresh self)
	(iup:main-loop-flush)
	(if *exit-started*
	    (set! *exit-started* 'ok)
	    (loop i)))))))