Megatest

Check-in [de789cac51]
Login
Overview
Comment:Fixed issue with -list-targets where it sometimes failed to report all targets
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: de789cac51b84227ec9a60a0f3cae136540ebed8
User & Date: mrwellan on 2012-12-04 17:02:48
Other Links: manifest | tags
Context
2012-12-06
17:27
Removed run info caching. Cache needs to be invalidated on removal of runs. check-in: 858eb80b3f user: mrwellan tags: trunk
2012-12-04
17:02
Fixed issue with -list-targets where it sometimes failed to report all targets check-in: de789cac51 user: mrwellan tags: trunk
2012-12-03
17:21
Added -list-targets, -list-disks and -list-db-targets check-in: 970f20a4ba user: mrwellan tags: trunk
Changes

Modified common.scm from [4f1a0ece13] to [0c5c3a4b91].

113
114
115
116
117
118
119

120
121
122
123
124
125
126
127
128
129
130
	     (debug:print-info 10 "patt " patt " modpatt " modpatt)
	     (if (string-match (regexp modpatt) item)
		 (set! res #t))))
	 (string-split patts ","))
	res)
      #t))


(define (common:get-runconfig-targets)
  (sort (map car (hash-table->alist
		  (read-config "runconfigs.config"
			       (make-hash-table) #f))) string<?))

;; '(print (string-intersperse (map cadr (hash-table-ref/default (read-config "megatest.config" \#f \#t) "disks" '"'"'("none" ""))) "\n"))'
(define (common:get-disks)
  (hash-table-ref/default 
   (read-config "megatest.config" #f #t)
   "disks" '("none" "")))








>



|







113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
	     (debug:print-info 10 "patt " patt " modpatt " modpatt)
	     (if (string-match (regexp modpatt) item)
		 (set! res #t))))
	 (string-split patts ","))
	res)
      #t))

;; (map print (map car (hash-table->alist (read-config "runconfigs.config" #f #t))))
(define (common:get-runconfig-targets)
  (sort (map car (hash-table->alist
		  (read-config "runconfigs.config"
			       #f #t))) string<?))

;; '(print (string-intersperse (map cadr (hash-table-ref/default (read-config "megatest.config" \#f \#t) "disks" '"'"'("none" ""))) "\n"))'
(define (common:get-disks)
  (hash-table-ref/default 
   (read-config "megatest.config" #f #t)
   "disks" '("none" "")))

Modified megatest.scm from [302c3da708] to [f0f3da05f7].

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
307
308
309
310
311
312
;;======================================================================

(if (args:get-arg "-env2file")
    (begin
      (save-environment-as-files (args:get-arg "-env2file"))
      (set! *didsomething* #t)))

(if (args:get-arg "-list-targets")
    (begin
      (print (string-intersperse
	      (common:get-runconfig-targets)
	      "\n"))
      (set! *didsomething* #t)))

;; (if (args:get-arg "-list-db-targets")
;;     (if (setup-for-run)
;; 	(let* ((db       (open-db)) ;; A=%,B=foo => ("A=%" "B=foo")
;; 	       (keypatts (let ((pattstr  (args:get-arg "-list-db-targets")))
;; 			   (if (equal? pattstr "-") 
;; 			       #f
;; 			       (let ((all (string-split pattstr ",")))
;; 				 (map (lambda (x) ;; A=% => (A "%")
;; 					(string-split x "="))
;; 				      all)))))
;; 	       (runsdat  (db:get-runs db "%" #f #f keypatts))
;; 	       (runs     (cadr runsdat))
;; 	       (header   (car  runsdat))
;; 	       (seen     (make-hash-table))
;; 	       (keysdat  (db:get-keys db))
;; 	       (keys     (map (lambda (x)(vector-ref x 0)) keysdat)))
;; 
;; 	  (for-each 
;; 	   (lambda (run)
;; 	     (print (string-intersperse 
;; 		     (let loop ((key (car keys))
;; 				(tal (cdr keys))
;; 				(res '()))
;; 		       (let ((val (db:get-value-by-header run header key)))
;; 			 (if (null? tal)
;; 			     (append res (list val))
;; 			     (loop (car tal)(cdr tal)(append res (list val))))))
;; 		     "/")))
;; 	   runs))))

(if (args:get-arg "-list-disks")
    (begin
      (print 
       (string-intersperse 
	(map (lambda (x)
	       (string-intersperse 
		x







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







262
263
264
265
266
267
268





































269
270
271
272
273
274
275
;;======================================================================

(if (args:get-arg "-env2file")
    (begin
      (save-environment-as-files (args:get-arg "-env2file"))
      (set! *didsomething* #t)))






































(if (args:get-arg "-list-disks")
    (begin
      (print 
       (string-intersperse 
	(map (lambda (x)
	       (string-intersperse 
		x
371
372
373
374
375
376
377













378
379
380
381
382
383
384
	  (exit)))
    ;; if not list or kill then start a client (if appropriate)
    (if (or (args-defined? "-h" "-version" "-gen-megatest-area" "-gen-megatest-test")
	    (eq? (length (hash-table-keys args:arg-hash)) 0))
	(debug:print-info 1 "Server connection not needed")
	
	(server:client-launch)))














;;======================================================================
;; Remove old run(s)
;;======================================================================

;; since several actions can be specified on the command line the removal
;; is done first







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







334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
	  (exit)))
    ;; if not list or kill then start a client (if appropriate)
    (if (or (args-defined? "-h" "-version" "-gen-megatest-area" "-gen-megatest-test")
	    (eq? (length (hash-table-keys args:arg-hash)) 0))
	(debug:print-info 1 "Server connection not needed")
	
	(server:client-launch)))

;;======================================================================
;; Weird special calls that need to run *after* the server has started?
;;======================================================================

(if (args:get-arg "-list-targets")
    (let ((targets (common:get-runconfig-targets)))
      (print "Found "(length targets) " targets")
      (for-each (lambda (x)
		  (print "[" x "]"))
		targets)
      (set! *didsomething* #t)))


;;======================================================================
;; Remove old run(s)
;;======================================================================

;; since several actions can be specified on the command line the removal
;; is done first
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457

458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
(if (or (args:get-arg "-list-runs")
	(args:get-arg "-list-db-targets"))
    (if (setup-for-run)
	(let* ((db       #f)
	       (runpatt  (args:get-arg "-list-runs"))
	       (testpatt (if (args:get-arg "-testpatt") 
			     (args:get-arg "-testpatt") 
			     "A long and rediculous test name that hopefully will never match"))
	       (runsdat  (open-run-close db:get-runs db runpatt #f #f '()))
	       (runs     (db:get-rows runsdat))
	       (header   (db:get-header runsdat))
	       (keys     (open-run-close db:get-keys db))
	       (keynames (map key:get-fieldname keys))
	       (db-targets (args:get-arg "-list-db-targets"))
	       (seen     (make-hash-table)))
	  ;; Each run
	  (for-each 
	   (lambda (run)
	     (let ((targetstr (string-intersperse (map (lambda (x)
							 (db:get-value-by-header run header x))
						       keynames) "/")))
	       (if db-targets
		   (if (not (hash-table-ref/default seen targetstr #f))
		       (begin
			 (hash-table-set! seen targetstr #t)
			 (print targetstr)))
		   (debug:print 1 
				(if db-targets "" "Run: ")
				targetstr 
				(if db-targets "" (conc " status: " (db:get-value-by-header run header "state"))))
		   ))
	     (let ((run-id (open-run-close db:get-value-by-header run header "id")))
	       (let ((tests (open-run-close db:get-tests-for-run db run-id testpatt '() '())))

		 ;; Each test
		 (for-each 
		  (lambda (test)
		    (format #t
			    "  Test: ~25a State: ~15a Status: ~15a Runtime: ~5@as Time: ~22a Host: ~10a\n"
			    (conc (db:test-get-testname test)
				  (if (equal? (db:test-get-item-path test) "")
				      "" 
				      (conc "(" (db:test-get-item-path test) ")")))
			    (db:test-get-state test)
			    (db:test-get-status test)
			    (db:test-get-run_duration test)
			    (db:test-get-event_time test)
			    (db:test-get-host test))
		    (if (not (or (equal? (db:test-get-status test) "PASS")
				 (equal? (db:test-get-status test) "WARN")
				 (equal? (db:test-get-state test)  "NOT_STARTED")))
			(begin
			  (print "         cpuload:  " (db:test-get-cpuload test)
				 "\n         diskfree: " (db:test-get-diskfree test)
				 "\n         uname:    " (db:test-get-uname test)
				 "\n         rundir:   " (db:test-get-rundir test)
				 )
			  ;; Each test
			  (let ((steps (open-run-close db:get-steps-for-test db (db:test-get-id test))))
			    (for-each 
			     (lambda (step)
			       (format #t 
				       "    Step: ~20a State: ~10a Status: ~10a Time ~22a\n"
				       (db:step-get-stepname step)
				       (db:step-get-state step)
				       (db:step-get-status step)
				       (db:step-get-event_time step)))
			     steps)))))
		  tests))))
	   runs)
	  (set! *didsomething* #t))
	(exit)))

;;======================================================================
;; full run
;;======================================================================

;; get lock in db for full run for this directory
;; for all tests with deps







|

















|
<
<
|
<
<
|
|
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<







401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426


427


428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467

468
469
470
471
472
473
474
(if (or (args:get-arg "-list-runs")
	(args:get-arg "-list-db-targets"))
    (if (setup-for-run)
	(let* ((db       #f)
	       (runpatt  (args:get-arg "-list-runs"))
	       (testpatt (if (args:get-arg "-testpatt") 
			     (args:get-arg "-testpatt") 
			     "%"))
	       (runsdat  (open-run-close db:get-runs db runpatt #f #f '()))
	       (runs     (db:get-rows runsdat))
	       (header   (db:get-header runsdat))
	       (keys     (open-run-close db:get-keys db))
	       (keynames (map key:get-fieldname keys))
	       (db-targets (args:get-arg "-list-db-targets"))
	       (seen     (make-hash-table)))
	  ;; Each run
	  (for-each 
	   (lambda (run)
	     (let ((targetstr (string-intersperse (map (lambda (x)
							 (db:get-value-by-header run header x))
						       keynames) "/")))
	       (if db-targets
		   (if (not (hash-table-ref/default seen targetstr #f))
		       (begin
			 (hash-table-set! seen targetstr #t)
			 (print "[" targetstr "]"))))


	       (if (not db-targets)


		   (let* ((run-id (open-run-close db:get-value-by-header run header "id"))
			  (tests  (open-run-close db:get-tests-for-run db run-id testpatt '() '())))
		     (debug:print 1 "Run: " targetstr " status: " (db:get-value-by-header run header "state")
				  " run-id: " run-id ", number tests: " (length tests))
		     (for-each 
		      (lambda (test)
			(format #t
				"  Test: ~25a State: ~15a Status: ~15a Runtime: ~5@as Time: ~22a Host: ~10a\n"
				(conc (db:test-get-testname test)
				      (if (equal? (db:test-get-item-path test) "")
					  "" 
					  (conc "(" (db:test-get-item-path test) ")")))
				(db:test-get-state test)
				(db:test-get-status test)
				(db:test-get-run_duration test)
				(db:test-get-event_time test)
				(db:test-get-host test))
			(if (not (or (equal? (db:test-get-status test) "PASS")
				     (equal? (db:test-get-status test) "WARN")
				     (equal? (db:test-get-state test)  "NOT_STARTED")))
			    (begin
			      (print "         cpuload:  " (db:test-get-cpuload test)
				     "\n         diskfree: " (db:test-get-diskfree test)
				     "\n         uname:    " (db:test-get-uname test)
				     "\n         rundir:   " (db:test-get-rundir test)
				     )
			      ;; Each test
			      (let ((steps (open-run-close db:get-steps-for-test db (db:test-get-id test))))
				(for-each 
				 (lambda (step)
				   (format #t 
					   "    Step: ~20a State: ~10a Status: ~10a Time ~22a\n"
					   (db:step-get-stepname step)
					   (db:step-get-state step)
					   (db:step-get-status step)
					   (db:step-get-event_time step)))
				 steps)))))
		      tests)))))
	     runs)
	   (set! *didsomething* #t))))


;;======================================================================
;; full run
;;======================================================================

;; get lock in db for full run for this directory
;; for all tests with deps