Megatest

Check-in [3455a21c0c]
Login
Overview
Comment:Trimmed output on migrating db from v1.55 to v1.60
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v1.60
Files: files | file ages | folders
SHA1: 3455a21c0c034edee5cd979f9efc2443e58421e3
User & Date: mrwellan on 2014-09-11 10:06:48
Other Links: branch diff | manifest | tags
Context
2014-09-11
10:13
Added -import-megatest.db to help. check-in: b931cba810 user: mrwellan tags: v1.60, v1.6001_beta
10:06
Trimmed output on migrating db from v1.55 to v1.60 check-in: 3455a21c0c user: mrwellan tags: v1.60
09:54
Initial pass at re-numbering tests to prevent overlap check-in: 06b8e0ec89 user: mrwellan tags: v1.60
Changes

Modified db.scm from [9309044c0a] to [f6b0a09960].

1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668

1669
1670
1671
1672
1673
1674
1675

(define (db:replace-test-records dbstruct run-id testrecs)
  (db:with-db dbstruct run-id #t 
	      (lambda (db)
		(let* ((qmarks (string-intersperse (make-list (length db:test-record-fields) "?") ","))
		       (qrystr (conc "INSERT OR REPLACE INTO tests (" db:test-record-qry-selector ") VALUES (" qmarks ");"))
		       (qry    (sqlite3:prepare db qrystr)))
		  (debug:print 0 "INFO: replace-test-records, qrystr=" qrystr)
		  (for-each 
		   (lambda (rec)
		     (debug:print 0 "INFO: Inserting values: " (string-intersperse (map conc (vector->list rec)) ",") "\n")
		     (apply sqlite3:execute qry (vector->list rec)))
		   testrecs)
		  (sqlite3:finalize! qry)))))

;; map a test-id into the proper range
;;
(define (db:adj-test-id mtdb min-test-id test-id)
  (if (> test-id min-test-id)
      test-id
      (let loop ((new-id min-test-id))
	(let ((test-id-found #f))
	  (sqlite3:for-each-row 
	   (lambda (id)
	     (set! test-id-found id))
	   mtdb
	   "SELECT id FROM tests WHERE id=?;"
	   new-id)
	  ;; if test-id-found then need to try again
	  (if test-id-found
	      (loop (+ new-id 1))
	      (begin
		(debug:print 0 "New test id " new-id " found for test with id " test-id)
		(sqlite3:execute mtdb "UPDATE tests SET id=? WHERE id=?;" new-id test-id)))))))

;; move test ids into the 30k * run_id range
;;
(define (db:prep-megatest.db-adj-test-ids mtdb run-id testrecs)

  (let ((min-test-id (* run-id 30000)))
    (for-each 
     (lambda (testrec)
       (let* ((test-id (vector-ref testrec (db:field->number "id" db:test-record-fields))))
	 (db:adj-test-id mtdb min-test-id test-id)))
     testrecs)))
	







|


|







|













|





>







1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676

(define (db:replace-test-records dbstruct run-id testrecs)
  (db:with-db dbstruct run-id #t 
	      (lambda (db)
		(let* ((qmarks (string-intersperse (make-list (length db:test-record-fields) "?") ","))
		       (qrystr (conc "INSERT OR REPLACE INTO tests (" db:test-record-qry-selector ") VALUES (" qmarks ");"))
		       (qry    (sqlite3:prepare db qrystr)))
		  (debug:print 0 "INFO: migrating test records for run with id " run-id)
		  (for-each 
		   (lambda (rec)
		     ;; (debug:print 0 "INFO: Inserting values: " (string-intersperse (map conc (vector->list rec)) ",") "\n")
		     (apply sqlite3:execute qry (vector->list rec)))
		   testrecs)
		  (sqlite3:finalize! qry)))))

;; map a test-id into the proper range
;;
(define (db:adj-test-id mtdb min-test-id test-id)
  (if (>= test-id min-test-id)
      test-id
      (let loop ((new-id min-test-id))
	(let ((test-id-found #f))
	  (sqlite3:for-each-row 
	   (lambda (id)
	     (set! test-id-found id))
	   mtdb
	   "SELECT id FROM tests WHERE id=?;"
	   new-id)
	  ;; if test-id-found then need to try again
	  (if test-id-found
	      (loop (+ new-id 1))
	      (begin
		(debug:print-info 0 "New test id " new-id " selected for test with id " test-id)
		(sqlite3:execute mtdb "UPDATE tests SET id=? WHERE id=?;" new-id test-id)))))))

;; move test ids into the 30k * run_id range
;;
(define (db:prep-megatest.db-adj-test-ids mtdb run-id testrecs)
  (debug:print-info 0 "Adjusting test ids in megatest.db for run " run-id)
  (let ((min-test-id (* run-id 30000)))
    (for-each 
     (lambda (testrec)
       (let* ((test-id (vector-ref testrec (db:field->number "id" db:test-record-fields))))
	 (db:adj-test-id mtdb min-test-id test-id)))
     testrecs)))
	

Modified megatest.scm from [fe88c56cc7] to [93ab142f51].

1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
      ;; sync runs, test_meta etc.
      ;;
      (db:sync-tables (db:sync-main-list mtdb) mtdb (db:get-db dbstruct #f))
      (for-each 
       (lambda (run-id)
	 (let ((testrecs (db:get-all-tests-info-by-run-id mtdb run-id))
	       (dbstruct (if toppath (make-dbr:dbstruct path: toppath local: #t) #f)))
	   (debug:print 0 "INFO: Updating " (length testrecs) " records for run-id=" run-id)
	   (db:replace-test-records dbstruct run-id testrecs)
	   (sqlite3:finalize! (dbr:dbstruct-get-rundb dbstruct))))
       run-ids)
      (set! *didsomething* #t)
      (db:close-all dbstruct)))

;;======================================================================







|







1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
      ;; sync runs, test_meta etc.
      ;;
      (db:sync-tables (db:sync-main-list mtdb) mtdb (db:get-db dbstruct #f))
      (for-each 
       (lambda (run-id)
	 (let ((testrecs (db:get-all-tests-info-by-run-id mtdb run-id))
	       (dbstruct (if toppath (make-dbr:dbstruct path: toppath local: #t) #f)))
	   (debug:print 0 "INFO: Propagating " (length testrecs) " records for run-id=" run-id " to run specific db")
	   (db:replace-test-records dbstruct run-id testrecs)
	   (sqlite3:finalize! (dbr:dbstruct-get-rundb dbstruct))))
       run-ids)
      (set! *didsomething* #t)
      (db:close-all dbstruct)))

;;======================================================================