Megatest

Check-in [eee3b1253c]
Login
Overview
Comment:wip
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v1.65-code-cleanup
Files: files | file ages | folders
SHA1: eee3b1253ca26a67fdd90fda980be0895df214fc
User & Date: mrwellan on 2019-08-26 15:59:26
Other Links: branch diff | manifest | tags
Context
2019-08-27
14:12
Merged from v1.65 check-in: 9e659a12a0 user: mrwellan tags: v1.65-code-cleanup
2019-08-26
15:59
wip check-in: eee3b1253c user: mrwellan tags: v1.65-code-cleanup
13:51
wip check-in: ca9be5d286 user: mrwellan tags: v1.65-code-cleanup
Changes

Modified runs.scm from [ce693176ff] to [35c2075430].

2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
  (let ((test-names (tests:get-all))) ;; (tests:get-valid-tests)))
    (for-each 
     (lambda (test-name)
       (let* ((test-conf    (mt:lazy-read-test-config test-name)))
	 (if test-conf (runs:update-test_meta test-name test-conf))))
     (hash-table-keys test-names))))

;; This could probably be refactored into one complex query ...
;; NOT PORTED - DO NOT USE YET
;;
(define (runs:rollup-run keys runname user keyvals)
  (debug:print 4 *default-log-port* "runs:rollup-run, keys: " keys " -runname " runname " user: " user)
  (let* ((db              #f)
	 ;; register run operates on the main db
	 (new-run-id      (rmt:register-run keyvals runname "new" "n/a" user (args:get-arg "-contour")))
	 (prev-tests      (rmt:get-matching-previous-test-run-records new-run-id "%" "%"))
	 (curr-tests      (mt:get-tests-for-run new-run-id "%/%" '() '()))
	 (curr-tests-hash (make-hash-table)))
    (rmt:update-run-event_time new-run-id)
    ;; index the already saved tests by testname and itemdat in curr-tests-hash
    (for-each
     (lambda (testdat)
       (let* ((testname  (db:test-get-testname testdat))
	      (item-path (db:test-get-item-path testdat))
	      (full-name (conc testname "/" item-path)))
	 (hash-table-set! curr-tests-hash full-name testdat)))
     curr-tests)
    ;; NOPE: Non-optimal approach. Try this instead.
    ;;   1. tests are received in a list, most recent first
    ;;   2. replace the rollup test with the new *always*
    (for-each 
     (lambda (testdat)
       (let* ((testname  (db:test-get-testname testdat))
	      (item-path (db:test-get-item-path testdat))
	      (full-name (conc testname "/" item-path))
	      (prev-test-dat (hash-table-ref/default curr-tests-hash full-name #f))
	      (test-steps    (rmt:get-steps-for-test (db:test-get-id testdat)))
	      (new-test-record #f))
	 ;; replace these with insert ... select
	 (apply sqlite3:execute 
		db 
		(conc "INSERT OR REPLACE INTO tests (run_id,testname,state,status,event_time,host,cpuload,diskfree,uname,rundir,item_path,run_duration,final_logf,comment) "
		      "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?);")
		new-run-id (cddr (vector->list testdat)))
	 (set! new-testdat (car (mt:get-tests-for-run new-run-id (conc testname "/" item-path) '() '())))
	 (hash-table-set! curr-tests-hash full-name new-testdat) ;; this could be confusing, which record should go into the lookup table?
	 ;; Now duplicate the test steps
	 (debug:print 4 *default-log-port* "Copying records in test_steps from test_id=" (db:test-get-id testdat) " to " (db:test-get-id new-testdat))
	 (cdb:remote-run ;; to be replaced, note: this routine is not used currently
	  (lambda ()
	    (sqlite3:execute 
	     db 
	     (conc "INSERT OR REPLACE INTO test_steps (test_id,stepname,state,status,event_time,comment) "
		   "SELECT " (db:test-get-id new-testdat) ",stepname,state,status,event_time,comment FROM test_steps WHERE test_id=?;")
	     (db:test-get-id testdat))
	    ;; Now duplicate the test data
	    (debug:print 4 *default-log-port* "Copying records in test_data from test_id=" (db:test-get-id testdat) " to " (db:test-get-id new-testdat))
	    (sqlite3:execute 
	     db 
	     (conc "INSERT OR REPLACE INTO test_data (test_id,category,variable,value,expected,tol,units,comment) "
		   "SELECT " (db:test-get-id new-testdat) ",category,variable,value,expected,tol,units,comment FROM test_data WHERE test_id=?;")
	     (db:test-get-id testdat))))
	 ))
     prev-tests)))
	 
     
;; clean cache files
(define (runs:clean-cache target runname toppath)
  (if target
      (if runname
	  (let* ((linktree (common:get-linktree)) ;; (if toppath (configf:lookup *configdat* "setup" "linktree")))







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







2558
2559
2560
2561
2562
2563
2564

























































2565
2566
2567
2568
2569
2570
2571
  (let ((test-names (tests:get-all))) ;; (tests:get-valid-tests)))
    (for-each 
     (lambda (test-name)
       (let* ((test-conf    (mt:lazy-read-test-config test-name)))
	 (if test-conf (runs:update-test_meta test-name test-conf))))
     (hash-table-keys test-names))))


























































	 
     
;; clean cache files
(define (runs:clean-cache target runname toppath)
  (if target
      (if runname
	  (let* ((linktree (common:get-linktree)) ;; (if toppath (configf:lookup *configdat* "setup" "linktree")))
2640
2641
2642
2643
2644
2645
2646






























































		     (handle-exceptions
			 exn
			 (debug:print 0 *default-log-port* "WARNING: Failed to remove file " f)
		       (delete-file f)))
		   files))))
	  (debug:print-error 0 *default-log-port* "-clean-cache requires -runname."))
      (debug:print-error 0 *default-log-port* "-clean-cache requires -target or -reqtarg")))





































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
		     (handle-exceptions
			 exn
			 (debug:print 0 *default-log-port* "WARNING: Failed to remove file " f)
		       (delete-file f)))
		   files))))
	  (debug:print-error 0 *default-log-port* "-clean-cache requires -runname."))
      (debug:print-error 0 *default-log-port* "-clean-cache requires -target or -reqtarg")))

