Megatest

Check-in [9579cb5f06]
Login
Overview
Comment:wip
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v2.0001
Files: files | file ages | folders
SHA1: 9579cb5f06d97822b87a6439ee58ed704248e6c6
User & Date: matt on 2022-01-02 18:44:14
Other Links: branch diff | manifest | tags
Context
2022-01-02
20:49
wip check-in: 844a9d0924 user: matt tags: v2.0001
18:44
wip check-in: 9579cb5f06 user: matt tags: v2.0001
18:09
wip, merged remotedat and servdat and put single copy in *db-serv-info* check-in: e7444b7d34 user: matt tags: v2.0001
Changes

Modified commonmod.scm from [787a13f0a3] to [4042487aab].

388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
*db-cache-path*
*db-with-db-mutex*
*db-api-call-time*
*no-sync-db*
*my-signature*
*transport-type*
*logged-in-clients*
*server-info*
*server-run*
*run-id*
*server-kind-run*
*home-host*
*heartbeat-mutex*
*api-process-request-count*
*max-api-process-requests*







<







388
389
390
391
392
393
394

395
396
397
398
399
400
401
*db-cache-path*
*db-with-db-mutex*
*db-api-call-time*
*no-sync-db*
*my-signature*
*transport-type*
*logged-in-clients*

