Megatest

Check-in [c9ef4a34bf]
Login
Overview
Comment:Added obfuscation to extract skeleton ==/9.78/1.5/WARN/1202/orion/==
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v1.65
Files: files | file ages | folders
SHA1: c9ef4a34bf6d0877502438fe4377383894ee5573
User & Date: mrwellan on 2020-08-21 09:49:59
Original Comment: Added obfuscation to extract skeleton
Other Links: branch diff | manifest | tags
Context
2020-08-21
10:00
Removed junk noise ==/6.2/0.8/WARN/1202/mars/== check-in: 46d8ccee29 user: mrwellan tags: v1.65
09:49
Added obfuscation to extract skeleton ==/9.78/1.5/WARN/1202/orion/== check-in: c9ef4a34bf user: mrwellan tags: v1.65
2020-08-20
20:29
Added requirements section support to extract skeleton. Includes runner throttling change (get vars from configs). ==/7.2/0.9/WARN/1201/mars/== check-in: 3213d340ac user: mrwellan tags: v1.65
Changes

Modified db.scm from [35e6d8a640] to [657556a545].

3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240


3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251

;; NEW BEHAVIOR: Look only at single run with run-id
;; 
;; (define (db:get-running-stats dbstruct run-id)
(define (db:get-count-tests-running-for-run-id dbstruct run-id fastmode)
  (let* ((qry (if fastmode
		  "SELECT count(id) FROM tests WHERE state in ('RUNNING','LAUNCHED','REMOTEHOSTSTART') AND run_id=? LIMIT 1;"
		   "SELECT count(id) FROM tests WHERE state in ('RUNNING','LAUNCHED','REMOTEHOSTSTART') AND run_id=?;")))
    (db:with-db
     dbstruct
     run-id
     #f
     (lambda (db)
       (let* ((stmth (db:get-cache-stmth dbstruct db qry)))
	 (sqlite3:first-result stmth run-id))))))

;; For a given testname how many items are running? Used to determine
;; probability for regenerating html
;; 
(define (db:get-count-tests-running-for-testname dbstruct run-id testname)
  (db:with-db
   dbstruct
   run-id
   #f
   (lambda (db)


     (sqlite3:first-result
      db
      "SELECT count(id) FROM tests WHERE state in ('RUNNING','LAUNCHED','REMOTEHOSTSTART') AND run_id=? AND NOT (uname = 'n/a' AND item_path = '') AND testname=?;" run-id testname))))


(define (db:get-not-completed-cnt dbstruct run-id)
(db:with-db
   dbstruct
   run-id
   #f
   (lambda (db)







|

















>
>
|
<
<
|







3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243


3244
3245
3246
3247
3248
3249
3250
3251

;; NEW BEHAVIOR: Look only at single run with run-id
;; 
;; (define (db:get-running-stats dbstruct run-id)
(define (db:get-count-tests-running-for-run-id dbstruct run-id fastmode)
  (let* ((qry (if fastmode
		  "SELECT count(id) FROM tests WHERE state in ('RUNNING','LAUNCHED','REMOTEHOSTSTART') AND run_id=? LIMIT 1;"
		  "SELECT count(id) FROM tests WHERE state in ('RUNNING','LAUNCHED','REMOTEHOSTSTART') AND run_id=?;")))
    (db:with-db
     dbstruct
     run-id
     #f
     (lambda (db)
       (let* ((stmth (db:get-cache-stmth dbstruct db qry)))
	 (sqlite3:first-result stmth run-id))))))

;; For a given testname how many items are running? Used to determine
;; probability for regenerating html
;; 
(define (db:get-count-tests-running-for-testname dbstruct run-id testname)
  (db:with-db
   dbstruct
   run-id
   #f
   (lambda (db)
     (let* ((stmt "SELECT count(id) FROM tests WHERE state in ('RUNNING','LAUNCHED','REMOTEHOSTSTART') AND run_id=? AND NOT (uname = 'n/a' AND item_path = '') AND testname=?;")
	    (stmth (db:get-cache-stmth dbstruct db stmt)))
       (sqlite3:first-result


	stmth run-id testname)))))

(define (db:get-not-completed-cnt dbstruct run-id)
(db:with-db
   dbstruct
   run-id
   #f
   (lambda (db)
4078
4079
4080
4081
4082
4083
4084



4085
4086
4087
4088
4089
4090
4091
                                     db
                                     "SELECT state,status,count(id) FROM tests WHERE run_id=?  GROUP BY state,status;"
                                     run-id )))))
   test-count-recs))


;; BBnote: db:get-all-state-status-counts-for-test returns dbr:counts object aggregating state and status of items of a given test, *not including rollup state/status*



(define (db:get-all-state-status-counts-for-test dbstruct run-id test-name item-path item-state-in item-status-in)
  (let* ((test-info   (db:get-test-info dbstruct run-id test-name item-path))
         (item-state  (or item-state-in (db:test-get-state test-info))) 
         (item-status (or item-status-in (db:test-get-status test-info)))
         (other-items-count-recs (db:with-db
                                  dbstruct #f #f
                                  (lambda (db)







>
>
>







4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
                                     db
                                     "SELECT state,status,count(id) FROM tests WHERE run_id=?  GROUP BY state,status;"
                                     run-id )))))
   test-count-recs))


