︙ | | | ︙ | |
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
(include "common_records.scm")
(include "key_records.scm")
(include "db_records.scm")
(include "megatest-fossil-hash.scm")
;; (use trace dot-locking)
;; (trace
;; thread-sleep!
;; sqlite3:execute
;; sqlite3:for-each-row
;; open-run-close
;; runs:can-run-more-tests
;; cdb:remote-run
;; nice-path
;; read-config
;; db:teststep-set-status!
;; tests:test-set-status!
;; cdb:test-set-status-state
;; cdb:client-call
;; tests:check-waiver-eligibility
;; tests:summarize-items
;; db:test-get-logfile-info
;; obtain-dot-lock
;; change-directory
;; cdb:remote-run
;; )
(define help (conc "
Megatest, documentation at http://www.kiatoa.com/fossils/megatest
version " megatest-version "
license GPL, Copyright Matt Welland 2006-2012
|
|
<
<
<
<
>
>
>
>
>
>
>
|
|
<
|
|
|
<
<
|
|
|
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
(include "common_records.scm")
(include "key_records.scm")
(include "db_records.scm")
(include "megatest-fossil-hash.scm")
;; (use trace dot-locking)
;; (trace
;; cdb:client-call
;; cdb:remote-run
;; cdb:test-set-status-state
;; change-directory
;; db:process-queue-item
;; db:test-get-logfile-info
;; db:teststep-set-status!
;; nice-path
;; obtain-dot-lock
;; open-run-close
;; read-config
;; runs:can-run-more-tests
;; sqlite3:execute
;; sqlite3:for-each-row
;; tests:check-waiver-eligibility
;; tests:summarize-items
;; tests:test-set-status!
;; thread-sleep!
;;)
(define help (conc "
Megatest, documentation at http://www.kiatoa.com/fossils/megatest
version " megatest-version "
license GPL, Copyright Matt Welland 2006-2012
|
︙ | | | ︙ | |
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
-setvars VAR1=val1,VAR2=val2 : Add environment variables to a run NB// these are
overwritten by values set in config files.
-server -|hostname : start the server (reduces contention on megatest.db), use
- to automatically figure out hostname
-transport http|zmq : use http or zmq for transport (default is http)
-daemonize : fork into background and disconnect from stdin/out
-list-servers : list the servers
-repl : start a repl (useful for extending megatest)
-load file.scm : load and run file.scm
Spreadsheet generation
-extract-ods fname.ods : extract an open document spreadsheet from the database
-pathmod path : insert path, i.e. path/runame/itempath/logfile.html
will clear the field if no rundir/testname/itempath/logfile
|
>
|
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
-setvars VAR1=val1,VAR2=val2 : Add environment variables to a run NB// these are
overwritten by values set in config files.
-server -|hostname : start the server (reduces contention on megatest.db), use
- to automatically figure out hostname
-transport http|zmq : use http or zmq for transport (default is http)
-daemonize : fork into background and disconnect from stdin/out
-list-servers : list the servers
-stop-server id : stop server specified by id (see output of -list-servers)
-repl : start a repl (useful for extending megatest)
-load file.scm : load and run file.scm
Spreadsheet generation
-extract-ods fname.ods : extract an open document spreadsheet from the database
-pathmod path : insert path, i.e. path/runame/itempath/logfile.html
will clear the field if no rundir/testname/itempath/logfile
|
︙ | | | ︙ | |
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
megatest -test-files 'logs/*.log' -target ubuntu/n%/no% :runname w49% -testpatt test_mt%
Called as " (string-intersperse (argv) " ") "
Version " megatest-version ", built from " megatest-fossil-hash ))
;; -gui : start a gui interface
;; -config fname : override the runconfig file with fname
;; -kill-server host:port|pid : kill server specified by host:port or pid
;; process args
(define remargs (args:get-args
(argv)
(list "-runtests" ;; run a specific test
"-config" ;; override the config file name
"-execute" ;; run the command encoded in the base64 parameter
|
<
|
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
megatest -test-files 'logs/*.log' -target ubuntu/n%/no% :runname w49% -testpatt test_mt%
Called as " (string-intersperse (argv) " ") "
Version " megatest-version ", built from " megatest-fossil-hash ))
;; -gui : start a gui interface
;; -config fname : override the runconfig file with fname
;; process args
(define remargs (args:get-args
(argv)
(list "-runtests" ;; run a specific test
"-config" ;; override the config file name
"-execute" ;; run the command encoded in the base64 parameter
|
︙ | | | ︙ | |
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
":value"
":expected"
":tol"
":units"
;; misc
"-server"
"-transport"
"-kill-server"
"-port"
"-extract-ods"
"-pathmod"
"-env2file"
"-setvars"
"-set-state-status"
"-debug" ;; for *verbosity* > 2
|
|
|
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
":value"
":expected"
":tol"
":units"
;; misc
"-server"
"-transport"
"-stop-server"
"-port"
"-extract-ods"
"-pathmod"
"-env2file"
"-setvars"
"-set-state-status"
"-debug" ;; for *verbosity* > 2
|
︙ | | | ︙ | |
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
|
;; (server:launch (string->symbol (args:get-arg "-transport" "http"))))
(system (conc (car (argv)) " -server - -daemonize -transport " (args:get-arg "-transport" "http")))
(thread-sleep! 3)) ;; give the server a few seconds to start
(debug:print 0 "INFO: Servers already running " servers)
)))))
(if (args:get-arg "-list-servers")
;; (args:get-arg "-kill-server"))
(let ((tl (setup-for-run)))
(if tl
(let ((servers (open-run-close tasks:get-all-servers tasks:open-db))
(fmtstr "~5a~8a~8a~20a~20a~10a~10a~10a~10a~10a\n")
(servers-to-kill '()))
(format #t fmtstr "Id" "MTver" "Pid" "Host" "Interface" "OutPort" "InPort" "LastBeat" "State" "Transport")
(format #t fmtstr "==" "=====" "===" "====" "=========" "=======" "======" "========" "=====" "=========")
(for-each
(lambda (server)
(let* (;; (killinfo (args:get-arg "-kill-server"))
;; (khost-port (if killinfo (if (substring-index ":" killinfo)(string-split ":") #f) #f))
;; (kpid (if killinfo (if (substring-index ":" killinfo) #f (string->number killinfo)) #f))
(id (vector-ref server 0))
(pid (vector-ref server 1))
(hostname (vector-ref server 2))
(interface (vector-ref server 3))
(pullport (vector-ref server 4))
(pubport (vector-ref server 5))
(start-time (vector-ref server 6))
(priority (vector-ref server 7))
|
|
|
|
|
|
>
>
>
<
<
<
|
|
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
|
;; (server:launch (string->symbol (args:get-arg "-transport" "http"))))
(system (conc (car (argv)) " -server - -daemonize -transport " (args:get-arg "-transport" "http")))
(thread-sleep! 3)) ;; give the server a few seconds to start
(debug:print 0 "INFO: Servers already running " servers)
)))))
(if (or (args:get-arg "-list-servers")
(args:get-arg "-stop-server"))
(let ((tl (setup-for-run)))
(if tl
(let* ((servers (open-run-close tasks:get-all-servers tasks:open-db))
(fmtstr "~5a~8a~8a~20a~20a~10a~10a~10a~10a~10a\n")
(servers-to-kill '())
(killinfo (args:get-arg "-stop-server"))
(khost-port (if killinfo (if (substring-index ":" killinfo)(string-split ":") #f) #f))
(sid (if killinfo (if (substring-index ":" killinfo) #f (string->number killinfo)) #f)))
(format #t fmtstr "Id" "MTver" "Pid" "Host" "Interface" "OutPort" "InPort" "LastBeat" "State" "Transport")
(format #t fmtstr "==" "=====" "===" "====" "=========" "=======" "======" "========" "=====" "=========")
(for-each
(lambda (server)
(let* ((id (vector-ref server 0))
(pid (vector-ref server 1))
(hostname (vector-ref server 2))
(interface (vector-ref server 3))
(pullport (vector-ref server 4))
(pubport (vector-ref server 5))
(start-time (vector-ref server 6))
(priority (vector-ref server 7))
|
︙ | | | ︙ | |
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
|
;; no need to login as status of #t indicates we are connecting to correct
;; server
(if (equal? state "dead")
(if (> last-update (* 25 60 60)) ;; keep records around for slighly over a day.
(open-run-close tasks:server-deregister tasks:open-db hostname pullport: pullport pid: pid action: 'delete))
(if (> last-update 20) ;; Mark as dead if not updated in last 20 seconds
(open-run-close tasks:server-deregister tasks:open-db hostname pullport: pullport pid: pid)))
(format #t fmtstr id mt-ver pid hostname interface pullport pubport last-update
(if status "alive" "dead") transport)))
servers)
(debug:print-info 1 "Done with listservers")
(set! *didsomething* #t)
(exit) ;; must do, would have to add checks to many/all calls below
)
(exit)))
;; if not list or kill then start a client (if appropriate)
|
<
|
>
>
>
>
|
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
|
;; no need to login as status of #t indicates we are connecting to correct
;; server
(if (equal? state "dead")
(if (> last-update (* 25 60 60)) ;; keep records around for slighly over a day.
(open-run-close tasks:server-deregister tasks:open-db hostname pullport: pullport pid: pid action: 'delete))
(if (> last-update 20) ;; Mark as dead if not updated in last 20 seconds
(open-run-close tasks:server-deregister tasks:open-db hostname pullport: pullport pid: pid)))
(format #t fmtstr id mt-ver pid hostname interface pullport pubport last-update
(if status "alive" "dead") transport)
(if (equal? id sid)
(begin
(debug:print-info 0 "Attempting to stop server with pid " pid)
(tasks:kill-server status hostname pullport pid transport)))))
servers)
(debug:print-info 1 "Done with listservers")
(set! *didsomething* #t)
(exit) ;; must do, would have to add checks to many/all calls below
)
(exit)))
;; if not list or kill then start a client (if appropriate)
|
︙ | | | ︙ | |