Megatest

Check-in [18439ca550]
Login
Overview
Comment:Merged fork
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v1.6584-nanomsg
Files: files | file ages | folders
SHA1: 18439ca550c627795afeb35422b742f2d53148bc
User & Date: matt on 2021-11-15 15:05:13
Other Links: branch diff | manifest | tags
Context
2021-11-15
19:11
wip check-in: b2c735197b user: matt tags: v1.6584-nanomsg
15:05
Merged fork check-in: 18439ca550 user: matt tags: v1.6584-nanomsg
2021-11-14
15:33
Added -M to obj build to fix issue with dashboard not starting check-in: 39f1ace0d3 user: matt tags: v1.6584-nanomsg
2021-10-27
05:22
Cleaned up the example nng app check-in: 056cbbf3bc user: matt tags: v1.6584-nanomsg
Changes

Modified nng-trial/Makefile from [c83d590f9e] to [c9bb6fcc89].

1
2
3
4
5



nng-test : nng-test.scm
	csc nng-test.scm

test : nng-test
	./nng-test do-test








>
>
>
1
2
3
4
5
6
7
8
nng-test : nng-test.scm
	csc nng-test.scm

test : nng-test
	./nng-test do-test

clean :
	rm -f .runners/* NBFAKE*

Modified nng-trial/nng-test.scm from [1f5de0e9fe] to [a81f0cc6e1].




1


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

21
22
23
24
25
26
27



(import (chicken io)


	(chicken file)
	(chicken file posix)
        (chicken string)
	(chicken process-context)
	(chicken process-context posix)
        miscmacros
        nng
        srfi-18
	srfi-69
        test
	matchable
	typed-records
	system-information
	directory-utils
	)

(define help "Usage: nng-test COMMAND
  where COMMAND is one of:
    dotest    : run the basic req/rep test

")

(define address-tcp-1 "tcp://localhost:5555")
(define address-tcp-2 "tcp://localhost:6666")

(define address-inproc-1 "inproc://local1")
(define address-inproc-2 "inproc://local2")
>
>
>
|
>
>


















|
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
(module nng-test *
	
(import scheme
	(chicken io)
	(chicken base)
	(chicken time)
	(chicken file)
	(chicken file posix)
        (chicken string)
	(chicken process-context)
	(chicken process-context posix)
        miscmacros
        nng
        srfi-18
	srfi-69
        test
	matchable
	typed-records
	system-information
	directory-utils
	)

(define help "Usage: nng-test COMMAND
  where COMMAND is one of:
    do-test              : run the basic req/rep test
    run tcp://host:port  : start test server - start several in same dir
")

(define address-tcp-1 "tcp://localhost:5555")
(define address-tcp-2 "tcp://localhost:6666")

(define address-inproc-1 "inproc://local1")
(define address-inproc-2 "inproc://local2")
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
                    "message"
                    (req-rep-test address-tcp-1))
              (test "inproc req-rep"
                    "message"
                    (req-rep-test address-inproc-1)))
  (test-exit))

;; talking to self here...
;;
(define (send-n-messages n srvdat)
  (let* ((name (srv-name srvdat)))
    (let loop ((i 0))
      (if (< i n)
	  (begin
	    (nng-send (srv-req srvdat) (conc name "-" i))
	    (print "received: "(nng-recv (srv-rep srvdat)))
	    (loop (+ i 1)))))))

;; this should be run in a thread
(define (run-listener-responder socket myaddr)
  (let loop ((status 'running))
    (let* ((msg (nng-recv socket))
	   (response (process-message msg)))
      (if (not (eq? response 'done))
	  (begin







<
<
<
<
<
<
<
<
<
<
<







63
64
65
66
67
68
69











70
71
72
73
74
75
76
                    "message"
                    (req-rep-test address-tcp-1))
              (test "inproc req-rep"
                    "message"
                    (req-rep-test address-inproc-1)))
  (test-exit))












;; this should be run in a thread
(define (run-listener-responder socket myaddr)
  (let loop ((status 'running))
    (let* ((msg (nng-recv socket))
	   (response (process-message msg)))
      (if (not (eq? response 'done))
	  (begin
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127

128
129
130
131
132
133

134
135
136
137
138
139
140
141
142





143
144
145
146
147
148
149
150
151
152






153
	    'done
	    (conc msg " " (if count count 0)))))
     ((msg)
      (conc msg " 0"))
     (else
      "hello 0"))))

(define (close-srv srvdat)
  (nng-close! (srv-rep srvdat)))
    
(match
 (command-line-arguments)
 (("do-test")(do-test))
 ((run myaddr)
  ;; start listener
  ;; put myaddr into file by host-pid in .runners
  ;; for 1 minute
  ;;     get all in .runners
  ;;     call each with a message
  ;;

  (let* ((socket (make-listening-reply-socket myaddr))
	 (rfile  (conc ".runners/"(get-host-name)"-"(current-process-id)))
	 (th1    (make-thread (lambda ()
				(run-listener-responder socket myaddr)
				(delete-file* rfile)
				(exit))

		 "responder")))
    (if (not (and (file-exists? ".runners")
		  (directory? ".runners")))
	(create-directory ".runners" #t))
    (with-output-to-file rfile
      (lambda ()
	(print myaddr)))
    (thread-start! th1)
    (let loop ((entries '()))





      (if (null? entries)
	  (loop (glob ".runners/*"))
	  (let* ((entry (car entries))
		 (destaddr (with-input-from-file entry read-line)))
	    (call *channels* (conc "hello-from-"destaddr)  destaddr)
	    (thread-sleep! 0.25)
	    (loop (cdr entries)))))))
 ((cmd)(print "ERROR: command "cmd", not recognised.\n\n"help))
 (else
  (print help)))














|
<
<
|
|
|
|
|
|
|
|
|
|
>
|
|
|
|
<
<
>
|
|
|
|
|
|
|
|
|
>
>
>
>
>
|
|
|
|
|
|
|
|
|
|
>
>
>
>
>
>

103
104
105
106
107
108
109
110


111
112
113
114
115
116
117
118
119
120
121
122
123
124
125


126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
	    'done
	    (conc msg " " (if count count 0)))))
     ((msg)
      (conc msg " 0"))
     (else
      "hello 0"))))

(define (main)


  (match
   (command-line-arguments)
   (("do-test")(do-test))
   ((run myaddr)
    ;; start listener
    ;; put myaddr into file by host-pid in .runners
    ;; for 1 minute
    ;;     get all in .runners
    ;;     call each with a message
    ;;
    (let* ((endtimes (+ (current-seconds) 20)) ;; run for 20 seconds
	   (socket (make-listening-reply-socket myaddr))
	   (rfile  (conc ".runners/"(get-host-name)"-"(current-process-id)))
	   (th1    (make-thread (lambda ()
				  (run-listener-responder socket myaddr)


				  )
				"responder")))
      (if (not (and (file-exists? ".runners")
		    (directory? ".runners")))
	  (create-directory ".runners" #t))
      (with-output-to-file rfile
	(lambda ()
	  (print myaddr)))
      (thread-start! th1)
      (let loop ((entries '()))
	(if (> (current-seconds) endtimes)
	    (begin
	      (delete-file* rfile)
	      (sleep 1)
	      (exit))
	    (if (null? entries)
		(loop (glob ".runners/*"))
		(let* ((entry (car entries))
		       (destaddr (with-input-from-file entry read-line)))
		  (call *channels* (conc "hello-from-"destaddr)  destaddr)
		  ;; (thread-sleep! 0.025)
		  (loop (cdr entries))))))))
   ((cmd)(print "ERROR: command "cmd", not recognised.\n\n"help))
   (else
    (print help))))

) ;; end module

(import nng-test)
(main)