Index: db.scm ================================================================== --- db.scm +++ db.scm @@ -936,10 +936,27 @@ (last-update (if use-last-update (cons "last_update" targ-db-last-mod) #f))) (db:sync-tables (db:sync-main-list source-db) last-update source-db cache-db) (db:sync-tables db:sync-tests-only last-update source-db cache-db) (hash-table-set! *global-db-store* target cache-db) cache-db))) + +;; move records for runs untouched for over given time (2 weeks default) to +;; megatest_additional.db if there are more than 5000 test records in the db +;; +(define (db:reduce-records #!key (use-last-update #f)) + (let* ((toppath (launch:setup)) + (srcdir toppath) + (srcname "megatest.db") + (trgdir toppath) + (trgname "megatest_additional.db") + (dest-db (db:open-megatest-db path: trgdir name: trgname)) + (source-db (db:open-megatest-db path: srcdir name: srcname))) + ;; (db:sync-tables (db:sync-main-list source-db) last-update source-db cache-db) + ;; (db:sync-tables db:sync-tests-only last-update source-db cache-db) + ;; (hash-table-set! *global-db-store* target cache-db) + ;; cache-db + )) ;; ;; call a proc with a cached db ;; ;; ;; (define (db:call-with-cached-db proc . params) ;; ;; first cache the db in /tmp Index: megatest.scm ================================================================== --- megatest.scm +++ megatest.scm @@ -178,15 +178,16 @@ Misc -start-dir path : switch to this directory before running megatest -contour cname : add a level of hierarcy to the linktree and run paths -area-tag tagname : add a tag to an area while syncking to pgdb - -rebuild-db : bring the database schema up to date -cleanup-db : remove any orphan records, vacuum the db -import-megatest.db : push data from megatest.db to cache db files in /tmp/$USER -sync-to-megatest.db : pull data from cache files in /tmp/$USER to megatest.db -sync-to dest : sync to new postgresql central style database + -reduce-records : move old records to megatest_additional.db, respects selectors + -restore-records : bring records back to megatest.db, respects selectors -update-meta : update the tests metadata for all tests -setvars VAR1=val1,VAR2=val2 : Add environment variables to a run NB// these are overwritten by values set in config files. -server -|hostname : start the server (reduces contention on megatest.db), use - to automatically figure out hostname @@ -308,10 +309,12 @@ "-env2file" "-envcap" "-envdelta" "-setvars" "-set-state-status" + "-reduce-records" + "-restore-records" ;; move runs stuff here "-remove-keep" "-set-run-status" "-age" @@ -1684,31 +1687,10 @@ ;; - step completed, exit status, timestamp ;; 6. test phone home ;; - if test run time > allowed run time then kill job ;; - if cannot access db > allowed disconnect time then kill job -;; == duplicated == (if (or (args:get-arg "-run")(args:get-arg "-runtests")) -;; == duplicated == (general-run-call -;; == duplicated == "-runtests" -;; == duplicated == "run a test" -;; == duplicated == (lambda (target runname keys keyvals) -;; == duplicated == ;; -;; == duplicated == ;; May or may not implement it this way ... -;; == duplicated == ;; -;; == duplicated == ;; Insert this run into the tasks queue -;; == duplicated == ;; (open-run-close tasks:add tasks:open-db -;; == duplicated == ;; "runtests" -;; == duplicated == ;; user -;; == duplicated == ;; target -;; == duplicated == ;; runname -;; == duplicated == ;; (args:get-arg "-runtests") -;; == duplicated == ;; #f)))) -;; == duplicated == (runs:run-tests target -;; == duplicated == runname -;; == duplicated == (common:args-get-testpatt #f) ;; (args:get-arg "-runtests") -;; == duplicated == user -;; == duplicated == args:arg-hash)))) ;;====================================================================== ;; Rollup into a run ;;====================================================================== @@ -1797,10 +1779,28 @@ (general-run-call "-archive" "Archive" (lambda (target runname keys keyvals) (operate-on 'archive)))) + +;; reduce-records and restore-records are similar to archiving +;; +(if (args:get-arg "-reduce-records") + (general-run-call + "-reduce-records" + "reduce records" + (lambda (target runname keys keyvals) + (operate-on 'reduce-records) + ))) + +(if (args:get-arg "-restore-records") + (general-run-call + "-reduce-records" + "reduce records" + (lambda (target runname keys keyvals) + (operate-on 'restore-records) + ))) ;;====================================================================== ;; Extract a spreadsheet from the runs database ;;======================================================================