;; BBnote: db:get-all-state-status-counts-for-test returns dbr:counts object aggregating state and status of items of a given test, *not including rollup state/status*
;;
;; NOTE: This is called within a transaction
;;
(define (db:get-all-state-status-counts-for-test dbstruct run-id test-name item-path item-state-in item-status-in)
  (let* ((test-info   (db:get-test-info dbstruct run-id test-name item-path))
         (item-state  (or item-state-in (db:test-get-state test-info))) 
         (item-status (or item-status-in (db:test-get-status test-info)))
         (other-items-count-recs (db:with-db
                                  dbstruct #f #f
                                  (lambda (db)

Modified genexample.scm from [ab7e6fd951] to [ba2406c882].

362
363
364
365
366
367
368
369
370



















371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389


390
391
392
393
394
395
396
    res))

;; generate a skeleton Megatest area from a current area with runs
;;
;;    specify target, runname etc to use specific runs for the template
;;
(define (genexample:extract-skeleton-area dest-path)
  (let* ((target  (args:get-arg "-target"))
	 (runname (args:get-arg "-runname")))



















    (if (not (and target runname))
	(debug:print 0 *default-log-port* "WARNING: For best results please specifiy -target and -runname for a good run to use as a template."))
    (if (not (and (file-exists? "megatest.config")
		  (file-exists? "megatest.db")))
	(begin
	  (debug:print 0 *default-log-port* "ERROR: this command must be run at the top level of a megatest area where runs have been completed")
	  (exit)))
	     
    ;; first create the dest path and needed subdirectories
    (if (not (file-exists? dest-path))
	(begin
	  (create-directory dest-path)
	  (create-directory (conc dest-path "/tests")))
	(if (file-exists? (conc dest-path "/megatest.config"))
	    (begin
	      (debug:print 0 *default-log-port* "ERROR: destination path already has megatest.config, stopping now.")
	      (exit))))

    ;; dump the config files from this area to the dest area


    (system (conc "megatest -show-config > " dest-path "/megatest.config"))
    (system (conc "megatest -show-runconfig > " dest-path "/runconfigs.config"))

    ;; create stepsinfo and items refdbs, some stuff has to be done due to refdb not initing area
    ;;
    ;;            sheet       row       col      value
    ;; stepsinfo  testname    itempath  stepname steptime







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



















>
>







362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
    res))

;; generate a skeleton Megatest area from a current area with runs
;;
;;    specify target, runname etc to use specific runs for the template
;;
(define (genexample:extract-skeleton-area dest-path)
  (let* ((target    (args:get-arg "-target"))
	 (runname   (args:get-arg "-runname"))
	 (obtuse    (make-hash-table))
	 (obtusef   (args:get-arg "-obfuscate"))
	 (letters   (string-split-fields "\\S" "abcdefghijklmnopqrstuvwxyz"))
	 (maxletter (- (length letters) 1))
	 (lastlet   0)
	 (lastnum   1) 
	 (obfuscate (lambda (instr)
		      (or (hash-table-ref/default obtuse instr #f)
			  (if obtusef
			      (let* ((letter (list-ref letters lastlet))
				     (val    (conc letter lastnum)))
				(if (>= lastlet maxletter)
				    (begin
				      (set! lastlet 0)
				      (set! lastnum (+ lastnum 1)))
				    (set! lastlet (+ lastlet 1)))
				(hash-table-set! obtuse instr val)
				val)
			      instr)))))
    (if (not (and target runname))
	(debug:print 0 *default-log-port* "WARNING: For best results please specifiy -target and -runname for a good run to use as a template."))
    (if (not (and (file-exists? "megatest.config")
		  (file-exists? "megatest.db")))
	(begin
	  (debug:print 0 *default-log-port* "ERROR: this command must be run at the top level of a megatest area where runs have been completed")
	  (exit)))
	     
    ;; first create the dest path and needed subdirectories
    (if (not (file-exists? dest-path))
	(begin
	  (create-directory dest-path)
	  (create-directory (conc dest-path "/tests")))
	(if (file-exists? (conc dest-path "/megatest.config"))
	    (begin
	      (debug:print 0 *default-log-port* "ERROR: destination path already has megatest.config, stopping now.")
	      (exit))))

    ;; dump the config files from this area to the dest area
    (if (args:get-arg "-obfuscate")
	(debug:print 0 *default-log-port* "WARNING: obfuscation is NOT done on megatest.config and runconfigs.config. Please edit those files to remove any sensitive information!"))
    (system (conc "megatest -show-config > " dest-path "/megatest.config"))
    (system (conc "megatest -show-runconfig > " dest-path "/runconfigs.config"))

    ;; create stepsinfo and items refdbs, some stuff has to be done due to refdb not initing area
    ;;
    ;;            sheet       row       col      value
    ;; stepsinfo  testname    itempath  stepname steptime
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
		     ;; now get steps info
		     (test-steps   (tests:get-compressed-steps run-id test-id))
		     (testconfig   (tests:get-testconfig testname item-path testreg #f)))

		
		(if (not (hash-table-exists? fullt tfullname))
		    ;; do the work for this test if not previously done
		    (let* ((new-test-dir (conc dest-path "/tests/" testname))
			   (tconfigf     (conc new-test-dir "/testconfig")))
		      (print "Analyzing and extracting info for " tfullname)
		      (print "  toplevel: " (if tlevel "yes" "no"))
		      (hash-table-set! fullt tfullname #t) ;; track that this one has been seen
		      (if (not (directory-exists? new-test-dir))
			  (create-directory new-test-dir #t))

		      ;; create the testconfig IIF we are a toplevel or an item AND the testconfig has not been previously created
		      (if (and (or (not tlevel)
				   (not (equal? item-path "")))
			       (not (file-exists? tconfigf)))
			  (with-output-to-file tconfigf
			    (lambda ()
			      ;; first the ezsteps
			      (print "[ezsteps]")
			      (for-each
			       (lambda (teststep)
				 (let* ((step-name  (vector-ref teststep 0)))

				   (print step-name " sleep [refdb lookup #{getenv MT_RUN_AREA_HOME}/" stepsrdb " " testname " $MT_ITEM_PATH " step-name "]")))


			       test-steps)

			      ;; now the requirements section
			      (if testconfig
				  (begin
				    (print "\n[requirements]")
				    (for-each
				     (lambda (entry)

				       (print (car entry) " " (cadr entry))) ;; it is not an alist



				     (configf:get-section testconfig "requirements")))
				  (print "WARNING: No testconfig data for " testname ", " item-path))
				    
			      (print "[items]")
			      (print "THE_ITEM [refdb getrow #{getenv MT_RUN_AREA_HOME}/miscinfo itemsinfo #{getenv MT_TESTNAME}| awk '{print $1}'")
			      )))

		      ;; fill the stepsrdb
		      (for-each
		       (lambda (teststep)
			 (let* ((step-name     (vector-ref teststep 0))
				(step-duration (hrs-min-sec->seconds (vector-ref teststep 4))))
			   
			   (system (conc "refdb set " stepsrdb " " testname " '" (if (equal? item-path "")

										  "no-item-path"
										  item-path)
					 "' " step-name " " step-duration))))
		       test-steps)

		      ;; miscinfo   "itemsinfo" testname  itempath "x"
		      (if (not (equal? item-path ""))
			  (system (conc "refdb set " miscrdb " itemsinfo " testname " " item-path " x")))

		      ))))
	    tests-data)))
       (map (lambda (runrec)(simple-run-id runrec)) runs)))
    ))







|

|
















>
|
>
>








>
|
>
>
>



|
|








|
>
|
|
|




|





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
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
		     ;; now get steps info
		     (test-steps   (tests:get-compressed-steps run-id test-id))
		     (testconfig   (tests:get-testconfig testname item-path testreg #f)))

		
		(if (not (hash-table-exists? fullt tfullname))
		    ;; do the work for this test if not previously done
		    (let* ((new-test-dir (conc dest-path "/tests/" (obfuscate testname)))
			   (tconfigf     (conc new-test-dir "/testconfig")))
		      (print "Analyzing and extracting info for " tfullname " as " (obfuscate testname))
		      (print "  toplevel: " (if tlevel "yes" "no"))
		      (hash-table-set! fullt tfullname #t) ;; track that this one has been seen
		      (if (not (directory-exists? new-test-dir))
			  (create-directory new-test-dir #t))

		      ;; create the testconfig IIF we are a toplevel or an item AND the testconfig has not been previously created
		      (if (and (or (not tlevel)
				   (not (equal? item-path "")))
			       (not (file-exists? tconfigf)))
			  (with-output-to-file tconfigf
			    (lambda ()
			      ;; first the ezsteps
			      (print "[ezsteps]")
			      (for-each
			       (lambda (teststep)
				 (let* ((step-name  (vector-ref teststep 0)))
				   (print (obfuscate step-name)
					  " sleep [refdb lookup #{getenv MT_RUN_AREA_HOME}/stepsinfo "
					  (obfuscate testname) " $MT_ITEMPATH "
					  (obfuscate step-name) "]")))
			       test-steps)

			      ;; now the requirements section
			      (if testconfig
				  (begin
				    (print "\n[requirements]")
				    (for-each
				     (lambda (entry)
				       (let* ((key (car entry))
					      (val (cadr entry)))
					 (case (string->symbol key)
					   ((waiton)  (print "waiton " (obfuscate val)))
					   (else      (print key " " val)))))
				     (configf:get-section testconfig "requirements")))
				  (print "WARNING: No testconfig data for " testname ", " item-path))
				    
			      (print "\n[items]")
			      (print "THE_ITEM [refdb getrow #{getenv MT_RUN_AREA_HOME}/miscinfo itemsinfo " (obfuscate testname)" | awk '{print $1}']")
			      )))

		      ;; fill the stepsrdb
		      (for-each
		       (lambda (teststep)
			 (let* ((step-name     (vector-ref teststep 0))
				(step-duration (hrs-min-sec->seconds (vector-ref teststep 4))))
			   
			   (system (conc "refdb set " stepsrdb " " (obfuscate testname)
					 " '" (if (equal? item-path "")
						  "no-item-path"
						  (obfuscate item-path))
					 "' " (obfuscate step-name) " " step-duration))))
		       test-steps)

		      ;; miscinfo   "itemsinfo" testname  itempath "x"
		      (if (not (equal? item-path ""))
			  (system (conc "refdb set " miscrdb " itemsinfo " (obfuscate testname) " " (obfuscate item-path) " x")))

		      ))))
	    tests-data)))
       (map (lambda (runrec)(simple-run-id runrec)) runs)))
    ))

Modified megatest.scm from [cb14ee8afa] to [52da2391a8].

445
446
447
448
449
450
451

452
453
454
455
456
457
458
                        "-sync-brute-force"
			"-logging"
			"-v" ;; verbose 2, more than normal (normal is 1)
			"-q" ;; quiet 0, errors/warnings only

                        "-diff-rep"


			;; junk placeholder
			;; "-:p"
			
                        )
		 args:arg-hash
		 0))








>







445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
                        "-sync-brute-force"
			"-logging"
			"-v" ;; verbose 2, more than normal (normal is 1)
			"-q" ;; quiet 0, errors/warnings only

                        "-diff-rep"

			"-obfuscate"
			;; junk placeholder
			;; "-:p"
			
                        )
		 args:arg-hash
		 0))