*server-run*
*run-id*
*server-kind-run*
*home-host*
*heartbeat-mutex*
*api-process-request-count*
*max-api-process-requests*
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
(define *my-signature* #f)
(define *transport-type*    'http)             ;; override with [server] transport http|rpc|nmsg
;; replaced by *rmt:remote*
;; (define *runremote*         #f)                ;; if set up for server communication this will hold <host port>
;; (define *max-cache-size*    0)
(define *logged-in-clients* (make-hash-table))
;; (define *server-id*         #f)
(define *server-info*       #f)  ;; good candidate for easily convert to non-global
;; (define *time-to-exit*      #f)
(define *server-run*        #t)
(define *run-id*            #f)
(define *server-kind-run*   (make-hash-table))
(define *home-host*         #f)
;; (define *total-non-write-delay* 0)
(define *heartbeat-mutex*   (make-mutex))
(define *api-process-request-count* 0)







<
<







971
972
973
974
975
976
977


978
979
980
981
982
983
984
(define *my-signature* #f)
(define *transport-type*    'http)             ;; override with [server] transport http|rpc|nmsg
;; replaced by *rmt:remote*
;; (define *runremote*         #f)                ;; if set up for server communication this will hold <host port>
;; (define *max-cache-size*    0)
(define *logged-in-clients* (make-hash-table))
;; (define *server-id*         #f)


(define *server-run*        #t)
(define *run-id*            #f)
(define *server-kind-run*   (make-hash-table))
(define *home-host*         #f)
;; (define *total-non-write-delay* 0)
(define *heartbeat-mutex*   (make-mutex))
(define *api-process-request-count* 0)

Modified rmtmod.scm from [547f9cf5de] to [fb260a632c].

1636
1637
1638
1639
1640
1641
1642
1643

1644
1645
1646
1647
1648
1649

1650
1651
1652
1653
1654
1655
1656
1657

;; Main entry point to start a server. was start-server
(define (rmt:run hostn)
  ;;  ;; Configurations for server
  ;;  (tcp-buffer-size 2048)
  ;;  (max-connections 2048) 
  (debug:print 2 *default-log-port* "PID: "(current-process-id)". Attempting to start the server ...")
  (if *db-serv-info*

      (let* ((uconn (servdat-uconn *db-serv-info*)))
	(wait-and-close uconn))
      (let* ((port            (portlogger:open-run-close portlogger:find-port))
	     (handler-proc    (lambda (rem-host-port qrykey cmd params) ;;
				(api:execute-requests *dbstruct-db* cmd params))))
	;; (api:process-request *dbstuct-db* 

	(set! *db-serv-info* (make-servdat host: hostn port: port))
	(let* ((uconn (run-listener handler-proc port))
	       (rport (udat-port uconn))) ;; the real port
	  (servdat-host-set! *db-serv-info* hostn)
	  (servdat-port-set! *db-serv-info* rport)
	  (servdat-uconn-set! *db-serv-info* uconn)
	  (wait-and-close uconn)
	  (db:print-current-query-stats)







|
>






>
|







1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659

;; Main entry point to start a server. was start-server
(define (rmt:run hostn)
  ;;  ;; Configurations for server
  ;;  (tcp-buffer-size 2048)
  ;;  (max-connections 2048) 
  (debug:print 2 *default-log-port* "PID: "(current-process-id)". Attempting to start the server ...")
  (if (and *db-serv-info*
	   (servdat-uconn *db-serv-info*))
      (let* ((uconn (servdat-uconn *db-serv-info*)))
	(wait-and-close uconn))
      (let* ((port            (portlogger:open-run-close portlogger:find-port))
	     (handler-proc    (lambda (rem-host-port qrykey cmd params) ;;
				(api:execute-requests *dbstruct-db* cmd params))))
	;; (api:process-request *dbstuct-db* 
	(if (not *db-serv-info*)
	    (set! *db-serv-info* (make-servdat host: hostn port: port)))
	(let* ((uconn (run-listener handler-proc port))
	       (rport (udat-port uconn))) ;; the real port
	  (servdat-host-set! *db-serv-info* hostn)
	  (servdat-port-set! *db-serv-info* rport)
	  (servdat-uconn-set! *db-serv-info* uconn)
	  (wait-and-close uconn)
	  (db:print-current-query-stats)

Modified tests/unittests/basicserver.scm from [7731f5ea2b] to [621aa95c92].

43
44
45
46
47
48
49





50
51
52
53
54
55
56
57
58
59
60
61



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
 ;; rmt:find-main-server
 ;; get-all-server-pkts
 ;; get-viable-servers
 ;; get-best-candidate
 ;; api:run-server-process
 ;; rmt:run
 ;; rmt:try-start-server





 )

(test #f #t (servdat? (let ((s (make-servdat)))
			  (set! *servdat* s)
			  s)))
(test #f #f (rmt:get-conn *servdat* *toppath* ".db/main.db"))
(test #f #f (rmt:find-main-server *servdat* *toppath* ".db/main.db"))
(define th1 (make-thread (lambda ()
			   (rmt:run (get-host-name)))
			 "rmt:run thread"))
(thread-start! th1)
(thread-sleep! 0.5) ;; give things some time to get going



(test #f #t (ulex-listener? *server-info*))
(test #f #t (string? (udat-host-port *server-info*)))
(exit)
(test #f #t (server-ready? *server-info* (udat-host-port *server-info*)))
  
(test #f #t (rmt:open-main-connection *servdat* *toppath*))
;; (pp (hash-table->alist (remotedat-conns *servdat*)))
(test #f #t (conndat? (rmt:get-conn *servdat* *toppath* ".db/main.db")))
(exit)

(define *main*  (rmt:get-conn *servdat* *toppath* ".db/main.db"))

;; (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 #t (rmt:send-receive 'ping #f 'hello))

(define *db* (db:setup ".db/main.db"))

;; these let me cut and paste from source easily
(define apath *toppath*)
(define dbname ".db/2.db")
(define remote *servdat*)
(define keyvals  '(("SYSTEM" "a")("RELEASE" "b")))

(test #f '() (string->sexpr "()"))
(test #f 'server-started (api:execute-requests *db* 'get-server (list *toppath* ".db/2.db")))
(set! *dbstruct-db* #f)

(exit)







>
>
>
>
>












>
>
>
|
|
|
|

|
|
|


|













|







43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
 ;; rmt:find-main-server
 ;; get-all-server-pkts
 ;; get-viable-servers
 ;; get-best-candidate
 ;; api:run-server-process
 ;; rmt:run
 ;; rmt:try-start-server
 ;;
 ;; ulex
 ;;
 wait-and-close
 run-listener
 )

(test #f #t (servdat? (let ((s (make-servdat)))
			  (set! *servdat* s)
			  s)))
(test #f #f (rmt:get-conn *servdat* *toppath* ".db/main.db"))
(test #f #f (rmt:find-main-server *servdat* *toppath* ".db/main.db"))
(define th1 (make-thread (lambda ()
			   (rmt:run (get-host-name)))
			 "rmt:run thread"))
(thread-start! th1)
(thread-sleep! 0.5) ;; give things some time to get going
;; switch to *db-serv-info* instead of *servdat*
(define *uconn* (servdat-uconn *db-serv-info*))
(print "*uconn*: " *uconn*)
(test #f #t (ulex-listener? (servdat-uconn *db-serv-info*)))
(test #f #t (string? (udat-host-port *uconn*)))

(test #f #t (server-ready? *db-serv-dat* (udat-host-port *db-serv-dat*)))
  
(test #f #t (rmt:open-main-connection *db-serv-info* *toppath*))
;; (pp (hash-table->alist (remotedat-conns *db-serv-info*)))
(test #f #t (conndat? (rmt:get-conn *db-serv-info* *toppath* ".db/main.db")))
(exit)

(define *main*  (rmt:get-conn *db-serv-info* *toppath* ".db/main.db"))

;; (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 #t (rmt:send-receive 'ping #f 'hello))

(define *db* (db:setup ".db/main.db"))

;; these let me cut and paste from source easily
(define apath *toppath*)
(define dbname ".db/2.db")
(define remote *db-serv-info*)
(define keyvals  '(("SYSTEM" "a")("RELEASE" "b")))

(test #f '() (string->sexpr "()"))
(test #f 'server-started (api:execute-requests *db* 'get-server (list *toppath* ".db/2.db")))
(set! *dbstruct-db* #f)

(exit)