Index: dbmod.scm
==================================================================
--- dbmod.scm
+++ dbmod.scm
@@ -306,10 +306,47 @@
(let ((tblname (car dat))
(count (cdr dat)))
(set! tot-count (+ tot-count count))))
(sort (hash-table->alist numrecs)(lambda (a b)(> (cdr a)(cdr b))))))
tot-count))
+
+;; direction = fromdest, todest
+;; mode = 'full, 'incr
+;;
+(define (dbmod:attach-sync tables dbh destdbfile direction #!key (mode 'full))
+ (let* ((dest-exists (file-exists? destdbfile)))
+ (assert dest-exists "FATAL: sync called with non-existant file, "destdbfile)
+ ;; attach the destdbfile
+ ;; for each table
+ ;; insert into dest.
select * from src. where last_update>last_update
+ ;; done
+ (sqlite3:execute dbh "ATTACH ? AS auxdb;" destdbfile)
+ (for-each
+ (lambda (table)
+ (let* ((dir (eq? direction 'todest))
+ (fromdb (if dir "" "auxdb."))
+ (todb (if dir "auxdb." ""))
+ (stmt1 (conc "INSERT OR IGNORE INTO "todb table
+ " SELECT * FROM "fromdb table";"))
+ (stmt2 (conc "INSERT OR REPLACE INTO "todb table
+ " SELECT * FROM "fromdb table" WHERE "
+ fromdb table".last_update > "
+ todb table".last_update;"))
+ (stmt3 (conc "INSERT OR REPLACE INTO "todb"."table
+ " SELECT * FROM "fromdb table";"))
+ (stmt4 (conc "DELETE FROM "todb table" WHERE "fromdb
+ "tests.last_update > "todb table".last_update;")))
+ ;; (print "stmt1: "stmt1)
+ ;; (print "stmt2: "stmt2)
+ ;; (print "stmt3: "stmt4)
+ ;; (print "stmt1: "stmt1)
+ (sqlite3:execute dbh stmt4)
+ (sqlite3:execute dbh stmt1)
+ ;; (sqlite3:execute dbh stmt1)
+ ;; (sqlite3:execute dbh stmt2)
+ (sqlite3:execute dbh "DETACH auxdb;")))
+ tables)))
;;======================================================================
;; Moved from dbfile
;;======================================================================
Index: tcp-transportmod.scm
==================================================================
--- tcp-transportmod.scm
+++ tcp-transportmod.scm
@@ -535,12 +535,14 @@
;;
(define (tt:server-process-run areapath testsuite mtexe run-id #!key (profile-mode "")) ;; areapath is *toppath* for a given testsuite area
(assert areapath "FATAL: tt:server-process-run called without areapath defined.")
(assert testsuite "FATAL: tt:server-process-run called without testsuite defined.")
(assert mtexe "FATAL: tt:server-process-run called without mtexe defined.")
- (let* ((load (get-normalized-cpu-load))
- (nrun (number-of-processes-running "mtest.*server")))
+ ;; mtest -server - -m testsuite:ext-tests -db 6.db
+ (let* ((dbfname (dbmod:run-id->dbfname run-id))
+ (load (get-normalized-cpu-load))
+ (nrun (number-of-processes-running (conc "mtest.*server.*"testsuite".*"dbfname))))
(cond
((> load 2.0)
(debug:print 0 *default-log-port* "Normalized load "load" is over the limit of 2.0. Not starting a server.")
(thread-sleep! 1))
((> nrun 100)
@@ -553,11 +555,11 @@
(cmdln (conc
mtexe
" -server - ";; (or target-host "-")
" -m testsuite:" testsuite
;; " -run-id " (or run-id "main") ;; NO, we do NOT want to have run id as part of this
- " -db " (dbmod:run-id->dbfname run-id)
+ " -db " dbfname ;; (dbmod:run-id->dbfname run-id)
" " profile-mode
))) ;; (conc " >> " logfile " 2>&1 &")))))
;; we want the remote server to start in *toppath* so push there
;; (push-directory areapath) ;; use cd in the command line instead
(debug:print 0 *default-log-port* "INFO: Trying to start server in tcp mode (" cmdln ") at "(common:human-time)" for "areapath)