;;======================================================================
;; DEFUNCT
;;======================================================================

;;==remove me==;; This could probably be refactored into one complex query ...
;;==remove me==;; NOT PORTED - DO NOT USE YET
;;==remove me==;;
;;==remove me==(define (runs:rollup-run keys runname user keyvals)
;;==remove me==  (debug:print 4 *default-log-port* "runs:rollup-run, keys: " keys " -runname " runname " user: " user)
;;==remove me==  (let* ((db              #f)
;;==remove me==	 ;; register run operates on the main db
;;==remove me==	 (new-run-id      (rmt:register-run keyvals runname "new" "n/a" user (args:get-arg "-contour")))
;;==remove me==	 (prev-tests      (rmt:get-matching-previous-test-run-records new-run-id "%" "%"))
;;==remove me==	 (curr-tests      (mt:get-tests-for-run new-run-id "%/%" '() '()))
;;==remove me==	 (curr-tests-hash (make-hash-table)))
;;==remove me==    (rmt:update-run-event_time new-run-id)
;;==remove me==    ;; index the already saved tests by testname and itemdat in curr-tests-hash
;;==remove me==    (for-each
;;==remove me==     (lambda (testdat)
;;==remove me==       (let* ((testname  (db:test-get-testname testdat))
;;==remove me==	      (item-path (db:test-get-item-path testdat))
;;==remove me==	      (full-name (conc testname "/" item-path)))
;;==remove me==	 (hash-table-set! curr-tests-hash full-name testdat)))
;;==remove me==     curr-tests)
;;==remove me==    ;; NOPE: Non-optimal approach. Try this instead.
;;==remove me==    ;;   1. tests are received in a list, most recent first
;;==remove me==    ;;   2. replace the rollup test with the new *always*
;;==remove me==    (for-each 
;;==remove me==     (lambda (testdat)
;;==remove me==       (let* ((testname  (db:test-get-testname testdat))
;;==remove me==	      (item-path (db:test-get-item-path testdat))
;;==remove me==	      (full-name (conc testname "/" item-path))
;;==remove me==	      (prev-test-dat (hash-table-ref/default curr-tests-hash full-name #f))
;;==remove me==	      (test-steps    (rmt:get-steps-for-test (db:test-get-id testdat)))
;;==remove me==	      (new-test-record #f))
;;==remove me==	 ;; replace these with insert ... select
;;==remove me==	 (apply sqlite3:execute 
;;==remove me==		db 
;;==remove me==		(conc "INSERT OR REPLACE INTO tests (run_id,testname,state,status,event_time,host,cpuload,diskfree,uname,rundir,item_path,run_duration,final_logf,comment) "
;;==remove me==		      "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?);")
;;==remove me==		new-run-id (cddr (vector->list testdat)))
;;==remove me==	 (set! new-testdat (car (mt:get-tests-for-run new-run-id (conc testname "/" item-path) '() '())))
;;==remove me==	 (hash-table-set! curr-tests-hash full-name new-testdat) ;; this could be confusing, which record should go into the lookup table?
;;==remove me==	 ;; Now duplicate the test steps
;;==remove me==	 (debug:print 4 *default-log-port* "Copying records in test_steps from test_id=" (db:test-get-id testdat) " to " (db:test-get-id new-testdat))
;;==remove me==	 (cdb:remote-run ;; to be replaced, note: this routine is not used currently
;;==remove me==	  (lambda ()
;;==remove me==	    (sqlite3:execute 
;;==remove me==	     db 
;;==remove me==	     (conc "INSERT OR REPLACE INTO test_steps (test_id,stepname,state,status,event_time,comment) "
;;==remove me==		   "SELECT " (db:test-get-id new-testdat) ",stepname,state,status,event_time,comment FROM test_steps WHERE test_id=?;")
;;==remove me==	     (db:test-get-id testdat))
;;==remove me==	    ;; Now duplicate the test data
;;==remove me==	    (debug:print 4 *default-log-port* "Copying records in test_data from test_id=" (db:test-get-id testdat) " to " (db:test-get-id new-testdat))
;;==remove me==	    (sqlite3:execute 
;;==remove me==	     db 
;;==remove me==	     (conc "INSERT OR REPLACE INTO test_data (test_id,category,variable,value,expected,tol,units,comment) "
;;==remove me==		   "SELECT " (db:test-get-id new-testdat) ",category,variable,value,expected,tol,units,comment FROM test_data WHERE test_id=?;")
;;==remove me==	     (db:test-get-id testdat))))
;;==remove me==	 ))
;;==remove me==     prev-tests)))