Index: db.scm ================================================================== --- db.scm +++ db.scm @@ -327,13 +327,19 @@ (begin (sqlite3:execute db "CREATE TABLE IF NOT EXISTS log (id INTEGER PRIMARY KEY,event_time TIMESTAMP DEFAULT (strftime('%s','now')),logline TEXT,pwd TEXT,cmdline TEXT,pid INTEGER);") (sqlite3:execute db (conc "PRAGMA synchronous = 0;")))) db)) -(define (db:log-event . loglst) - (let ((db (open-logging-db)) - (logline (apply conc loglst))) +(define (db:log-local-event . loglst) + (let ((logline (apply conc loglst)) + (pwd (current-directory)) + (cmdline (string-intersperse (argv) " ")) + (pid (current-process-id))) + (db:log-event logline pwd cmdline pid))) + +(define (db:log-event logline pwd cmdline pid) + (let ((db (open-logging-db))) (sqlite3:execute db "INSERT INTO log (logline,pwd,cmdline,pid) VALUES (?,?,?,?);" logline (current-directory)(string-intersperse (argv) " ")(current-process-id)) (sqlite3:finalize! db) logline)) ;;====================================================================== @@ -1672,11 +1678,11 @@ (debug:print 4 "test-id: " test-id " teststep-name: " teststep-name) (let* ((tdb (db:open-test-db-by-test-id db test-id)) (state (items:check-valid-items "state" state-in)) (status (items:check-valid-items "status" status-in))) (if (or (not state)(not status)) - (debug:print 0 "WARNING: Invalid " (if status "status" "state") + (debug:print 3 "WARNING: Invalid " (if status "status" "state") " value \"" (if status state-in status-in) "\", update your validvalues section in megatest.config")) (if tdb (begin (sqlite3:execute tdb ADDED testzmq/mockupclientlib.scm Index: testzmq/mockupclientlib.scm ================================================================== --- /dev/null +++ testzmq/mockupclientlib.scm @@ -0,0 +1,40 @@ +(define sub (make-socket 'sub)) +(define push (make-socket 'push)) +(socket-option-set! sub 'subscribe cname) +(connect-socket sub "tcp://localhost:5563") +(connect-socket push "tcp://localhost:5564") + +(define (dbaccess cname cmd var val #!key (numtries 20)) + (let* ((msg (conc cname ":" cmd ":" (if val (conc var " " val) var))) + (res #f) + (mtx1 (make-mutex)) + (do-access (lambda () + (print "Sending msg: " msg) + (send-message push msg) + (print "Message " msg " sent") + (print "Client " cname " waiting for response to " msg) + (print "Client " cname " received address " (receive-message* sub)) + (mutex-lock! mtx1) + (set! res (receive-message* sub)) + (mutex-unlock! mtx1)))) + (let ((th1 (make-thread do-access "do access")) + (th2 (make-thread (lambda () + (let ((result #f)) + (mutex-lock! mtx1) + (set! result res) + (mutex-unlock! mtx1) + (thread-sleep! 5) + (if (not result) + (if (> numtries 0) + (begin + (print "WARNING: access timed out for " cname ", trying again. Trys remaining=" numtries) + (dbaccess cname cmd var val numtries: (- numtries 1))) + (begin + (print "ERROR: dbaccess timed out. Exiting") + (exit))))) + "timeout thread")))) + (thread-start! th1) + (thread-start! th2) + (thread-join! th1) + res))) + Index: testzmq/mockupserver.scm ================================================================== --- testzmq/mockupserver.scm +++ testzmq/mockupserver.scm @@ -9,12 +9,12 @@ (define pull (make-socket 'pull)) (define cname "server") (define total-db-accesses 0) (define start-time (current-seconds)) -(bind-socket pub "tcp://*:5563") -(bind-socket pull "tcp://*:5564") +(bind-socket pub "tcp://*:6563") +(bind-socket pull "tcp://*:6564") (define (open-db) (let* ((dbpath "mockup.db") (dbexists (file-exists? dbpath)) (db (open-database dbpath)) ;; (never-give-up-open-db dbpath)) ADDED testzmq/random.scm Index: testzmq/random.scm ================================================================== --- /dev/null +++ testzmq/random.scm @@ -0,0 +1,8 @@ +(use posix) +(randomize (inexact->exact (current-seconds))) + +(define low (string->number (cadr (argv)))) +(define hi (string->number (caddr (argv)))) + +(print (+ low (random (- hi low)))) + Index: testzmq/testmockup.sh ================================================================== --- testzmq/testmockup.sh +++ testzmq/testmockup.sh @@ -1,27 +1,28 @@ #!/bin/bash rm -f mockup.db echo Compiling mockupserver.scm and mockupclient.scm +csc random.scm csc mockupserver.scm csc mockupclient.scm echo Starting server ./mockupserver & sleep 1 echo Starting clients -for i in a b c d e f g h i j k l m n o p q s t u v w x y z; +for i in a b c d e; # f g h i j k l m n o p q s t u v w x y z; do for k in a b; do for j in 0 1 2 3 4 5 6 7 8 9; do - waittime=`random 0 60` - runtime=`random 5 120` + waittime=`./random 0 60` + runtime=`./random 5 120` echo "Starting client $i$k$j with waittime $waittime and runtime $runtime" (sleep $waittime;./mockupclient $i$k$j $runtime) & done done done