ADDED fullrununit.sh Index: fullrununit.sh ================================================================== --- /dev/null +++ fullrununit.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +(killall mtest -v;sleep 1;killall mtest -v -9;rm tests/simplerun/logs/*;rm tests/basicserver.log) & +ck5 make install +wait +ck5 make unit Index: http-transportmod.scm ================================================================== --- http-transportmod.scm +++ http-transportmod.scm @@ -126,10 +126,15 @@ ;; -> http-transport:run ;; -> http-transport:try-start-server -> http-transport:try-start-server (until success) (define (http-get-function fnkey) (hash-table-ref/default *http-functions* fnkey (lambda () "nothing here yet"))) + +(define (http-handle-api dbstruct $) + (if (api-proc) + ((api-proc) dbstruct $) ;; ($) => alist + 'no-api-proc-set)) (define (http-transport:run hostn) ;; Configurations for server (tcp-buffer-size 2048) (max-connections 2048) @@ -161,18 +166,18 @@ ;; (vhost-map `(((* any) . ,(lambda (continue) ;; open the db on the first call ;; This is were we set up the database connections (let* (($ (request-vars source: 'both)) - (dat ($ 'dat)) + ;; (dat ($ 'dat)) (res #f)) (cond ((equal? (uri-path (request-uri (current-request))) '(/ "api")) (debug:print 0 *default-log-port* "In api request $=" $) (send-response ;; the $ is the request vars proc - body: ((api-proc) *dbstruct-db* $) ;; ($) => alist + body: (http-handle-api *dbstruct-db* $) headers: '((content-type text/plain))) (set! *db-last-access* (current-seconds))) ((equal? (uri-path (request-uri (current-request))) '(/ "ping")) (send-response body: (conc *toppath*"/"(args:get-arg "-db")) @@ -495,11 +500,11 @@ ;; if it ready ;; (let* ((sdat (servdat-init #f host port #f))) ;; (http-transport:send-receive sdat "abc" 'ping '()))) (let* ((payload (sexpr->string data)) (res (with-input-from-request - (conc "http://"host":"port"/loop-test") ;; returns *toppath*/dbname + (conc "http://"host":"port"/loop-test") `((data . ,payload)) read-string))) (string->sexpr res))) ; from the pkts return servers associated with dbpath Index: rmtmod.scm ================================================================== --- rmtmod.scm +++ rmtmod.scm @@ -272,16 +272,18 @@ (assert conn "FATAL: Unable to connect to db "apath"/"dbname) (let* (;; (host (rmt:conn-ipaddr conn)) ;; (port (rmt:conn-port conn)) (payload (sexpr->string params)) (res (with-input-from-request - (rmt:conn->uri conn "api") ;; (conc "http://"host":"port"/api") + (rmt:conn->uri conn "api") `((params . ,payload) (cmd . ,cmd) (key . "nokey")) read-string))) - (string->sexpr res)))) + (if (string? res) + (string->sexpr res) + res)))) ;; db is at apath/.db/dbname, rid is an intermediary solution and will be removed ;; sometime in the future ;; (define (rmt:send-receive-server-start remote apath dbname) Index: tests/unittests/basicserver.scm ================================================================== --- tests/unittests/basicserver.scm +++ tests/unittests/basicserver.scm @@ -25,10 +25,12 @@ (import rmtmod trace http-transportmod http-client apimod dbmod) (trace-call-sites #t) (trace ;; db:get-dbdat ;; rmt:find-main-server + rmt:send-receive-real + sexpr->string ) (test #f #t (rmt:remote? (let ((r (make-rmt:remote))) (set! *rmt:remote* r) r))) @@ -38,11 +40,16 @@ (pp (hash-table->alist (rmt:remote-conns *rmt:remote*))) (test #f #t (rmt:conn? (rmt:get-connection *rmt:remote* *toppath* ".db/main.db"))) (define *main* (rmt:get-connection *rmt:remote* *toppath* ".db/main.db")) -(test #f 'a (loop-test (rmt:conn-ipaddr *main*)(rmt:conn-port *main*) 'a)) +(for-each (lambda (tdat) + (test #f tdat (loop-test (rmt:conn-ipaddr *main*) + (rmt:conn-port *main*) tdat))) + (list 'a + '(a "b" 123 1.23 ))) +(test #f #f (rmt:send-receive 'ping #f 'hello)) (trace rmt:send-receive with-input-from-request rmt:get-connection with-input-from-request