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
|
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
|
-
+
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
ok))
;; Do all the connection work, look up the transport type and set up the
;; connection if required.
;;
;; There are two scenarios.
;; 1. We are a test manager and we received *transport-type* and *runremote* via cmdline
;; 2. We are a run tests, list runs or other interactive process and we mush figure out
;; 2. We are a run tests, list runs or other interactive process and we must figure out
;; *transport-type* and *runremote* from the monitor.db
;;
;; client:setup
(define (client:setup #!key (numtries 3))
(if (not *toppath*)
(if (not (setup-for-run))
(begin
(debug:print 0 "ERROR: failed to find megatest.config, exiting")
(exit))))
(push-directory *toppath*) ;; This is probably NOT needed
(debug:print-info 11 "*transport-type* is " *transport-type* ", *runremote* is " *runremote*)
(let* ((hostinfo (if (not *transport-type*) ;; If we dont' already have transport type set then figure it out
(open-run-close tasks:get-best-server tasks:open-db)
(let* ((hostinfo (open-run-close tasks:get-best-server tasks:open-db)))
#f)))
;; if have hostinfo then extract the transport type
;; else fall back to fs
(debug:print-info 11 "CLIENT SETUP, hostinfo=" hostinfo)
(set! *transport-type* (if hostinfo
(string->symbol (tasks:hostinfo-get-transport hostinfo))
'fs))
;; ;; DEBUG STUFF
;; (if (eq? *transport-type* 'fs)(begin (print "ERROR!!!!!!! refusing to run with transport " *transport-type*)(exit 99)))
(debug:print-info 11 "Using transport type of " *transport-type* (if hostinfo (conc " to connect to " hostinfo) ""))
(case *transport-type*
((fs)(if (not *megatest-db*)(set! *megatest-db* (open-db))))
;; NB// Going back to enabling fs and possibly even make it the default.
;; ;; we are not doing fs any longer. let's cheat and start up a server
;; ;; if we are falling back on fs (not 100% supported) do an about face and start a server
;; (if (not (equal? (args:get-arg "-transport") "fs"))
;; (begin
;; (set! *transport-type* #f)
;; (system ;; (conc "megatest -list-servers | grep " (common:version-signature) " | grep alive || megatest -server - -daemonize && sleep 3"))
;; "megatest -server - -daemonize")
;; (thread-sleep! 1)
;; (if (> numtries 0)
;; (client:setup numtries: (- numtries 1))))))
((http)
(http-transport:client-connect (tasks:hostinfo-get-interface hostinfo)
(tasks:hostinfo-get-port hostinfo)))
((zmq)
(zmq-transport:client-connect (tasks:hostinfo-get-interface hostinfo)
(tasks:hostinfo-get-port hostinfo)
(tasks:hostinfo-get-pubport hostinfo)))
|