Changes In Branch v1.65-multi-db Excluding Merge-Ins
This is equivalent to a diff from b5a0ecc65a to adbeb66c05
2019-02-09
| ||
20:55 | progress Leaf check-in: adbeb66c05 user: matt tags: v1.65-multi-db | |
2019-02-07
| ||
10:19 | Tidy up of mtut formating check-in: e52f8b2513 user: matt tags: v1.65-multi-db | |
2019-02-02
| ||
19:31 | Merged v1.65 changes Leaf check-in: 1d106be172 user: matt tags: v1.65-intra-waiton | |
06:00 | Updated portlogger to check on the port availability check-in: 60b0f467ff user: matt tags: v1.65-multi-db | |
2019-01-28
| ||
09:42 | Moved boxes w/2 and h/2 in flow view. check-in: b5a0ecc65a user: mrwellan tags: v1.65-intra-waiton, v1.6521 | |
2019-01-27
| ||
13:49 | Merged in handy changes from v1.65 check-in: 1254c88236 user: matt tags: v1.65-intra-waiton | |
Modified Makefile from [8e9ef04054] to [28c4911343].
︙ | ︙ | |||
18 19 20 21 22 23 24 | # make install CSCOPTS='-accumulate-profile -profile-name $(PWD)/profile-ww$(shell date +%V.%u)' # rm <files>.o ; make install CSCOPTS='-profile' ; ... ; chicken-profile | less SHELL=/bin/bash PREFIX=$(PWD) CSCOPTS= INSTALL=install SRCFILES = common.scm items.scm launch.scm \ | | | | | | | > > > > | 18 19 20 21 22 23 24 25 26 27 28 29 30 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 | # make install CSCOPTS='-accumulate-profile -profile-name $(PWD)/profile-ww$(shell date +%V.%u)' # rm <files>.o ; make install CSCOPTS='-profile' ; ... ; chicken-profile | less SHELL=/bin/bash PREFIX=$(PWD) CSCOPTS= INSTALL=install SRCFILES = common.scm items.scm launch.scm \ ods.scm runconfig.scm configf.scm \ keys.scm margs.scm server.o megatest-version.scm \ process.scm runs.scm tasks.scm tests.scm genexample.scm \ http-transport.scm filedb.scm tdb.scm \ client.scm mt.scm \ ezsteps.scm lock-queue.scm \ rmt.scm subrun.scm \ archive.scm env.scm diff-report.scm cgisetup/models/pgdb.scm # module source files MSRCFILES = ftail.scm portlogger.scm nmsg-transport.scm db.scm api.scm # files needed for mtserve MTSERVEFILES = common.scm megatest-version.scm margs.scm server.scm keys.scm ods.scm rmt.scm # Eggs to install (straightforward ones) EGGS=matchable readline apropos base64 regex-literals format regex-case test coops trace csv \ dot-locking posix-utils posix-extras directory-utils hostinfo tcp-server rpc csv-xml fmt \ json md5 awful http-client spiffy uri-common intarweb spiffy-request-vars \ spiffy-directory-listing ssax sxml-serializer sxml-modifications iup canvas-draw sqlite3 GUISRCF = dashboard-context-menu.scm dashboard-tests.scm dashboard-guimonitor.scm gutils.scm dcommon.scm tree.scm vg.scm OFILES = $(SRCFILES:%.scm=%.o) GOFILES = $(GUISRCF:%.scm=%.o) MTSERVEOFILES = $(MTSERVEFILES:%.scm=%.o) MOFILES = $(addprefix mofiles/,$(MSRCFILES:%.scm=%.o)) mofiles/%.o : %.scm mkdir -p mofiles csc $(CSCOPTS) -J -c $< -o mofiles/$*.o |
︙ | ︙ | |||
66 67 68 69 70 71 72 | # BASH_MACHTYPE=$(shell bash -c "echo \$$MACHTYPE") # ARCHSTR=$(BASH_MACHTYPE)_$(shell lsb_release -sr) ARCHSTR=$(shell if [[ -e /usr/bin/sw_vers ]]; then /usr/bin/sw_vers -productVersion; else lsb_release -sr; fi) # ARCHSTR=$(shell bash -c "echo \$$MACHTYPE") PNGFILES = $(shell cd docs/manual;ls *png) | < | | > > > | | < < < < | > > > > | | | 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 102 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 | # BASH_MACHTYPE=$(shell bash -c "echo \$$MACHTYPE") # ARCHSTR=$(BASH_MACHTYPE)_$(shell lsb_release -sr) ARCHSTR=$(shell if [[ -e /usr/bin/sw_vers ]]; then /usr/bin/sw_vers -productVersion; else lsb_release -sr; fi) # ARCHSTR=$(shell bash -c "echo \$$MACHTYPE") PNGFILES = $(shell cd docs/manual;ls *png) all : $(PREFIX)/bin/.$(ARCHSTR) mtest dboard mtut mtserve mtest: $(OFILES) readline-fix.scm megatest.o $(MOFILES) csc $(CSCOPTS) $(OFILES) $(MOFILES) megatest.o -o mtest mtserve: $(MTSERVEOFILES) readline-fix.scm mtserve.o $(MOFILES) csc $(CSCOPTS) $(MTSERVEOFILES) $(MOFILES) mtserve.o -o mtserve showmtesthash: @echo $(MTESTHASH) dboard : $(OFILES) $(GOFILES) dashboard.scm $(MOFILES) csc $(CSCOPTS) $(OFILES) dashboard.scm $(GOFILES) $(MOFILES) -o dboard ndboard : newdashboard.scm $(OFILES) $(GOFILES) csc $(CSCOPTS) $(OFILES) $(GOFILES) newdashboard.scm -o ndboard mtut: $(OFILES) megatest-fossil-hash.scm mtut.scm $(MOFILES) csc $(CSCOPTS) $(OFILES) $(MOFILES) mtut.scm -o mtut TCMTOBJS = \ archive.o \ cgisetup/models/pgdb.o \ client.o \ common.o \ configf.o \ env.o \ http-transport.o \ items.o \ keys.o \ launch.o \ lock-queue.o \ margs.o \ mt.o \ megatest-version.o \ ods.o \ process.o \ rmt.o \ runconfig.o \ runs.o \ server.o \ tasks.o \ tdb.o \ tests.o \ subrun.o \ # api.o \ # db.o \ # rpc-transport.o \ # portlogger.o \ tcmt : $(TCMTOBJS) tcmt.scm $(MOFILES) csc $(CSCOPTS) $(TCMTOBJS) $(MOFILES) tcmt.scm -o tcmt # install documentation to $(PREFIX)/docs # DOES NOT REBUILD DOCS # $(PREFIX)/share/docs/megatest_manual.html : docs/manual/megatest_manual.html mkdir -p $(PREFIX)/share/docs $(INSTALL) docs/manual/megatest_manual.html $(PREFIX)/share/docs/megatest_manual.html |
︙ | ︙ | |||
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | tests.o tasks.o dashboard-tasks.o : task_records.scm runs.o : test_records.scm megatest.o : megatest-fossil-hash.scm rmt.scm client.scm common.scm configf.scm dashboard-guimonitor.scm dashboard-tests.scm dashboard.scm db.scm dcommon.scm ezsteps.scm fs-transport.scm http-transport.scm index-tree.scm items.scm keys.scm launch.scm megatest.scm monitor.scm mt.scm newdashboard.scm runconfig.scm runs.scm server.scm tdb.scm tests.scm tree.scm : common_records.scm common_records.scm : altdb.scm vg.o dashboard.o : vg_records.scm dcommon.o : run_records.scm # Temporary while transitioning to new routine # runs.o : run-tests-queue-classic.scm run-tests-queue-new.scm megatest-fossil-hash.scm : $(SRCFILES) megatest.scm *_records.scm echo "(define megatest-fossil-hash \"$(MTESTHASH)\")" > megatest-fossil-hash.new if ! diff -q megatest-fossil-hash.new megatest-fossil-hash.scm ; then echo copying .new to .scm;cp -f megatest-fossil-hash.new megatest-fossil-hash.scm;fi $(OFILES) $(GOFILES) : common_records.scm | > > > > > | | > > > > > > > > > > > > > | 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | tests.o tasks.o dashboard-tasks.o : task_records.scm runs.o : test_records.scm megatest.o : megatest-fossil-hash.scm rmt.scm client.scm common.scm configf.scm dashboard-guimonitor.scm dashboard-tests.scm dashboard.scm db.scm dcommon.scm ezsteps.scm fs-transport.scm http-transport.scm index-tree.scm items.scm keys.scm launch.scm megatest.scm monitor.scm mt.scm newdashboard.scm runconfig.scm runs.scm server.scm tdb.scm tests.scm tree.scm : common_records.scm common_records.scm : altdb.scm vg.o dashboard.o : vg_records.scm dcommon.o : run_records.scm # module deps http-transport.o : mofiles/portlogger.o megatest.o rnt.o : mofiles/nmsg-transport.o # Temporary while transitioning to new routine # runs.o : run-tests-queue-classic.scm run-tests-queue-new.scm megatest-fossil-hash.scm : $(SRCFILES) megatest.scm *_records.scm echo "(define megatest-fossil-hash \"$(MTESTHASH)\")" > megatest-fossil-hash.new if ! diff -q megatest-fossil-hash.new megatest-fossil-hash.scm ; then echo copying .new to .scm;cp -f megatest-fossil-hash.new megatest-fossil-hash.scm;fi $(OFILES) $(GOFILES) : common_records.scm # %.o : %.scm $(MOFILES) # csc $(CSCOPTS) -c $< $(MOFILES) %.o : %.scm csc $(CSCOPTS) -c $< $(PREFIX)/bin/.$(ARCHSTR)/mtest : mtest utils/mk_wrapper @echo Installing to PREFIX=$(PREFIX) $(INSTALL) mtest $(PREFIX)/bin/.$(ARCHSTR)/mtest utils/mk_wrapper $(PREFIX) mtest $(PREFIX)/bin/megatest chmod a+x $(PREFIX)/bin/megatest $(PREFIX)/bin/.$(ARCHSTR)/mtserve : mtserve utils/mk_wrapper @echo Installing to PREFIX=$(PREFIX) $(INSTALL) mtserve $(PREFIX)/bin/.$(ARCHSTR)/mtserve utils/mk_wrapper $(PREFIX) mtserve $(PREFIX)/bin/mtserver chmod a+x $(PREFIX)/bin/mtserver $(PREFIX)/bin/mtserver : $(PREFIX)/bin/.$(ARCHSTR)/mtserve utils/mk_wrapper utils/mk_wrapper $(PREFIX) mtserve $(PREFIX)/bin/mtserver chmod a+x $(PREFIX)/bin/mtserver $(PREFIX)/bin/.$(ARCHSTR)/ndboard : ndboard $(INSTALL) ndboard $(PREFIX)/bin/.$(ARCHSTR)/ndboard $(PREFIX)/bin/newdashboard : $(PREFIX)/bin/.$(ARCHSTR)/ndboard utils/mk_wrapper utils/mk_wrapper $(PREFIX) ndboard $(PREFIX)/bin/newdashboard chmod a+x $(PREFIX)/bin/newdashboard |
︙ | ︙ | |||
276 277 278 279 280 281 282 | $(PREFIX)/bin/.$(ARCHSTR)/dboard : dboard $(FILES) utils/mk_wrapper utils/mk_wrapper $(PREFIX) dboard $(PREFIX)/bin/dashboard chmod a+x $(PREFIX)/bin/dashboard $(INSTALL) dboard $(PREFIX)/bin/.$(ARCHSTR)/dboard install : $(PREFIX)/bin/.$(ARCHSTR) $(PREFIX)/bin/.$(ARCHSTR)/mtest $(PREFIX)/bin/megatest \ $(PREFIX)/bin/.$(ARCHSTR)/dboard $(PREFIX)/bin/dashboard $(HELPERS) $(PREFIX)/bin/nbfake \ | | | 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 | $(PREFIX)/bin/.$(ARCHSTR)/dboard : dboard $(FILES) utils/mk_wrapper utils/mk_wrapper $(PREFIX) dboard $(PREFIX)/bin/dashboard chmod a+x $(PREFIX)/bin/dashboard $(INSTALL) dboard $(PREFIX)/bin/.$(ARCHSTR)/dboard install : $(PREFIX)/bin/.$(ARCHSTR) $(PREFIX)/bin/.$(ARCHSTR)/mtest $(PREFIX)/bin/megatest \ $(PREFIX)/bin/.$(ARCHSTR)/dboard $(PREFIX)/bin/dashboard $(HELPERS) $(PREFIX)/bin/nbfake \ $(PREFIX)/bin/serialize-env $(PREFIX)/bin/mtserver \ $(PREFIX)/bin/nbfind $(PREFIX)/bin/loadrunner $(PREFIX)/bin/viewscreen $(PREFIX)/bin/mt_xterm \ $(PREFIX)/share/docs/megatest_manual.html $(PREFIX)/bin/remrun \ $(PREFIX)/share/docs/megatest_manual.html $(PREFIX)/bin/remrun $(PREFIX)/bin/mtutil \ $(PREFIX)/bin/tcmt $(PREFIX)/share/db/mt-pg.sql \ $(PREFIX)/share/js/jquery-3.1.0.slim.min.js # $(PREFIX)/bin/.$(ARCHSTR)/ndboard |
︙ | ︙ | |||
301 302 303 304 305 306 307 | mkdir -p ext-tests cd ext-tests;fossil open --nested $(MTQA_FOSSIL) $(MTQA_FOSSIL) : fossil clone https://www.kiatoa.com/fossils/megatest_qa $(MTQA_FOSSIL) clean : | | | 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 | mkdir -p ext-tests cd ext-tests;fossil open --nested $(MTQA_FOSSIL) $(MTQA_FOSSIL) : fossil clone https://www.kiatoa.com/fossils/megatest_qa $(MTQA_FOSSIL) clean : rm -f $(OFILES) $(GOFILES) $(MOFILES) $(TCMTOBJS) $(PREFIX)/megatest $(PREFIX)/dashboard mtest mtutil dboard dboard.o megatest.o dashboard.o megatest-fossil-hash.* altdb.scm mofiles/*.o vg.o *import.scm #====================================================================== # Make the records files #====================================================================== # vg_records.scm : records.sh # ./records.sh |
︙ | ︙ | |||
400 401 402 403 404 405 406 | if csi -ne '(use mysql-client)';then \ echo "(use mysql-client)(hash-table-set! *available-db* 'mysql #t)" >> altdb.scm; \ fi if csi -ne '(use postgresql)';then \ echo "(use postgresql)(hash-table-set! *available-db* 'postgresql #t)" >> altdb.scm;\ fi | | | | 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 | if csi -ne '(use mysql-client)';then \ echo "(use mysql-client)(hash-table-set! *available-db* 'mysql #t)" >> altdb.scm; \ fi if csi -ne '(use postgresql)';then \ echo "(use postgresql)(hash-table-set! *available-db* 'postgresql #t)" >> altdb.scm;\ fi portlogger-example : portlogger-example.scm portlogger.o csc $(CSCOPTS) portlogger-example.scm portlogger.o # create a pdf dot graphviz diagram from notations in rmt.scm rmt.pdf : rmt.scm grep ';;DOT' rmt.scm | sed -e 's/.*;;DOT //' > rmt.dot;dot -Tpdf rmt.dot -o rmt.pdf buildmanual: cd docs/manual && make |
︙ | ︙ |
Modified api.scm from [1541791de9] to [b22a7f13c0].
︙ | ︙ | |||
14 15 16 17 18 19 20 | ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with Megatest. If not, see <http://www.gnu.org/licenses/>. ;; ;;====================================================================== | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < | < < < | < < < < < < < < < | < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < | < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with Megatest. If not, see <http://www.gnu.org/licenses/>. ;; ;;====================================================================== (declare (unit api)) (module api ( * ) (import scheme posix chicken data-structures ports) (define (api:execute-requests . args) #t) (define (api:process-request . args) #t) ) |
Modified client.scm from [3b6119f752] to [58115c88ed].
︙ | ︙ | |||
29 30 31 32 33 34 35 | (declare (uses common)) (declare (uses db)) (declare (uses tasks)) ;; tasks are where stuff is maintained about what is running. (include "common_records.scm") (include "db_records.scm") | < < < < < < < | | | | | | | | < | | | | > > | | < | | | > > | | | | | | | | | | | > | < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 29 30 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 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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | (declare (uses common)) (declare (uses db)) (declare (uses tasks)) ;; tasks are where stuff is maintained about what is running. (include "common_records.scm") (include "db_records.scm") ;; ;; Not currently used! But, I think it *should* be used!!! ;; (define (client:logout serverdat) ;; (let ((ok (and (socket? serverdat) ;; (cdb:logout serverdat *toppath* (client:get-signature))))) ;; ok)) ;; ;; (define (client:connect iface port) ;; (case (server:get-transport) ;; ((http) (http:client-connect iface port)) ;; ((zmq) (zmq:client-connect iface port)) ;; (else (begin ;; (debug:print 0 *default-log-port* "ERROR: no such transport " (server:get-transport) ", exiting now.") ;; (exit 1))))) ;; ;; (define (client:setup areapath #!key (remaining-tries 100) (failed-connects 0)) ;; (case (server:get-transport) ;; ((http)(client:setup-http areapath remaining-tries: remaining-tries failed-connects: failed-connects)) ;; (else (begin ;; (debug:print 0 *default-log-port* "ERROR: no such transport " (server:get-transport) ", exiting now.") ;; (exit 1))))) ;; ;; ;; 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 must figure out ;; ;; *transport-type* and *runremote* from the monitor.db ;; ;; ;; ;; client:setup ;; ;; ;; ;; lookup_server, need to remove *runremote* stuff ;; ;; ;; ;; (define (client:setup-http areapath #!key (remaining-tries 100) (failed-connects 0)(area-dat #f)) ;; (debug:print-info 2 *default-log-port* "client:setup remaining-tries=" remaining-tries) ;; (server:start-and-wait areapath) ;; (if (<= remaining-tries 0) ;; (begin ;; (debug:print-error 0 *default-log-port* "failed to start or connect to server") ;; (exit 1)) ;; ;; ;; ;; Alternatively here, we can get the list of candidate servers and work our way ;; ;; through them searching for a good one. ;; ;; ;; (let* ((server-dat (server:get-rand-best areapath)) ;; (server:get-first-best areapath)) ;; (runremote (or area-dat *runremote*))) ;; (if (not server-dat) ;; no server found ;; (client:setup-http areapath remaining-tries: (- remaining-tries 1)) ;; (let ((host (cadr server-dat)) ;; (port (caddr server-dat))) ;; (debug:print-info 4 *default-log-port* "client:setup server-dat=" server-dat ", remaining-tries=" remaining-tries) ;; (if (and (not area-dat) ;; (not *runremote*)) ;; (set! *runremote* (make-remote))) ;; (if (and host port) ;; (let* ((start-res (case *transport-type* ;; ((http)(http-transport:client-connect host port)))) ;; (ping-res (case *transport-type* ;; ((http)(rmt:login-no-auto-client-setup start-res))))) ;; (if (and start-res ;; ping-res) ;; (let ((runremote (or area-dat *runremote*))) ;; it might have been generated only a few statements ago ;; (remote-conndat-set! runremote start-res) ;; (hash-table-set! runremote run-id start-res) ;; (debug:print-info 2 *default-log-port* "connected to " (http-transport:server-dat-make-url start-res)) ;; start-res) ;; (begin ;; login failed but have a server record, clean out the record and try again ;; (debug:print-info 0 *default-log-port* "client:setup, login failed, will attempt to start server ... start-res=" start-res ", server-dat=" server-dat) ;; had runid. Fixes part of Randy;s ticket 1405717332 ;; (case *transport-type* ;; ((http)(http-transport:close-connections))) ;; (remote-conndat-set! runremote #f) ;; (hash-table-delete! runremote run-id) ;; (thread-sleep! 1) ;; (client:setup-http areapath remaining-tries: (- remaining-tries 1)) ;; ))) ;; (begin ;; no server registered ;; ;; (server:kind-run areapath) ;; (server:start-and-wait areapath) ;; (debug:print-info 0 *default-log-port* "client:setup, no server registered, remaining-tries=" remaining-tries) ;; (thread-sleep! 1) ;; (+ 5 (random (- 20 remaining-tries)))) ;; give server a little time to start up, randomize a little to avoid start storms. ;; (client:setup-http areapath remaining-tries: (- remaining-tries 1))))))))) ;; |
Modified common.scm from [f3a824a935] to [04f4dea505].
︙ | ︙ | |||
1133 1134 1135 1136 1137 1138 1139 | (conc (getenv "MT_TEST_NAME") "/" (getenv "MT_ITEMPATH"))) #f)) ;; logic for getting homehost. Returns (host . at-home) ;; IF *toppath* is not set, wait up to five seconds trying every two seconds ;; (this is to accomodate the watchdog) ;; | | | 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 | (conc (getenv "MT_TEST_NAME") "/" (getenv "MT_ITEMPATH"))) #f)) ;; logic for getting homehost. Returns (host . at-home) ;; IF *toppath* is not set, wait up to five seconds trying every two seconds ;; (this is to accomodate the watchdog) ;; #;(define (common:get-homehost #!key (trynum 5)) ;; called often especially at start up. use mutex to eliminate collisions (mutex-lock! *homehost-mutex*) (cond (*home-host* (mutex-unlock! *homehost-mutex*) *home-host*) ((not *toppath*) |
︙ | ︙ | |||
1185 1186 1187 1188 1189 1190 1191 | (equal? homehost bestadrs)))) (set! *home-host* (cons homehost at-home)) (mutex-unlock! *homehost-mutex*) *home-host*)))) ;; am I on the homehost? ;; | | | 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 | (equal? homehost bestadrs)))) (set! *home-host* (cons homehost at-home)) (mutex-unlock! *homehost-mutex*) *home-host*)))) ;; am I on the homehost? ;; #;(define (common:on-homehost?) (let ((hh (common:get-homehost))) (if hh (cdr hh) #f))) ;; do we honor the caches of the config files? ;; |
︙ | ︙ |
Modified db.scm from [decb5b7df2] to [7f1125265b].
︙ | ︙ | |||
20 21 22 23 24 25 26 | ;;====================================================================== ;; Database access ;;====================================================================== ;; dbstruct vector containing all the relevant dbs like main.db, megatest.db, run.db etc | < < < < < | < < < | | < | < < | | > | > > > > | | < < < | < < | | | | | | > > > > > | < < < | | | | | < < < | < < < | < < | < < < < < | < < | | < | > > > | < < | < < < < | < < < < < < < | < < < < < | > | > > | < | > | > > | < < < > > > > | | | < < | | > | | | < < > | < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < | < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < | | | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < | < < < < < < | < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < | < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | | | | | | | | | | | | | | | | | | | > > | < | | | | < < < < | | 20 21 22 23 24 25 26 27 28 29 30 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 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 102 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 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | ;;====================================================================== ;; Database access ;;====================================================================== ;; dbstruct vector containing all the relevant dbs like main.db, megatest.db, run.db etc (declare (unit db)) (module db ( db:setup ) (import scheme posix chicken data-structures ports) (use (prefix sqlite3 sqlite3:) (srfi 18) extras tcp stack srfi-1 posix regex regex-case srfi-69 csv-xml s11n md5 message-digest base64 format dot-locking z3 typed-records matchable (prefix base64 base64:)) ;;====================================================================== ;; ;;====================================================================== (defstruct dbinfo (mtrah #f) (dbpath #f) (maindb #f) (dbfile #f) (writeable #f) (rundbs (make-hash-table)) ;; id => #(dbhandle readq writeq) (stats (make-hash-table)) (mreadq (make-queue)) ;; read queue for main.db (mwriteq (make-queue)) ;; write queue for main.db (localq (make-queue)) ;; queue for cpuload, numcores and other OS requests (respq (make-queue)) ;; queue for responses ) (defstruct rundbinfo (rundb #f) ;; db handle (dbfile #f) (readq (make-queue)) (writeq (make-queue)) (sdbcache (make-hash-table)) ;; cache the id => strings as we read them (stats (make-hash-table)) ) (defstruct request (srchost #f) (srcport #f) (reqtype #f) ;; read, write, local (response #f) (status 'new) (start (current-milliseconds))) ;; create a dbinfo record initialized to a specific Megatest area ;; (define (db:create-dbinfo mtrah) (make-dbinfo mtrah: mtrah dbpath: (conc mtrah "/.mtdb"))) (define (db:get-open-db dbinfo run-id #!key (dbpath #f)) (let* ((dbpath (dbinfo-dbpath dbinfo)) (ismain (if (number? run-id) #f #t)) (dbname (if run-id (conc run-id ".db") "main.db")) ;; can use string for run-id (dbfile (conc dbpath "/" dbname)) (dbexists (file-exists? dbfile)) (readable (file-read-access? dbpath)) ;; should be safe to assume can read db file (writeable (file-write-access? dbpath))) ;; handle error conditions (cond ((and (not dbexists) (not writeable))(values #f "No db file and no write access")) ((not readable) (values #f "No read access")) (else ;; TODO - transfer over the error handling from MT1.65 db:lock-create-open (let ((db (sqlite3:open-database dbfile))) (if (not dbexists)(db:initialize-db db)) ;; now deal with the added structure for run-id based db if needed (if ismain (begin (dbinfo-maindb-set! dbinfo db) (dbinfo-writeable-set! dbinfo writeable)) (let ((runrec (or (hash-table-ref/default (dbinfo-rundbs dbinfo) run-id (make-rundbinfo rundb: db dbfile: dbfile))))) (hash-table-set! (dbinfo-rundbs dbinfo) run-id runrec))) (values #t "Success")))))) ;; dbinfo must have been initiatized with the dbpath ;; #;(define (db:with-db dbinfo run-id proc . params) (let* ((db (db:get-open-db dbinfo run-id)) (use-mutex (> *api-process-request-count* 25))) (if (and use-mutex (common:low-noise-print 120 "over-50-parallel-api-requests")) (debug:print-info 0 *default-log-port* *api-process-request-count* " parallel api requests being processed in process " (current-process-id) ", throttling access")) (if (common:low-noise-print 600 (conc "parallel-api-requests" *max-api-process-requests*)) (debug:print-info 2 *default-log-port* "Parallel api request count: " *api-process-request-count* " max parallel requests: " *max-api-process-requests*)) (handle-exceptions exn (begin (print-call-chain (current-error-port)) (debug:print-error 0 *default-log-port* "sqlite3 issue in db:with-db, dbstruct=" dbstruct ", run-id=" run-id ", proc=" proc ", params=" params " error: " ((condition-property-accessor 'exn 'message) exn)) ;; there is no recovering at this time. exit (exit 50)) (if use-mutex (mutex-lock! *db-with-db-mutex*)) (let ((res (apply proc db params))) (if use-mutex (mutex-unlock! *db-with-db-mutex*)) ;; (if (vector? dbstruct)(db:done-with dbstruct run-id r/w)) (if dbdat (stack-push! (dbr:dbstruct-dbstack dbstruct) dbdat)) res)))) (define (db:initialize-db db) (sqlite3:with-transaction db (lambda () (sqlite3:execute db "CREATE TABLE IF NOT EXISTS ttype ( id SERIAL PRIMARY KEY, target_spec TEXT DEFAULT '');") (sqlite3:execute db "CREATE TABLE IF NOT EXISTS runs ( id INTEGER PRIMARY KEY, target TEXT DEFAULT 'nodata', ttype_id INTEGER DEFAULT 0, run_name TEXT DEFAULT 'norun', contour TEXT DEFAULT '', state TEXT DEFAULT '', status TEXT DEFAULT '', owner TEXT DEFAULT '', event_time TIMESTAMP DEFAULT (strftime('%s','now')), comment TEXT DEFAULT '', fail_count INTEGER DEFAULT 0, pass_count INTEGER DEFAULT 0, last_update INTEGER DEFAULT (strftime('%s','now')), CONSTRAINT runsconstraint UNIQUE (target,ttype_id,run_name, area_id));") (sqlite3:execute db "CREATE TRIGGER IF NOT EXISTS update_runs_trigger AFTER UPDATE ON runs FOR EACH ROW BEGIN UPDATE runs SET last_update=(strftime('%s','now')) WHERE id=old.id; END;") (sqlite3:execute db "CREATE TABLE IF NOT EXISTS run_stats ( id INTEGER PRIMARY KEY, run_id INTEGER, state TEXT, status TEXT, count INTEGER, last_update INTEGER DEFAULT (strftime('%s','now')))") (sqlite3:execute db "CREATE TRIGGER IF NOT EXISTS update_run_stats_trigger AFTER UPDATE ON run_stats FOR EACH ROW BEGIN UPDATE run_stats SET last_update=(strftime('%s','now')) WHERE id=old.id; END;") (sqlite3:execute db "CREATE TABLE IF NOT EXISTS test_meta ( id INTEGER PRIMARY KEY, testname TEXT DEFAULT '', author TEXT DEFAULT '', owner TEXT DEFAULT '', description TEXT DEFAULT '', reviewed TIMESTAMP, iterated TEXT DEFAULT '', avg_runtime REAL, avg_disk REAL, tags TEXT DEFAULT '', jobgroup TEXT DEFAULT 'default', CONSTRAINT test_meta_constraint UNIQUE (testname));") (sqlite3:execute db "CREATE TABLE IF NOT EXISTS tasks_queue (id INTEGER PRIMARY KEY, action TEXT DEFAULT '', owner TEXT, state TEXT DEFAULT 'new', target TEXT DEFAULT '', name TEXT DEFAULT '', testpatt TEXT DEFAULT '', keylock TEXT, params TEXT, creation_time TIMESTAMP DEFAULT (strftime('%s','now')), execution_time TIMESTAMP);") ;; archive disk areas, cached info from [archive-disks] (sqlite3:execute db "CREATE TABLE IF NOT EXISTS archive_disks ( id INTEGER PRIMARY KEY, archive_area_name TEXT, disk_path TEXT, last_df INTEGER DEFAULT -1, last_df_time TIMESTAMP DEFAULT (strftime('%s','now')), creation_time TIMESTAMP DEFAULT (strftime('%','now')));") ;; individual bup (or tar) data chunks (sqlite3:execute db "CREATE TABLE IF NOT EXISTS archive_blocks ( id INTEGER PRIMARY KEY, archive_disk_id INTEGER, disk_path TEXT, last_du INTEGER DEFAULT -1, last_du_time TIMESTAMP DEFAULT (strftime('%s','now')), creation_time TIMESTAMP DEFAULT (strftime('%','now')));") ;; tests allocated to what chunks. reusing a chunk for a test/item_path is very efficient ;; NB// the per run/test recording of where the archive is stored is done in the test ;; record. (sqlite3:execute db "CREATE TABLE IF NOT EXISTS archive_allocations ( id INTEGER PRIMARY KEY, archive_block_id INTEGER, testname TEXT, item_path TEXT, creation_time TIMESTAMP DEFAULT (strftime('%','now')));") ;; move this clean up call somewhere else (sqlite3:execute db "DELETE FROM tasks_queue WHERE state='done' AND creation_time < ?;" (- (current-seconds)(* 24 60 60))) ;; remove older than 24 hrs (sqlite3:execute db (conc "CREATE INDEX IF NOT EXISTS runs_index ON runs (runname);")) ;; (if havekeys "," "") keystr ");")) ;; (sqlite3:execute db "CREATE VIEW runs_tests AS SELECT * FROM runs INNER JOIN tests ON runs.id=tests.run_id;") (sqlite3:execute db "CREATE TABLE IF NOT EXISTS extradat (id INTEGER PRIMARY KEY, run_id INTEGER, key TEXT, val TEXT);") (sqlite3:execute db "CREATE TABLE IF NOT EXISTS metadat (id INTEGER PRIMARY KEY, var TEXT, val TEXT, CONSTRAINT metadat_constraint UNIQUE (var));") (sqlite3:execute db "CREATE TABLE IF NOT EXISTS access_log (id INTEGER PRIMARY KEY, user TEXT, accessed TIMESTAMP, args TEXT);") ;; Must do this *after* running patch db !! No more. ;; cannot use db:set-var since it will deadlock, hardwire the code here ;; ERROR: Cannot do this here - must update from Megatest itself, not from mtserver ;; (sqlite3:execute db "INSERT OR REPLACE INTO metadat (var,val) VALUES (?,?);" "MEGATEST_VERSION" (common:version-signature)) ;;====================================================================== ;; R U N S P E C I F I C D B ;;====================================================================== (sqlite3:execute db "CREATE TABLE IF NOT EXISTS tests (id INTEGER PRIMARY KEY, run_id INTEGER DEFAULT -1, testname TEXT DEFAULT 'noname', host TEXT DEFAULT 'n/a', cpuload REAL DEFAULT -1, diskfree INTEGER DEFAULT -1, uname TEXT DEFAULT 'n/a', |
︙ | ︙ | |||
1330 1331 1332 1333 1334 1335 1336 | comment TEXT DEFAULT '', event_time TIMESTAMP DEFAULT (strftime('%s','now')), fail_count INTEGER DEFAULT 0, pass_count INTEGER DEFAULT 0, archived INTEGER DEFAULT 0, -- 0=no, > 1=archive block id where test data can be found last_update INTEGER DEFAULT (strftime('%s','now')), CONSTRAINT testsconstraint UNIQUE (run_id, testname, item_path));") | | > > > > > | 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | comment TEXT DEFAULT '', event_time TIMESTAMP DEFAULT (strftime('%s','now')), fail_count INTEGER DEFAULT 0, pass_count INTEGER DEFAULT 0, archived INTEGER DEFAULT 0, -- 0=no, > 1=archive block id where test data can be found last_update INTEGER DEFAULT (strftime('%s','now')), CONSTRAINT testsconstraint UNIQUE (run_id, testname, item_path));") ;; deprecated -- (sqlite3:execute db "CREATE INDEX IF NOT EXISTS tests_index ON tests (run_id, testname, item_path, uname);") (sqlite3:execute db "CREATE INDEX IF NOT EXISTS tests_run_id_index ON tests (run_id);") ;; new (sqlite3:execute db "CREATE INDEX IF NOT EXISTS tests_testname_index ON tests (testname,item_path);") ;; new (sqlite3:execute db "CREATE INDEX IF NOT EXISTS tests_state_status_index ON tests (state, status); ") ;; new (sqlite3:execute db "CREATE TRIGGER IF NOT EXISTS update_tests_trigger AFTER UPDATE ON tests FOR EACH ROW BEGIN UPDATE tests SET last_update=(strftime('%s','now')) WHERE id=old.id; END;") (sqlite3:execute db "CREATE TABLE IF NOT EXISTS test_steps |
︙ | ︙ | |||
1391 1392 1393 1394 1395 1396 1397 | id INTEGER PRIMARY KEY, test_id INTEGER, state TEXT DEFAULT 'new', status TEXT DEFAULT 'n/a', archive_type TEXT DEFAULT 'bup', du INTEGER, archive_path TEXT);"))) | < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < > > > | > > | > > | | < < | < < < < < < < < | < < < < < < < < | | < < < < | < | < < < | < < | < < | < < < < < < < < < < < | < < < < < < | < < < | < < < < < < < < < < < < < < | | < < | | < < < < < < < < | < < < | < < < | | < < < < < < < < < | < < | < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < | < | < < < | | < < < < | < < < < < < < < < < < < < | < < < < < < < > | < < < < < < < < | < < | < < < < < < < < < < | < | | < | < < < < < < < < < < < < < < < < < < | < | < < < | < < < < < < < | < < < < < < | < < < < | < < < < < < < < < < < | < < < < < < < < < < > > | < < < < < < < < < < < < < | < < | < < < < < < < < < < < < < | < | < < < < < < < < < < < > | < < < < < < > > < < < < < < | < > | < < < < < < < < < < < | < | < < < < < < < < < < < > | < < < < < < < < < < < < < < < < > < < | < < < < < < < < < < < < < | < < | < < < | < < < | < < | > | < < < < < < < < < < | < < < < < < < < < < < | | < < < | < < < < | < < < | < < < < < < < < < < < < | < < < < < < < < < < < < < | | < | < < | | < < < < < < < < < < | < < < < | < < | < < < < < < < < < < < < < < < < < | | | < < < | < < < < < < < < < < < < < < < | < | < | < < < < < < < < < < < | < < < < | < < < | | | | < < < < < < < < < < < < < < < < | < | | | | < < < < < | < < < < < < < | | < < | < < < < < < < < < < | < < < < < < < < < < < < < < < < < < | | | < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | < < < < < | < < < < > < < < < < < < | < < < | < < < < < < < < > | < < | < < < < < < < < | | < | < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < | < < < < < < < < < < < < < < | | < | < < < < < < < < | < | < < < < < < < | < < < | | | < < | < < < < < < < < < < < | < | < < | < < < < < < | < < < < < < < < < < < < < < < | < < < < < < < | | < < | < < < | < < < < < < < < | < < < | < < < | < | < < < < < < < < < < < < < < < < < < | < < < < | < < < < < < < < | | < < < < < < < < < < < < < < < < < | > | < < | < < < < < > < | < < | < < < < < < < > | < < < < < < | < < < < | < < < < < < < | < < | < < < < < < < < < < < < < < < | | < < < < | | < < < < < < | < < < < < | < < < < < < < < < < < < < < < < < < < | < | | < < < < < < < < < < < | < < < < | < < < < < < < < < | < < < < < < < < < < < < < | | < | < < < | < | < | < < < < < < < < < | | < < < < | < < < < < < < < < < < < | | < | < < < < | | < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < | < | < < < | < < < < < < < < < < < < < | < | < < < | < < | < < < < < < < < < | < < < < < < < | < < < | < < < < < < < | < < < < < < < | | < < < < < | < < | < < < < < < < < < < < < < < < < < < < < < < < | < < < | < < < < < < > | < < < | < < < < < < < < < < < < < < < > | < < < < < < < | < < < | < | | < < < < < < < < < < | | < < < < < < | < < < < < < < < | < < < < < < < < < < < < | < < < < < | < < < < < < < < < < < < < < | < < | < < < < < < < | < < < < < < < | < < < < < < < | < < < < < < | < < < < < < < < < < < < > | < | | < < < < < < < < < < < | < < < < < | < < < | > > | < < < < < | < < < < < < < < < < | < < < | < < < < < < < < | < < | < < < | < < < < < < < | < < | < < < < | < < < < | < < < < | < < | < < < < | | < < < < < < < < < < < < < < < < < < | < < | < < < < < | < < | < | | < < < | < < < < > < < < | < < < | < < < < < < | < < < < < < < < < < < | < < < < | < < < < < < | < < < | < < < < | < < < < < < < < | < | | < < < < < < < < < < < < < < < < | | < < < < < < < < < < < < < < < | < < < < | < < < < < | < < < < < < < < | < < < < < < < | < | | < < < < < < < < < < | < < | < < < | < < < < < < < < | < | < < < < < < < | < < < < < < < < < < | | < < < | < < < < < < < < < | | < < < | < < < < < < | < < < < | < < < < < < < < < < < | > | < < | < < < < < < < < < < < < | < < < | < < < < | < < < < < < < | < < < < < < < < < < < < < < < < | < < | < < < < < < < < < < | | < < < | < < < < < < < < < | < < < | < < < | < > | | < < < | < | < | | < < < < < | < < < | < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < | < < < < < < < < < < < > | < | < > > | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < > > | | < < < < < < < < < < | | < < < < < < < < < < < < < < < < < < < < < | < < < < < | < < < < < < < | < > > < < < < < < < < < < < < < < < < < < | < < < | < < < < | < | < < < < < < | | < | < < | < < < < < < < | | < < < | < < < < < < < < < < < < < < < < < < < < | < < < < < | < < | < < < < < < < < | | < < < | < < > < < < | < < < < | < < < | < | < < < < < < < < < | < < | | < < < < < < < < | < < < < < < < | < < < < < < | < < < < < < < | < < < < < > | < < | < < < < < < | < < | < | < | < < < < < < < < < < < < < < < < < < < | < > | | < > | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | < < < < < < < < < < < | < < < < < < < < < | < < < < | < < < < < | | | < < < < < < < < < < < < < | < < < < | < < | < | < < < | < | < < | < | < < < < < < < < < < < < < | | < < < < < < < < < < < < < < < < < < < < < < < | > | < | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < | | < < | < < | < < < < < < < | | < < < | < < < < < < | | < < < | < < < > | < < | < | | < | | < < | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < > | | > | | < < < < < | < < < > | < < > | | < < < < < < < < < < < < < < > | | < > | | < > | | < < < < < < < < < < < | > | < > | < | | < < < < < < < | < | < < < | < < | | | < < < < < < > < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < | < < | < < < < < < < | < < < < < < < < < < < | < < < < < < < < < < < < | < | < | < < < < < < < < < | | < < < < < < < | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | > | < < < < < < < < < < | | < | < | < < < < < < | > | < < < < < < < < < < < < < < < < < < < < < < < < < < < < > > | | < | < < | < < < < | < < < < < < | < < > | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < | < | | | < > | < < < | < < < < < < < < < > | | < < < | < < < < < < < < | < < < < < < < | < < < | < | < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < | < < < < < < < < | < < < < < < < < < < < < < < | | < < < | | < < | < < < < < < < < | < | < < < | < < < < < < < < < < < | < < < < < < < < < < < < < | < < | < < < < < < < < < < < | < | | | 322 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 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 | id INTEGER PRIMARY KEY, test_id INTEGER, state TEXT DEFAULT 'new', status TEXT DEFAULT 'n/a', archive_type TEXT DEFAULT 'bup', du INTEGER, archive_path TEXT);"))) db) (define (db:general-sqlite-error-dump . args) #t (print "Got here: db:general-sqlite-error-dump")) (define (db:first-result-default . args) #t (print "Got here: db:first-result-default")) (define (db:get-db . args) #t (print "Got here: db:get-db")) (define (db:dbdat-get-db . args) #t (print "Got here: db:dbdat-get-db")) (define (db:dbdat-get-path . args) #t (print "Got here: db:dbdat-get-path")) (define (db:with-db . args) #t (print "Got here: db:with-db")) (define (db:set-sync . args) #t (print "Got here: db:set-sync")) (define (db:lock-create-open . args) #t (print "Got here: db:lock-create-open")) (define (db:open-db . args) #t (print "Got here: db:open-db")) (define (db:get-last-update-time . args) #t (print "Got here: db:get-last-update-time")) (define (db:setup . args) #t (print "Got here: db:setup")) (define (db:open-megatest-db . args) #t (print "Got here: db:open-megatest-db")) (define (db:sync-touched . args) #t (print "Got here: db:sync-touched")) (define (db:safely-close-sqlite3-db . args) #t (print "Got here: db:safely-close-sqlite3-db")) (define (db:close-all . args) #t (print "Got here: db:close-all")) (define (db:sync-main-list . args) #t (print "Got here: db:sync-main-list")) (define (db:sync-all-tables-list . args) #t (print "Got here: db:sync-all-tables-list")) (define (db:move-and-recreate-db . args) #t (print "Got here: db:move-and-recreate-db")) (define (db:repair-db . args) #t (print "Got here: db:repair-db")) (define (db:sync-tables . args) #t (print "Got here: db:sync-tables")) (define (db:patch-schema-rundb . args) #t (print "Got here: db:patch-schema-rundb")) (define (db:patch-schema-maindb . args) #t (print "Got here: db:patch-schema-maindb")) (define (db:adj-target . args) #t (print "Got here: db:adj-target")) (define (db:get-access-mode . args) #t (print "Got here: db:get-access-mode")) (define (db:dispatch-query . args) #t (print "Got here: db:dispatch-query")) (define (db:cache-for-read-only . args) #t (print "Got here: db:cache-for-read-only")) (define (db:multi-db-sync . args) #t (print "Got here: db:multi-db-sync")) (define (db:tmp->megatest.db-sync . args) #t (print "Got here: db:tmp->megatest.db-sync")) (define (db:sync-to-megatest.db . args) #t (print "Got here: db:sync-to-megatest.db")) (define (open-run-close-no-exception-handling . args) #t (print "Got here: open-run-close-no-exception-handling")) (define (open-run-close-exception-handling . args) #t (print "Got here: open-run-close-exception-handling")) (define (db:initialize-main-db . args) #t (print "Got here: db:initialize-main-db")) (define (db:archive-get-allocations . args) #t (print "Got here: db:archive-get-allocations")) (define (db:archive-register-disk . args) #t (print "Got here: db:archive-register-disk")) (define (db:archive-register-block-name . args) #t (print "Got here: db:archive-register-block-name")) (define (db:test-set-archive-block-id . args) #t (print "Got here: db:test-set-archive-block-id")) (define (db:test-get-archive-block-info . args) #t (print "Got here: db:test-get-archive-block-info")) (define (open-logging-db . args) #t (print "Got here: open-logging-db")) (define (db:log-local-event . args) #t (print "Got here: db:log-local-event")) (define (db:log-event . args) #t (print "Got here: db:log-event")) (define (db:have-incompletes? . args) #t (print "Got here: db:have-incompletes?")) (define (db:find-and-mark-incomplete . args) #t (print "Got here: db:find-and-mark-incomplete")) (define (db:top-test-set-per-pf-counts . args) #t (print "Got here: db:top-test-set-per-pf-counts")) (define (db:clean-up . args) #t (print "Got here: db:clean-up")) (define (db:clean-up-rundb . args) #t (print "Got here: db:clean-up-rundb")) (define (db:clean-up-maindb . args) #t (print "Got here: db:clean-up-maindb")) (define (db:get-var . args) #t (print "Got here: db:get-var")) (define (db:set-var . args) #t (print "Got here: db:set-var")) (define (db:del-var . args) #t (print "Got here: db:del-var")) (define (db:open-no-sync-db . args) #t (print "Got here: db:open-no-sync-db")) (define (db:no-sync-db . args) #t (print "Got here: db:no-sync-db")) (define (db:no-sync-set . args) #t (print "Got here: db:no-sync-set")) (define (db:no-sync-del! . args) #t (print "Got here: db:no-sync-del!")) (define (db:no-sync-get/default . args) #t (print "Got here: db:no-sync-get/default")) (define (db:no-sync-close-db . args) #t (print "Got here: db:no-sync-close-db")) (define (db:no-sync-get-lock . args) #t (print "Got here: db:no-sync-get-lock")) (define (db:get-keys . args) #t (print "Got here: db:get-keys")) (define (db:get-value-by-header . args) #t (print "Got here: db:get-value-by-header")) (define (db:get-header . args) #t (print "Got here: db:get-header")) (define (db:get-rows . args) #t (print "Got here: db:get-rows")) (define (db:get-run-times . args) #t (print "Got here: db:get-run-times")) (define (db:get-run-name-from-id . args) #t (print "Got here: db:get-run-name-from-id")) (define (db:get-run-key-val . args) #t (print "Got here: db:get-run-key-val")) (define (runs:get-std-run-fields . args) #t (print "Got here: runs:get-std-run-fields")) (define (db:patt->like . args) #t (print "Got here: db:patt->like")) (define (db:register-run . args) #t (print "Got here: db:register-run")) (define (db:get-runs . args) #t (print "Got here: db:get-runs")) (define (db:simple-get-runs . args) #t (print "Got here: db:simple-get-runs")) (define (db:get-changed-run-ids . args) #t (print "Got here: db:get-changed-run-ids")) (define (db:get-targets . args) #t (print "Got here: db:get-targets")) (define (db:get-num-runs . args) #t (print "Got here: db:get-num-runs")) (define (db:get-runs-cnt-by-patt . args) #t (print "Got here: db:get-runs-cnt-by-patt")) (define (db:get-raw-run-stats . args) #t (print "Got here: db:get-raw-run-stats")) (define (db:update-run-stats . args) #t (print "Got here: db:update-run-stats")) (define (db:get-main-run-stats . args) #t (print "Got here: db:get-main-run-stats")) (define (db:print-current-query-stats . args) #t (print "Got here: db:print-current-query-stats")) (define (db:get-all-run-ids . args) #t (print "Got here: db:get-all-run-ids")) (define (db:get-run-stats . args) #t (print "Got here: db:get-run-stats")) (define (db:get-runs-by-patt . args) #t (print "Got here: db:get-runs-by-patt")) (define (db:get-run-info . args) #t (print "Got here: db:get-run-info")) (define (db:set-comment-for-run . args) #t (print "Got here: db:set-comment-for-run")) (define (db:delete-run . args) #t (print "Got here: db:delete-run")) (define (db:update-run-event_time . args) #t (print "Got here: db:update-run-event_time")) (define (db:lock/unlock-run . args) #t (print "Got here: db:lock/unlock-run")) (define (db:set-run-status . args) #t (print "Got here: db:set-run-status")) (define (db:get-run-status . args) #t (print "Got here: db:get-run-status")) (define (db:get-key-val-pairs . args) #t (print "Got here: db:get-key-val-pairs")) (define (db:get-key-vals . args) #t (print "Got here: db:get-key-vals")) (define (db:get-target . args) #t (print "Got here: db:get-target")) (define (db:get-prev-run-ids . args) #t (print "Got here: db:get-prev-run-ids")) (define (db:get-tests-for-run . args) #t (print "Got here: db:get-tests-for-run")) (define (db:test-short-record->norm . args) #t (print "Got here: db:test-short-record->norm")) (define (db:get-tests-for-run-state-status . args) #t (print "Got here: db:get-tests-for-run-state-status")) (define (db:get-testinfo-state-status . args) #t (print "Got here: db:get-testinfo-state-status")) (define (db:get-tests-for-run-mindata . args) #t (print "Got here: db:get-tests-for-run-mindata")) (define (db:get-tests-for-runs . args) #t (print "Got here: db:get-tests-for-runs")) (define (db:delete-test-records . args) #t (print "Got here: db:delete-test-records")) (define (db:delete-old-deleted-test-records . args) #t (print "Got here: db:delete-old-deleted-test-records")) (define (db:set-tests-state-status . args) #t (print "Got here: db:set-tests-state-status")) (define (db:test-set-state-status . args) #t (print "Got here: db:test-set-state-status")) (define (db:get-count-tests-running . args) #t (print "Got here: db:get-count-tests-running")) (define (db:get-count-tests-actually-running . args) #t (print "Got here: db:get-count-tests-actually-running")) (define (db:get-count-tests-running-for-run-id . args) #t (print "Got here: db:get-count-tests-running-for-run-id")) (define (db:get-count-tests-running-for-testname . args) #t (print "Got here: db:get-count-tests-running-for-testname")) (define (db:get-count-tests-running-in-jobgroup . args) #t (print "Got here: db:get-count-tests-running-in-jobgroup")) (define (db:estimated-tests-remaining . args) #t (print "Got here: db:estimated-tests-remaining")) (define (db:get-test-id . args) #t (print "Got here: db:get-test-id")) (define (db:test-set-top-process-pid . args) #t (print "Got here: db:test-set-top-process-pid")) (define (db:test-get-top-process-pid . args) #t (print "Got here: db:test-get-top-process-pid")) (define (db:field->number . args) #t (print "Got here: db:field->number")) (define (db:get-all-tests-info-by-run-id . args) #t (print "Got here: db:get-all-tests-info-by-run-id")) (define (db:replace-test-records . args) #t (print "Got here: db:replace-test-records")) (define (db:adj-test-id . args) #t (print "Got here: db:adj-test-id")) (define (db:prep-megatest.db-adj-test-ids . args) #t (print "Got here: db:prep-megatest.db-adj-test-ids")) (define (db:prep-megatest.db-for-migration . args) #t (print "Got here: db:prep-megatest.db-for-migration")) (define (db:get-test-info-by-id . args) #t (print "Got here: db:get-test-info-by-id")) (define (db:get-test-info-by-ids . args) #t (print "Got here: db:get-test-info-by-ids")) (define (db:get-test-info . args) #t (print "Got here: db:get-test-info")) (define (db:test-get-rundir-from-test-id . args) #t (print "Got here: db:test-get-rundir-from-test-id")) (define (db:get-test-times . args) #t (print "Got here: db:get-test-times")) (define (db:get-test-times . args) #t (print "Got here: db:get-test-times")) (define (db:teststep-set-status! . args) #t (print "Got here: db:teststep-set-status!")) (define (db:get-steps-for-test . args) #t (print "Got here: db:get-steps-for-test")) (define (db:get-steps-info-by-id . args) #t (print "Got here: db:get-steps-info-by-id")) (define (db:get-steps-data . args) #t (print "Got here: db:get-steps-data")) (define (db:get-data-info-by-id . args) #t (print "Got here: db:get-data-info-by-id")) (define (db:test-data-rollup . args) #t (print "Got here: db:test-data-rollup")) (define (db:logpro-dat->csv . args) #t (print "Got here: db:logpro-dat->csv")) (define (db:csv->test-data . args) #t (print "Got here: db:csv->test-data")) (define (db:read-test-data . args) #t (print "Got here: db:read-test-data")) (define (db:read-test-data* . args) #t (print "Got here: db:read-test-data*")) (define (db:get-run-ids-matching-target . args) #t (print "Got here: db:get-run-ids-matching-target")) (define (db:test-get-paths-matching-keynames-target-new . args) #t (print "Got here: db:test-get-paths-matching-keynames-target-new")) (define (db:test-toplevel-num-items . args) #t (print "Got here: db:test-toplevel-num-items")) (define (db:obj->string . args) #t (print "Got here: db:obj->string")) (define (db:string->obj . args) #t (print "Got here: db:string->obj")) (define (db:set-state-status-and-roll-up-items . args) #t (print "Got here: db:set-state-status-and-roll-up-items")) (define (db:get-all-state-status-counts-for-test . args) #t (print "Got here: db:get-all-state-status-counts-for-test")) (define (db:test-get-logfile-info . args) #t (print "Got here: db:test-get-logfile-info")) (define (db:lookup-query . args) #t (print "Got here: db:lookup-query")) (define (db:login . args) #t (print "Got here: db:login")) (define (db:general-call . args) #t (print "Got here: db:general-call")) (define (db:get-state-status-summary . args) #t (print "Got here: db:get-state-status-summary")) (define (db:get-latest-host-load . args) #t (print "Got here: db:get-latest-host-load")) (define (db:set-top-level-from-items . args) #t (print "Got here: db:set-top-level-from-items")) (define (db:get-matching-previous-test-run-records . args) #t (print "Got here: db:get-matching-previous-test-run-records")) (define (db:delay-if-busy . args) #t (print "Got here: db:delay-if-busy")) (define (db:test-get-records-for-index-file . args) #t (print "Got here: db:test-get-records-for-index-file")) (define (db:get-tests-tags . args) #t (print "Got here: db:get-tests-tags")) (define (db:testmeta-get-record . args) #t (print "Got here: db:testmeta-get-record")) (define (db:testmeta-add-record . args) #t (print "Got here: db:testmeta-add-record")) (define (db:testmeta-update-field . args) #t (print "Got here: db:testmeta-update-field")) (define (db:testmeta-get-all . args) #t (print "Got here: db:testmeta-get-all")) (define (db:compare-itempaths . args) #t (print "Got here: db:compare-itempaths")) (define (db:convert-test-itempath . args) #t (print "Got here: db:convert-test-itempath")) (define (db:multi-pattern-apply . args) #t (print "Got here: db:multi-pattern-apply")) (define (db:get-prereqs-not-met . args) #t (print "Got here: db:get-prereqs-not-met")) (define (db:get-run-record-ids . args) #t (print "Got here: db:get-run-record-ids")) (define (db:get-changed-record-ids . args) #t (print "Got here: db:get-changed-record-ids")) (define (db:extract-ods-file . args) #t (print "Got here: db:extract-ods-file")) ;;====================================================================== ;; Strings table (kept in the <runid>.db) ;;====================================================================== ;; Move this into the runid db init ;; (define (db:sdb-initialize sdb) (sqlite3:execute sdb "CREATE TABLE IF NOT EXISTS strs (id INTEGER PRIMARY KEY, str TEXT, CONSTRAINT str UNIQUE (str));") (sqlite3:execute sdb "CREATE INDEX IF NOT EXISTS strindx ON strs (str);")) ;; (define sumup (let ((a 0))(lambda (x)(set! a (+ x a)) a))) (define (db:sdb-register-string sdb str) (sqlite3:execute sdb "INSERT OR IGNORE INTO strs (str) VALUES (?);" str)) (define (db:sdb-string->id sdb str-cache str) (let ((id (hash-table-ref/default str-cache str #f))) (if (not id) (sqlite3:for-each-row (lambda (sid) (set! id sid) (hash-table-set! str-cache str id)) sdb "SELECT id FROM strs WHERE str=?;" str)) id)) (define (db:sdb-id->string sdb id-cache id) (let ((str (hash-table-ref/default id-cache id #f))) (if (not str) (sqlite3:for-each-row (lambda (istr) (set! str istr) (hash-table-set! id-cache id str)) sdb "SELECT str FROM strs WHERE id=?;" id)) str)) ;; Numbers get passed though in both directions ;; #;(define (db:sdb-qry fname) (let ((sdb #f) (scache (make-hash-table)) (icache (make-hash-table))) (lambda (cmd var) (case cmd ((setup) (set! sdb (if (not sdb) (db:sdb-open (if var var fname))))) ((setdb) (set! sdb var)) ((getdb) sdb) ((finalize) (if sdb (begin (sqlite3:finalize! sdb) (set! sdb #f)))) ((getid) (let ((id (if (or (number? var) (string->number var)) var (db:sdb-string->id sdb scache var)))) (if id id (begin (db:sdb-register-string sdb var) (db:sdb-string->id sdb scache var))))) ((getstr) (if (or (number? var) (string->number var)) (db:sdb-id->string sdb icache var) var)) ((passid) var) ((passstr) var) (else #f))))) ) |
Modified ftail.scm from [96a7ff77a3] to [82f85a3958].
︙ | ︙ | |||
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ;; Megatest is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with Megatest. If not, see <http://www.gnu.org/licenses/>. ;;====================================================================== (declare (unit ftail)) (module ftail ( open-tail-db | > > > > > > > | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | ;; Megatest is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with Megatest. If not, see <http://www.gnu.org/licenses/>. ;; ;;====================================================================== ;;====================================================================== ;; ;; log to sqlite3 db, polling to tail along with indexing to any point in ;; history is then easy ;; ;;====================================================================== (declare (unit ftail)) (module ftail ( open-tail-db |
︙ | ︙ |
Modified http-transport.scm from [da311848d8] to [b6b8ef7c43].
︙ | ︙ | |||
38 39 40 41 42 43 44 45 46 47 48 49 50 51 | (declare (uses portlogger)) (declare (uses rmt)) (include "common_records.scm") (include "db_records.scm") (include "js-path.scm") (require-library stml) (define (http-transport:make-server-url hostport) (if (not hostport) #f (conc "http://" (car hostport) ":" (cadr hostport)))) (define *server-loop-heart-beat* (current-seconds)) | > > > > > | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | (declare (uses portlogger)) (declare (uses rmt)) (include "common_records.scm") (include "db_records.scm") (include "js-path.scm") (import portlogger) (portlogger:set-default-log-port! *default-log-port*) (portlogger:set-configdat! *configdat*) (portlogger:set-printers! debug:print debug:print-error) (require-library stml) (define (http-transport:make-server-url hostport) (if (not hostport) #f (conc "http://" (car hostport) ":" (cadr hostport)))) (define *server-loop-heart-beat* (current-seconds)) |
︙ | ︙ |
Modified iup-test/Makefile from [2356e68571] to [a0f27c5501].
|
| | | 1 2 3 4 5 | LIBSRC = "PATH/chicken-4.10.0-patch" sample : sample.c gcc -I$(LIBSRC)/include/ -L$(LIBSRC)/lib -L$(LIBSRC)/lib64 -liup -liupimglib -o sample sample.c |
Modified launch.scm from [5b95a5518e] to [6dd1993f7c].
︙ | ︙ | |||
608 609 610 611 612 613 614 | (debug:print 0 *default-log-port* "INFO: test is INCOMPLETE or KILLED, treat this execute call as a rerun request") ;; (tests:test-force-state-status! run-id test-id "REMOTEHOSTSTART" "n/a") (rmt:test-set-state-status run-id test-id "REMOTEHOSTSTART" "n/a" #f) ) ;; prime it for running ((member (db:test-get-state test-info) '("RUNNING" "REMOTEHOSTSTART")) (if (process:alive-on-host? test-host test-pid) (debug:print-error 0 *default-log-port* "test state is " (db:test-get-state test-info) " and process " test-pid " is still running on host " test-host ", cannot proceed") | < < | | 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 | (debug:print 0 *default-log-port* "INFO: test is INCOMPLETE or KILLED, treat this execute call as a rerun request") ;; (tests:test-force-state-status! run-id test-id "REMOTEHOSTSTART" "n/a") (rmt:test-set-state-status run-id test-id "REMOTEHOSTSTART" "n/a" #f) ) ;; prime it for running ((member (db:test-get-state test-info) '("RUNNING" "REMOTEHOSTSTART")) (if (process:alive-on-host? test-host test-pid) (debug:print-error 0 *default-log-port* "test state is " (db:test-get-state test-info) " and process " test-pid " is still running on host " test-host ", cannot proceed") (exit))) ((not (member (db:test-get-state test-info) '("REMOVING" "REMOTEHOSTSTART" "RUNNING" "KILLREQ"))) ;; (tests:test-force-state-status! run-id test-id "REMOTEHOSTSTART" "n/a") (rmt:test-set-state-status run-id test-id "REMOTEHOSTSTART" "n/a" #f) ) (else ;; (member (db:test-get-state test-info) '("REMOVING" "REMOTEHOSTSTART" "RUNNING" "KILLREQ")) (debug:print-error 0 *default-log-port* "test state is " (db:test-get-state test-info) ", cannot proceed") (exit)))) |
︙ | ︙ |
Modified megatest-version.scm from [1094c4a239] to [58d639f18b].
︙ | ︙ | |||
16 17 18 19 20 21 22 | ;; along with Megatest. If not, see <http://www.gnu.org/licenses/>. ;; Always use two or four digit decimal ;; 1.01, 1.02...1.10,1.11,1.1101 ... 1.99,2.00.. (declare (unit megatest-version)) | | | 16 17 18 19 20 21 22 23 | ;; along with Megatest. If not, see <http://www.gnu.org/licenses/>. ;; Always use two or four digit decimal ;; 1.01, 1.02...1.10,1.11,1.1101 ... 1.99,2.00.. (declare (unit megatest-version)) (define megatest-version 1.6523) |
Modified megatest.scm from [cecad5eaf2] to [8bf0940777].
︙ | ︙ | |||
20 21 22 23 24 25 26 | ;; (include "megatest-version.scm") ;; fake out readline usage of toplevel-command (define (toplevel-command . a) #f) (use (prefix sqlite3 sqlite3:) srfi-1 posix regex regex-case srfi-69 (prefix base64 base64:) readline apropos json http-client directory-utils typed-records | | | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | ;; (include "megatest-version.scm") ;; fake out readline usage of toplevel-command (define (toplevel-command . a) #f) (use (prefix sqlite3 sqlite3:) srfi-1 posix regex regex-case srfi-69 (prefix base64 base64:) readline apropos json http-client directory-utils typed-records http-client srfi-18 extras format (prefix pkts pkts:)) ;; Added for csv stuff - will be removed ;; (use sparse-vectors) (require-library mutils) |
︙ | ︙ | |||
42 43 44 45 46 47 48 49 50 51 52 53 54 55 | (declare (uses server)) (declare (uses client)) (declare (uses tests)) (declare (uses genexample)) ;; (declare (uses daemon)) (declare (uses db)) ;; (declare (uses dcommon)) (declare (uses tdb)) (declare (uses mt)) (declare (uses api)) (declare (uses tasks)) ;; only used for debugging. (declare (uses env)) (declare (uses diff-report)) | > > | | > > > > > > | 42 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 | (declare (uses server)) (declare (uses client)) (declare (uses tests)) (declare (uses genexample)) ;; (declare (uses daemon)) (declare (uses db)) ;; (declare (uses dcommon)) (import db) (declare (uses tdb)) (declare (uses mt)) (declare (uses api)) (declare (uses tasks)) ;; only used for debugging. (declare (uses env)) (declare (uses diff-report)) ;; (declare (uses ftail)) ;; (import ftail) ;; ;; (declare (uses portlogger)) ;; (import portlogger) ;; ;; (declare (uses nmsg-transport)) ;; (import (prefix nmsg-transport nmsg:)) (define *db* #f) ;; this is only for the repl, do not use in general!!!! (include "common_records.scm") (include "key_records.scm") (include "db_records.scm") (include "run_records.scm") |
︙ | ︙ | |||
108 109 110 111 112 113 114 115 116 117 118 119 120 121 | -version : print megatest version (currently " megatest-version ") Launching and managing runs -run : run all tests or as specified by -testpatt -remove-runs : remove the data for a run, requires -runname and -testpatt Optionally use :state and :status, use -keep-records to remove only the run data. -set-state-status X,Y : set state to X and status to Y, requires controls per -remove-runs -rerun FAIL,WARN... : force re-run for tests with specificed status(s) -rerun-clean : set all tests not COMPLETED+PASS,WARN,WAIVED to NOT_STARTED,n/a and then run the specified testpatt with -preclean -rerun-all : set all tests to NOT_STARTED,n/a and run with -preclean -lock : lock run specified by target and runname -unlock : unlock run specified by target and runname | > > | 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | -version : print megatest version (currently " megatest-version ") Launching and managing runs -run : run all tests or as specified by -testpatt -remove-runs : remove the data for a run, requires -runname and -testpatt Optionally use :state and :status, use -keep-records to remove only the run data. -kill-runs : kill existing run(s) (all incomplete tests killed) -kill-rerun : kill an existing run (all incomplete tests killed and run is rerun) -set-state-status X,Y : set state to X and status to Y, requires controls per -remove-runs -rerun FAIL,WARN... : force re-run for tests with specificed status(s) -rerun-clean : set all tests not COMPLETED+PASS,WARN,WAIVED to NOT_STARTED,n/a and then run the specified testpatt with -preclean -rerun-all : set all tests to NOT_STARTED,n/a and run with -preclean -lock : lock run specified by target and runname -unlock : unlock run specified by target and runname |
︙ | ︙ | |||
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | "-itempatt" "-setlog" "-set-toplog" "-runstep" "-logpro" "-m" "-rerun" "-days" "-rename-run" "-to" ;; values and messages ":category" ":variable" ":value" ":expected" ":tol" ":units" ;; misc "-start-dir" "-run-patt" "-target-patt" "-contour" "-area-tag" "-server" "-transport" "-port" "-extract-ods" "-pathmod" "-env2file" "-envcap" | > > | 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 | "-itempatt" "-setlog" "-set-toplog" "-runstep" "-logpro" "-m" "-rerun" "-days" "-rename-run" "-to" ;; values and messages ":category" ":variable" ":value" ":expected" ":tol" ":units" ;; misc "-start-dir" "-run-patt" "-target-patt" "-contour" "-area-tag" "-area" "-server" "-transport" "-port" "-extract-ods" "-pathmod" "-env2file" "-envcap" |
︙ | ︙ | |||
401 402 403 404 405 406 407 408 409 410 411 412 413 414 | ;; queries "-test-paths" ;; get path(s) to a test, ordered by youngest first "-runall" ;; run all tests, respects -testpatt, defaults to % "-run" ;; alias for -runall "-remove-runs" "-keep-records" ;; use with -remove-runs to remove only the run data "-rebuild-db" "-cleanup-db" "-rollup" "-update-meta" "-create-megatest-area" "-mark-incompletes" | > > | 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 | ;; queries "-test-paths" ;; get path(s) to a test, ordered by youngest first "-runall" ;; run all tests, respects -testpatt, defaults to % "-run" ;; alias for -runall "-remove-runs" "-kill-runs" "-kill-rerun" "-keep-records" ;; use with -remove-runs to remove only the run data "-rebuild-db" "-cleanup-db" "-rollup" "-update-meta" "-create-megatest-area" "-mark-incompletes" |
︙ | ︙ | |||
569 570 571 572 573 574 575 | (printf "Sending signal/term to ~A\n" pid) (process-signal pid signal/term)))))) (process:children #f)) (original-exit exit-code))))) ;; for some switches always print the command to stderr ;; | | | | 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 | (printf "Sending signal/term to ~A\n" pid) (process-signal pid signal/term)))))) (process:children #f)) (original-exit exit-code))))) ;; for some switches always print the command to stderr ;; (if (args:any? "-run" "-runall" "-remove-runs" "-set-state-status" "-kill-runs" "-kill-rerun") (debug:print 0 *default-log-port* (string-intersperse (argv) " "))) ;; some switches imply homehost. Exit here if not on homehost ;; #;(let ((homehost-required (list "-cleanup-db" "-server"))) (if (apply args:any? homehost-required) (if (not (common:on-homehost?)) (for-each (lambda (switch) (if (args:get-arg switch) (begin (debug:print 0 *default-log-port* "ERROR: you must be on the homehost to run with " switch |
︙ | ︙ | |||
1036 1037 1038 1039 1040 1041 1042 | ((not target) (debug:print-error 0 *default-log-port* "Missing required parameter for " action ", you must specify -target or -reqtarg") (exit 1)) ((not (or (args:get-arg ":runname") (args:get-arg "-runname"))) (debug:print-error 0 *default-log-port* "Missing required parameter for " action ", you must specify the run name pattern with -runname patt") (exit 2)) | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 | ((not target) (debug:print-error 0 *default-log-port* "Missing required parameter for " action ", you must specify -target or -reqtarg") (exit 1)) ((not (or (args:get-arg ":runname") (args:get-arg "-runname"))) (debug:print-error 0 *default-log-port* "Missing required parameter for " action ", you must specify the run name pattern with -runname patt") (exit 2)) ((not (or (args:get-arg "-testpatt") (eq? action 'kill-runs))) (debug:print-error 0 *default-log-port* "Missing required parameter for " action ", you must specify the test pattern with -testpatt") (exit 3)) (else (if (not (car *configinfo*)) (begin (debug:print-error 0 *default-log-port* "Attempted " action "on test(s) but run area config file not found") (exit 1)) ;; put test parameters into convenient variables (begin ;; check for correct version, exit with message if not correct (common:exit-on-version-changed) (runs:operate-on action target (common:args-get-runname) ;; (or (args:get-arg "-runname")(args:get-arg ":runname")) (common:args-get-testpatt #f) ;; (args:get-arg "-testpatt") state: (common:args-get-state) status: (common:args-get-status) new-state-status: (args:get-arg "-set-state-status") mode: mode))) (set! *didsomething* #t))))) (if (args:get-arg "-kill-runs") (general-run-call "-kill-runs" "kill runs" (lambda (target runname keys keyvals) (operate-on 'kill-runs mode: #f) ))) (if (args:get-arg "-kill-rerun") (let* ((target-patt (args:get-arg "-target")) (runname-patt (args:get-arg "-runname"))) (cond ((not target-patt) (debug:print-error 0 *default-log-port* "Missing target, must specify target for -kill-rerun with -target <target name>") (exit 1)) ((not runname-patt) (debug:print-error 0 *default-log-port* "Missing runname, must specify runname for -kill-rerun with -runname <run name>") (exit 1)) ((string-search "[ ,%]" target-patt) (debug:print-error 0 *default-log-port* "Invalid target ["target-patt"], must specify exact target (no wildcards) for -kill-rerun with -target <target name>") (exit 1)) ((string-search "[ ,%]" runname-patt) (debug:print-error 0 *default-log-port* "Invalid runname ["runname-patt"], must specify exact runname (no wildcards) for -kill-rerun with -runname <runname name>") (exit 1)) (else (general-run-call "-kill-runs" "kill runs" (lambda (target runname keys keyvals) (operate-on 'kill-runs mode: #f) )) (thread-sleep! 15)) ;; fall thru and let "-run" loop fire ))) (if (args:get-arg "-remove-runs") (general-run-call "-remove-runs" "remove runs" (lambda (target runname keys keyvals) (operate-on 'remove-runs mode: (if (args:get-arg "-keep-records") |
︙ | ︙ | |||
1620 1621 1622 1623 1624 1625 1626 | ;; process deferred tasks per above steps ;; run all tests are are Not COMPLETED and PASS or CHECK (if (or (args:get-arg "-runall") (args:get-arg "-run") (args:get-arg "-rerun-clean") (args:get-arg "-rerun-all") | | > | | 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 | ;; process deferred tasks per above steps ;; run all tests are are Not COMPLETED and PASS or CHECK (if (or (args:get-arg "-runall") (args:get-arg "-run") (args:get-arg "-rerun-clean") (args:get-arg "-rerun-all") (args:get-arg "-runtests") (args:get-arg "-kill-rerun")) (let ((need-clean (or (args:get-arg "-rerun-clean") (args:get-arg "-rerun-all")))) (general-run-call "-runall" "run all tests" (lambda (target runname keys keyvals) (if (or (args:get-arg "-kill-rerun") (args:get-arg "-rerun-clean")) ;; first set states/statuses correct ;; For rerun-clean do we or do we not support the testpatt? (let ((states (or (configf:lookup *configdat* "validvalues" "cleanrerun-states") "KILLREQ,KILLED,UNKNOWN,INCOMPLETE,STUCK,NOT_STARTED")) (statuses (or (configf:lookup *configdat* "validvalues" "cleanrerun-statuses") "FAIL,INCOMPLETE,ABORT,CHECK,DEAD,PREQ_FAIL,PREQ_DISCARDED"))) (hash-table-set! args:arg-hash "-preclean" #t) (runs:operate-on 'set-state-status |
︙ | ︙ | |||
2148 2149 2150 2151 2152 2153 2154 | (exit 0))) (if (or (getenv "MT_RUNSCRIPT") (args:get-arg "-repl") (args:get-arg "-load")) (let* ((toppath (launch:setup)) (dbstruct (if (and toppath | | | 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 | (exit 0))) (if (or (getenv "MT_RUNSCRIPT") (args:get-arg "-repl") (args:get-arg "-load")) (let* ((toppath (launch:setup)) (dbstruct (if (and toppath #;(common:on-homehost?)) (db:setup #t) #f))) ;; make-dbr:dbstruct path: toppath local: (args:get-arg "-local")) #f))) (if *toppath* (cond ((getenv "MT_RUNSCRIPT") ;; How to run megatest scripts ;; |
︙ | ︙ | |||
2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 | (else (begin (set! *db* dbstruct) (import extras) ;; might not be needed ;; (import csi) (import readline) (import apropos) ;; (import (prefix sqlite3 sqlite3:)) ;; doesn't work ... (if *use-new-readline* (begin (install-history-file (get-environment-variable "HOME") ".megatest_history") ;; [homedir] [filename] [nlines]) (current-input-port (make-readline-port "megatest> "))) (begin | > | 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 | (else (begin (set! *db* dbstruct) (import extras) ;; might not be needed ;; (import csi) (import readline) (import apropos) (import portlogger) ;; (import (prefix sqlite3 sqlite3:)) ;; doesn't work ... (if *use-new-readline* (begin (install-history-file (get-environment-variable "HOME") ".megatest_history") ;; [homedir] [filename] [nlines]) (current-input-port (make-readline-port "megatest> "))) (begin |
︙ | ︙ |
Added mtserve.scm version [64299a659d].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 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 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 102 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 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | ;; Copyright 2006-2017, Matthew Welland. ;; ;; This file is part of Megatest. ;; ;; Megatest is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; ;; Megatest is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with Megatest. If not, see <http://www.gnu.org/licenses/>. ;; ;; (include "common.scm") ;; (include "megatest-version.scm") ;; fake out readline usage of toplevel-command (define (toplevel-command . a) #f) (use (prefix sqlite3 sqlite3:) srfi-1 posix regex regex-case srfi-69 (prefix base64 base64:) readline apropos json directory-utils typed-records srfi-18 extras format (prefix pkts pkts:)) (declare (uses common)) (declare (uses megatest-version)) (declare (uses margs)) (declare (uses server)) (declare (uses rmt)) ;; (declare (uses daemon)) (declare (uses db)) (import db) (declare (uses portlogger)) (import portlogger) (declare (uses nmsg-transport)) (import (prefix nmsg-transport nmsg:)) (include "common_records.scm") (include "key_records.scm") (include "db_records.scm") (include "run_records.scm") (include "megatest-fossil-hash.scm") (define *usage-log-file* #f) ;; put path to file for logging usage in this var in the ~/.megatestrc file (define *usage-use-seconds* #t) ;; for Epoc seconds in usage logging change this to #t in ~/.megatestrc file ;; load the ~/.megatestrc file, put (use trace)(trace-call-sites #t)(trace function-you-want-to-trace) in this file ;; (let ((debugcontrolf (conc (get-environment-variable "HOME") "/.mtserverrc"))) (if (file-exists? debugcontrolf) (load debugcontrolf))) ;; usage logging, careful with this, it is not designed to deal with all real world challenges! ;; (if (and *usage-log-file* (file-write-access? *usage-log-file*)) (with-output-to-file *usage-log-file* (lambda () (print (if *usage-use-seconds* (current-seconds) (time->string (seconds->local-time (current-seconds)) "%Yww%V.%w %H:%M:%S")) " " (current-user-name) " " (current-directory) " " "\"" (string-intersperse (argv) " ") "\"")) #:append)) ;; Disabled help items ;; -rollup : (currently disabled) fill run (set by :runname) with latest test(s) ;; from prior runs with same keys ;; -daemonize : fork into background and disconnect from stdin/out (define help (conc " Megatest, documentation at http://www.kiatoa.com/fossils/megatest version " megatest-version " license GPL, Copyright Matt Welland 2006-2017 Usage: mtserver [options] -h : this help -manual : show the Megatest user manual -version : print megatest version (currently " megatest-version ") Launching and managing runs -run : run all tests or as specified by -testpatt -server main|passive : start the server in \"main\" mode or \"passive\" mode -log logfile : send stdout and stderr to logfile -list-servers : list the servers -kill-servers : kill all servers -repl : start a repl (useful for extending megatest) -ping run-id|host:port : ping server, exit with 0 if found -debug N|N,M,O... : enable debug 0-N or N and M and O ... Examples # Get test path, use '.' to get a single path or a specific path/file pattern 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 runconfigs file with fname ;; process args (define remargs (args:get-args (argv) (list "-start-dir" "-server" "-port" "-log" ) (list "-h" "-help" "--help" "-manual" "-version" "-list-servers" "-kill-servers" "-repl" "-v" ;; verbose 2, more than normal (normal is 1) "-q" ;; quiet 0, errors/warnings only "-diff-rep" ) args:arg-hash 0)) ;; Add args that use remargs here ;; (if (and (not (null? remargs)) (not (or (args:get-arg "-runstep") (args:get-arg "-envcap") (args:get-arg "-envdelta") ) )) (debug:print-error 0 *default-log-port* "Unrecognised arguments: " (string-intersperse (if (list? remargs) remargs (argv)) " "))) ;; before doing anything else change to the start-dir if provided ;; (if (args:get-arg "-start-dir") (if (file-exists? (args:get-arg "-start-dir")) (let ((fullpath (common:real-path (args:get-arg "-start-dir")))) (setenv "PWD" fullpath) (change-directory fullpath)) (begin (debug:print-error 0 *default-log-port* "non-existant start dir " (args:get-arg "-start-dir") " specified, exiting.") (exit 1)))) ;; The watchdog is to keep an eye on things like db sync etc. ;; (define *watchdog* (make-thread (lambda () (handle-exceptions exn (begin (print-call-chain) (print " message: " ((condition-property-accessor 'exn 'message) exn))) (common:watchdog))) "Watchdog thread")) ;;====================================================================== ;; Strive for clean exit handling ;;====================================================================== (define (server-exit-procedure) (on-exit (lambda () ;; close the databases, ensure the pkt is removed! (server:shutdown) 0))) ;; Copied from the SDL2 examples. ;; ;; Schedule quit! to be automatically called when your program exits normally. (on-exit server-exit-procedure) ;; Install a custom exception handler that will call quit! and then ;; call the original exception handler. This ensures that quit! will ;; be called even if an unhandled exception reaches the top level. (current-exception-handler (let ((original-handler (current-exception-handler))) (lambda (exception) (server-exit-procedure) (original-handler exception)))) ;;(if (not (args:get-arg "-server")) ;; (thread-start! *watchdog*)) ;; if starting a server; wait till we get to running state before kicking off watchdog #;(let* ((no-watchdog-args '("-list-runs" "-testdata-csv" "-list-servers" "-server" "-list-disks" "-list-targets" "-show-runconfig" ;;"-list-db-targets" "-show-runconfig" "-show-config" "-show-cmdinfo" "-cleanup-db")) (no-watchdog-args-vals (filter (lambda (x) x) (map args:get-arg no-watchdog-args))) (start-watchdog (null? no-watchdog-args-vals))) ;;(BB> "no-watchdog-args="no-watchdog-args "no-watchdog-args-vals="no-watchdog-args-vals) (if start-watchdog (thread-start! *watchdog*))) ;; bracket open-output-file with code to make leading directory if it does not exist and handle exceptions (define (open-logfile logpath) (condition-case (let* ((log-dir (or (pathname-directory logpath) "."))) (if (not (directory-exists? log-dir)) (system (conc "mkdir -p " log-dir))) (open-output-file logpath)) (exn () (debug:print-error 0 *default-log-port* "Could not open log file for write: "logpath) (define *didsomething* #t) (exit 1)))) ;; this segment will run launch:setup only if -log is not set. This is fairly safe as servers are not ;; manually started and thus should never be started in a non-megatest area. Thus no need to handle situation ;; where (launch:setup) returns #f? ;; #;(if (or (args:get-arg "-log")(args:get-arg "-server")) ;; redirect the log always when a server (handle-exceptions exn (begin (print "ERROR: Failed to switch to log output. " ((condition-property-accessor 'exn 'message) exn)) ) (let* ((tl (or (args:get-arg "-log")(launch:setup))) ;; run launch:setup if -server, ensure we do NOT run launch:setup if -log specified (logf (or (args:get-arg "-log") ;; use -log unless we are a server, then craft a logfile name (conc tl "/logs/server-" (current-process-id) "-" (get-host-name) ".log"))) (oup (open-logfile logf))) (if (not (args:get-arg "-log")) (hash-table-set! args:arg-hash "-log" logf)) ;; fake out future queries of -log (debug:print-info 0 *default-log-port* "Sending log output to " logf) (set! *default-log-port* oup)))) (if (or (args:get-arg "-h") (args:get-arg "-help") (args:get-arg "--help")) (begin (print help) (exit))) (if (args:get-arg "-version") (begin (print (common:version-signature)) ;; (print megatest-version) (exit))) (define *didsomething* #f) ;; ready? start the server ;; (if (args:get-arg "-server") (let ((mode (string->symbol (args:get-arg "-server")))) (print "Mode: " mode) (case mode ((main)(print "Starting server in main mode.")) (else (print "Starting server in hidden mode."))) ;; opens the port, drops the pkt, contacts other servers and then waits for messages (if (not (server:launch mode)) ;; (lambda (pktrecvd)(print "Received: " pktrecvd)))) (exit 1)) (set! *didsomething* #t))) (if (args:get-arg "-repl") (begin ;; user will have to start the server manually (print "Run: (server:start-nmsg 'main) to start the server") (import extras) ;; might not be needed ;; (import csi) (import readline) (import apropos) (import portlogger) ;; (import (prefix sqlite3 sqlite3:)) ;; doesn't work ... (install-history-file (get-environment-variable "HOME") ".megatest_history") ;; [homedir] [filename] [nlines]) (current-input-port (make-readline-port "megatest> ")) (repl) (set! *didsomething* #t))) |
Modified mtut.scm from [848d0d5914] to [e0feef8240].
︙ | ︙ | |||
27 28 29 30 31 32 33 | (prefix dbi dbi:) nanomsg) (declare (uses common)) (declare (uses megatest-version)) (declare (uses margs)) (declare (uses configf)) | | | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | (prefix dbi dbi:) nanomsg) (declare (uses common)) (declare (uses megatest-version)) (declare (uses margs)) (declare (uses configf)) (declare (uses rmt)) (use ducttape-lib) (include "megatest-fossil-hash.scm") (require-library stml) |
︙ | ︙ | |||
138 139 140 141 142 143 144 145 146 147 148 149 150 151 | -version : print megatest version (currently " megatest-version ") Run management: run : initiate or resume a run, already completed and in-progress tests are not affected. rerun-clean : clean and rerun all not completed pass/fail tests rerun-all : clean and rerun entire run remove : remove runs set-ss : set state/status archive : compress and move test data to archive disk kill : stop tests or entire runs db : database utilities Queries: | > > | 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | -version : print megatest version (currently " megatest-version ") Run management: run : initiate or resume a run, already completed and in-progress tests are not affected. rerun-clean : clean and rerun all not completed pass/fail tests rerun-all : clean and rerun entire run kill-run : kill all tests in run kill-rerun : kill all tests in run and restart non-completed tests remove : remove runs set-ss : set state/status archive : compress and move test data to archive disk kill : stop tests or entire runs db : database utilities Queries: |
︙ | ︙ | |||
245 246 247 248 249 250 251 252 253 254 255 256 257 258 | )) ;; alist to map actions to old megatest commands (define *action-keys* '((run . "-run") (rerun-clean . "-rerun-clean") (rerun-all . "-rerun-all") (sync . "") (archive . "-archive") (set-ss . "-set-state-status") (remove . "-remove-runs"))) ;; manually keep this list updated from the keys to ;; the case *action* near the end of this file. | > > | 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | )) ;; alist to map actions to old megatest commands (define *action-keys* '((run . "-run") (rerun-clean . "-rerun-clean") (rerun-all . "-rerun-all") (kill-run . "-kill-runs") (kill-rerun . "-kill-rerun") (sync . "") (archive . "-archive") (set-ss . "-set-state-status") (remove . "-remove-runs"))) ;; manually keep this list updated from the keys to ;; the case *action* near the end of this file. |
︙ | ︙ | |||
490 491 492 493 494 495 496 497 498 499 500 501 502 503 | (define-inline (decode data) (with-input-from-string data (lambda () (read)))) (define (is-port-in-use port-num) (let* ((ret #f)) (let-values (((inp oup pid) (process "netstat" (list "-tulpn" )))) (let loop ((inl (read-line inp))) (if (not (eof-object? inl)) (begin | > > | 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 | (define-inline (decode data) (with-input-from-string data (lambda () (read)))) ;; moved to portlogger - TODO: remove from here and get from portlogger ;; (define (is-port-in-use port-num) (let* ((ret #f)) (let-values (((inp oup pid) (process "netstat" (list "-tulpn" )))) (let loop ((inl (read-line inp))) (if (not (eof-object? inl)) (begin |
︙ | ︙ | |||
1441 1442 1443 1444 1445 1446 1447 | ; (hash-table-set! args:arg-hash "-log" logf)) ;; fake out future queries of -log (print *default-log-port* "Sending log output to " logf) (set! *default-log-port* oup) ))) (if *action* (case (string->symbol *action*) | | | 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 | ; (hash-table-set! args:arg-hash "-log" logf)) ;; fake out future queries of -log (print *default-log-port* "Sending log output to " logf) (set! *default-log-port* oup) ))) (if *action* (case (string->symbol *action*) ((run remove rerun rerun-clean rerun-all set-ss archive kill list kill-run kill-rerun) (let* ((mtconfdat (simple-setup (args:get-arg "-start-dir"))) (mtconf (car mtconfdat)) (area (args:get-arg "-area")) ;; look up the area to dispatch to from [areas] section (areasec (if area (configf:lookup mtconf "areas" area) #f)) (areadat (if areasec (common:val->alist areasec) #f)) (area-path (if areadat (alist-ref 'path areadat) #f)) (pktsdirs (configf:lookup mtconf "setup" "pktsdirs")) |
︙ | ︙ | |||
1620 1621 1622 1623 1624 1625 1626 | (let* ((rep (start-nn-server portnum)) (mtconfdat (simple-setup (args:get-arg "-start-dir"))) (mtconf (car mtconfdat)) (contact (configf:lookup mtconf "listener" "owner")) (script (configf:lookup mtconf "listener" "script"))) (print "Listening on port " portnum " for messages.") (set-signal-handler! signal/int (lambda (signum) | | | | | | | | | | | | | | | | | | | | | | | | | | < < < | | | | | | | | | | | | | | | | | | | | | | | | 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 | (let* ((rep (start-nn-server portnum)) (mtconfdat (simple-setup (args:get-arg "-start-dir"))) (mtconf (car mtconfdat)) (contact (configf:lookup mtconf "listener" "owner")) (script (configf:lookup mtconf "listener" "script"))) (print "Listening on port " portnum " for messages.") (set-signal-handler! signal/int (lambda (signum) (set! *time-to-exit* #t) (debug:print-error 0 *default-log-port* "Received signal " signum " sending email befor exiting !!") (let ((email-body (mtut:stml->string (s:body (s:p (conc "Received signal " signum ". Lister has been terminated on host " (get-environment-variable "HOST") ". ")))))) (sendmail contact "Listner has been terminated." email-body use_html: #t)) (exit))) (set-signal-handler! signal/term (lambda (signum) (set! *time-to-exit* #t) (debug:print-error 0 *default-log-port* "Received signal " signum " sending email befor exiting !!") (let ((email-body (mtut:stml->string (s:body (s:p (conc "Received signal " signum ". Lister has been terminated on host " (get-environment-variable "HOST") ". ")))))) (sendmail contact "Listner has been terminated." email-body use_html: #t)) (exit))) ;;(set-signal-handler! signal/term special-signal-handler) (let loop ((instr (nn-recv rep))) ;;(nn-send rep "3.9") (with-input-from-pipe (conc "/usr/bin/uptime | cut -d':' -f4 | awk '{print $1}' | cut -d',' -f1") (lambda() (let loop ((inl (read-line))) (if (not (eof-object? inl)) (begin ;;(print "fdk73: " inl ":") ;;(set! current-list-ciaf (append! current-list-ciaf (list (string-substitute "\\s+$" "" inl)))) (nn-send rep inl) (loop(read-line))) )))) ;;(print (isys "/usr/bin/uptime" foreach-stdout-thunk: foreach-stdout)) (let ((ctime (date->string (current-date)))) (if (equal? instr "time-to-die") (begin (debug:print 0 *default-log-port* ctime " received '" instr "'. Time to sucide." ) (let ((pid (current-process-id))) (debug:print 0 *default-log-port* "Killing current process (pid=" pid ")") (system (conc "kill " pid)))) (begin (debug:print 0 *default-log-port* ctime " received " instr ) ;(nn-send rep "ok") (if (not (equal? instr "ping")) (begin (debug:print 0 *default-log-port* ctime " running \"" script " " instr "\"") ;(system (conc script " '" instr "'")) (process-run script (list instr )) (debug:print 0 *default-log-port* ctime " done" )) (begin (if (not (equal? instr "load")) (print "Checking load") ) ) ) ))) (loop (nn-recv rep)))) (print "ERROR: Port " portnum " already in use. Try another port"))))))) ((tlisten) |
︙ | ︙ |
Added nmsg-transport.scm version [a75db0ab66].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 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 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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | ;; Copyright 2006-2012, Matthew Welland. ;; ;; This file is part of Megatest. ;; ;; Megatest is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; ;; Megatest is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with Megatest. If not, see <http://www.gnu.org/licenses/>. ;;====================================================================== ;; Support routines for nmsg usage. ;; This should be reusable, non-megatest specific stuff ;;====================================================================== (declare (unit nmsg-transport)) (module nmsg-transport ( nmsg:start-server nmsg:open-send-close nmsg:open-send-receive nmsg:recv nmsg:send nmsg:close ) (import scheme posix chicken data-structures ports) (use nanomsg srfi-18) ;;start a server, returns the connection ;; (define (nmsg:start-server portnum) (let ((rep (nn-socket 'rep))) (handle-exceptions exn (let ((emsg ((condition-property-accessor 'exn 'message) exn))) (print "ERROR: Failed to start server \"" emsg "\"") #f) (nn-bind rep (conc "tcp://*:" portnum))) rep)) ;; open connection to server, send message, close connection ;; ;; to take an action on failure use proc which is called with the error info ;; (proc exn errormsg) ;; ;; returns the response or #f if no response within timeout ;; (define (nmsg:open-send-close host-port msg #!key (timeout 3)(proc #f)) ;; default timeout is 3 seconds (let ((req (nn-socket 'req)) (uri (conc "tcp://" host-port)) (res #f)) (handle-exceptions exn (let ((emsg ((condition-property-accessor 'exn 'message) exn))) ;; call proc on fail (if proc (proc exn emsg)) #f) (nn-connect req uri) (print "Connected to the server " ) (nn-send req msg) (print "Request Sent") (let* ((th1 (make-thread (lambda () (let ((resp (nn-recv req))) (nn-close req) (set! res resp))) "recv thread")) (th2 (make-thread (lambda () (thread-sleep! timeout) (thread-terminate! th1)) "timer thread"))) (thread-start! th1) (thread-start! th2) (thread-join! th1) res)))) ;; default timeout is 3 seconds ;; (define (nmsg:open-send-receive host-port msg #!key (timeout 3)(proc #f)) (let ((req (nn-socket 'req)) (uri (conc "tcp://" host-port)) (res #f)) (handle-exceptions exn (let ((emsg ((condition-property-accessor 'exn 'message) exn))) ;; take action on fail (if proc (proc exn emsg)) #f) (nn-connect req uri) (nn-send req msg) (let* ((th1 (make-thread (lambda () (let ((resp (nn-recv req))) (nn-close req) (print resp) (set! res resp))) "recv thread")) (th2 (make-thread (lambda () (thread-sleep! timeout) (thread-terminate! th1)) "timer thread"))) (thread-start! th1) (thread-start! th2) (thread-join! th1) res)))) (define nmsg:close nn-close) (define nmsg:recv nn-recv) (define nmsg:send nn-send) ) |
Modified portlogger-example.scm from [79b0759ae8] to [075b5430bd].
︙ | ︙ | |||
13 14 15 16 17 18 19 20 21 | ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with Megatest. If not, see <http://www.gnu.org/licenses/>. (declare (uses portlogger)) (print (apply portlogger:main (cdr (argv)))) | > > > > > > > > | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with Megatest. If not, see <http://www.gnu.org/licenses/>. (declare (uses portlogger)) (import portlogger) (use trace (prefix sqlite3 sqlite3:)) (trace portlogger:open-db portlogger:take-port portlogger:open-run-close sqlite3:execute ) (print (apply portlogger:main (cdr (argv)))) |
Modified portlogger.scm from [8b8ee119e5] to [6ef6750d8e].
︙ | ︙ | |||
13 14 15 16 17 18 19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with Megatest. If not, see <http://www.gnu.org/licenses/>. ;; | > | > > > > > > > > > > > > > > > | > > > > | | > > | | > > > > | > > > > > > > > | | | < < < < < < < < | < | | | | | | | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 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 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 102 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 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with Megatest. If not, see <http://www.gnu.org/licenses/>. ;; (declare (unit portlogger)) (module portlogger (portlogger:set-configdat! portlogger:set-printers! portlogger:set-default-log-port! portlogger:open-db portlogger:open-run-close portlogger:take-port portlogger:get-prev-used-port portlogger:find-port portlogger:set-port portlogger:release-port portlogger:set-failed portlogger:is-port-in-use portlogger:main ) (import scheme posix chicken data-structures ports) (require-extension (srfi 18) extras tcp s11n) (use srfi-1 posix srfi-69 hostinfo dot-locking z3 regex) (use (prefix sqlite3 sqlite3:)) (use (prefix mtconfigf configf:)) ;; lsof -i (define *configdat* #f) (define (portlogger:set-configdat! cfgdat) (set! *configdat* cfgdat)) (define (debug:print level port . params) (with-output-to-port port (lambda ()(apply print params)))) (define debug:print-error debug:print) (define *default-log-port* (current-error-port)) (define (portlogger:set-printers! pdebug pdebugerr) (set! debug:print pdebug) (set! debug:print-error pdebugerr)) (define (portlogger:set-default-log-port! port) (set! *default-log-port* port)) (define (portlogger:open-db fname) (let* ((avail #t) ;; for now - assume wait on journal not needed (tasks:wait-on-journal fname 5 remove: #t)) ;; wait up to about 10 seconds for the journal to go away (exists (file-exists? fname)) (db (if avail (sqlite3:open-database fname) (begin (system (conc "rm -f " fname)) (sqlite3:open-database fname)))) (handler (sqlite3:make-busy-timeout 136000)) (canwrite (file-write-access? fname))) (sqlite3:set-busy-handler! db handler) (sqlite3:execute db "PRAGMA synchronous = 0;") (sqlite3:execute db "CREATE TABLE IF NOT EXISTS ports ( port INTEGER PRIMARY KEY, state TEXT DEFAULT 'not-used', fail_count INTEGER DEFAULT 0, update_time TIMESTAMP DEFAULT (strftime('%s','now')) );") db)) (define (portlogger:open-run-close proc . params) (let* ((fname (conc "/tmp/." (current-user-name) "-portlogger.db")) (avail #t)) ;; (tasks:wait-on-journal fname 10))) ;; wait up to about 10 seconds for the journal to go away (handle-exceptions exn (begin ;; (release-dot-lock fname) (debug:print-error 0 *default-log-port* "portlogger:open-run-close failed. " proc " " params) (debug:print 0 *default-log-port* " message: " ((condition-property-accessor 'exn 'message) exn)) (debug:print 5 *default-log-port* "exn=" (condition->list exn)) (if (file-exists? fname)(delete-file fname)) ;; brutally get rid of it (print-call-chain (current-error-port))) (let* (;; (lock (obtain-dot-lock fname 2 9 10)) (db (portlogger:open-db fname)) (res (apply proc db params))) (sqlite3:finalize! db) ;; (release-dot-lock fname) res)))) ;; (fold-row PROC INIT DATABASE SQL . PARAMETERS) (define (portlogger:take-port db portnum) (let* ((qry1 (sqlite3:prepare db "INSERT INTO ports (port,state) VALUES (?,?);")) (qry2 (sqlite3:prepare db "UPDATE ports SET state=?,update_time=strftime('%s','now') WHERE port=?;")) (qry3 (sqlite3:prepare db "SELECT state FROM ports WHERE port=?;")) (res ;; (sqlite3:with-transaction ;; move the transaction up to the find-port call ;; db ;; (lambda () ;; (fold-row (lambda (var curr) (or var curr)) #f db "SELECT var FROM foo WHERE id=100;") (let* ((curr #f) (res #f)) (set! curr (sqlite3:fold-row (lambda (var curr) (or curr var curr)) "not-tried" qry3 portnum)) ;; (print "curr=" curr) (set! res (case (string->symbol curr) ((released) (sqlite3:execute qry2 "taken" portnum) 'taken) ((not-tried) (sqlite3:execute qry1 portnum "taken") 'taken) ((taken) 'already-taken) ((failed) 'failed) (else 'error))) ;; (print "res=" res) res))) ;; )) (sqlite3:finalize! qry1) (sqlite3:finalize! qry2) (sqlite3:finalize! qry3) res)) (define (portlogger:get-prev-used-port db) (handle-exceptions |
︙ | ︙ | |||
122 123 124 125 126 127 128 | (lambda (var curr) (or curr var curr)) #f db "SELECT (port) FROM ports WHERE state='released' LIMIT 1;"))) (define (portlogger:find-port db) | | | | | | > > > > | | | | | | | | | | | | > | > > > > > > > > > > > > > > > > > | 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | (lambda (var curr) (or curr var curr)) #f db "SELECT (port) FROM ports WHERE state='released' LIMIT 1;"))) (define (portlogger:find-port db) (let ((lowport (let ((val (configf:lookup *configdat* "server" "lowport"))) (if (and val (string->number val)) (string->number val) 32768)))) (sqlite3:with-transaction db (lambda () (let loop ((numtries 0)) (let* ((portnum (or (portlogger:get-prev-used-port db) (+ lowport ;; top of registered ports is 49152 but let's use ports in the registered range (random (- 64000 lowport)))))) (handle-exceptions exn (begin (debug:print 0 *default-log-port* "EXCEPTION: portlogger database probably overloaded or unreadable. If you see this message again remove /tmp/.$USER-portlogger.db") (debug:print 0 *default-log-port* " message: " ((condition-property-accessor 'exn 'message) exn)) (debug:print 5 *default-log-port* "exn=" (condition->list exn)) (print-call-chain (current-error-port)) (debug:print 0 *default-log-port* "Continuing anyway.")) (portlogger:take-port db portnum) ;; always "take the port" (if (portlogger:is-port-in-use portnum) portnum (loop (add1 numtries)))))))))) ;; set port to "released", "failed" etc. ;; (define (portlogger:set-port db portnum value) (sqlite3:execute db "UPDATE ports SET state=?,update_time=strftime('%s','now') WHERE port=?;" value portnum)) ;; release port (define (portlogger:release-port db portnum) (sqlite3:execute db "UPDATE ports SET state=?,update_time=strftime('%s','now') WHERE port=?;" "released" portnum)) ;; set port to failed (attempted to take but got error) ;; (define (portlogger:set-failed db portnum) (sqlite3:execute db "UPDATE ports SET state='failed',fail_count=fail_count+1,update_time=strftime('%s','now') WHERE port=?;" portnum)) ;; pulled from mtut - TODO: remove from mtut ;; (define (portlogger:is-port-in-use port-num) (let-values (((inp oup pid) (process "netstat" (list "-tulpn" )))) (let loop ((inl (read-line inp))) (if (not (eof-object? inl)) (begin (if (string-search (regexp (conc ":" port-num "\\s+")) inl) #t (loop (read-line inp)))))))) ;;====================================================================== ;; MAIN ;;====================================================================== (define (portlogger:main . args) (let* ((dbfname (conc "/tmp/." (current-user-name) "-portlogger.db")) |
︙ | ︙ | |||
178 179 180 181 182 183 184 | ((find)(portlogger:find-port db)) ((set) (let ((port (cadr args)) (state (caddr args))) (portlogger:set-port db (if (number? port) port (string->number port)) state) state)) | | > > | 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | ((find)(portlogger:find-port db)) ((set) (let ((port (cadr args)) (state (caddr args))) (portlogger:set-port db (if (number? port) port (string->number port)) state) state)) ((failed)(portlogger:set-failed db (string->number (cadr args))) 'failed) (else "nosuchcommand"))))) (sqlite3:finalize! db) result)) ;; (print (apply portlogger:main (cdr (argv)))) ) |
Modified rmt.scm from [0a05f35135] to [3585e1244b].
︙ | ︙ | |||
18 19 20 21 22 23 24 | ;; ;;====================================================================== (use format typed-records) ;; RADT => purpose of json format?? (declare (unit rmt)) (declare (uses api)) | > | < < < | < < < < < < | < < < < < < < > | < < < < | | < < > < | < < < < < < < < < < < < | < < < | < < < < < > | < < < < < | < < < | < > > | < < | < < < < < | < | > | < < < < < > > < < | < < | < < < < < > | < | < < < < < < > | < > | | < < < < > > > > > | < | > | < < < < < < < < < | | < < < | | < < < < < > > | | < < | < < < < < < < | > | | | < < < < < < < < < < > | | < < < | | < > | < < < < < < < < < < < | | < < > | < < < < < > | < < | < | < < > | < < < < > | | | < < < < < < < | | < < < < < < < > | | | | < < | > | > | | | < > | | < < < < < < < < < < < < < < < < < < < < < < < < < < | < | | < < < < < < > | < < < < < > > < < < < < | | < > | < | < < < < < < | > | < < < < > | < < < < | < > | | < > | < < < < | < < < | > | < < < < < < < < < < < < < > > | < < < | < < < < < < < < < < < < < > > | < < < < < < < < < | | < < < | < < < > > | | < | < < < < > > | < < < | < < < < < | > > < < < | | < | > | < | < < < | | < | < < < < < < < < | < < < | < | | < | < | < < | < < < | < < < | < < | | < | < < < | | < | < < < | < < < < < | < < < < | < < < < | < < < < < < < < < | < | < < | | < | | < < < | < < < | < < | < < | < > | | < < | | | < | > | < < < < < | < < < | | < | < < < | | < < | < > | < | > | < | < < < < < | | < < < < < < < < < < > > < < < | < < < < < < < < < < < | < < < < < < < < < | | < | < < < < | | < | < < | | < | < < | | < | < < | | < | > | > < | | < | < < | | < | < < < < < < < < | | < | < < | | < | < | | < | < < | < < | < < < < | < < | < < < | < | < < < < < < | < < | < < | < < | < < < < < < < < < < < < < < < < < < < < < < < < < | < | < < | < | < | < < | | < | < < | | < < | < < | | < | < < | | < | < < < | < < < < < < | < < < < < < < < < < < | < < < < < < < < < < < < < < < < | | > > | | < < < | < < < < < < < < < | < | > | < < < < < < | > | > > | | > | < | < < < | | < < < | < < | | < | > | < | < < | < < < < < < < < < < < < < < < < < < < < < < < < < < | < | | | | > | < | > | < | < < < | | > | < | > | < | < | > | > | < | < | > | > | | 18 19 20 21 22 23 24 25 26 27 28 29 30 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 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 102 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 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 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 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | ;; ;;====================================================================== (use format typed-records) ;; RADT => purpose of json format?? (declare (unit rmt)) (declare (uses api)) (import api) (include "common_records.scm") (use (prefix pkts pkts:) srfi-18) (defstruct cmdrec cmd (host #f) (run-ids #f) params) ;; call cmd on remote host (#f for any host) ;; ;; example: (rmt:run 'get-runs target run-name test-patt state status) ;; (define (rmt:run cmd . params) (let ((server (rmt:get-server cmdrec))) ;; look up server #f)) (define (rmt:get-connection-info . args) #t (print "Got here: rmt:get-connection-info")) (define (rmt:send-receive . args) #t (print "Got here: rmt:send-receive")) (define (rmt:print-db-stats . args) #t (print "Got here: rmt:print-db-stats")) (define (rmt:get-max-query-average . args) #t (print "Got here: rmt:get-max-query-average")) (define (rmt:open-qry-close-locally . args) #t (print "Got here: rmt:open-qry-close-locally")) (define (rmt:send-receive-no-auto-client-setup . args) #t (print "Got here: rmt:send-receive-no-auto-client-setup")) (define (rmt:kill-server . args) #t (print "Got here: rmt:kill-server")) (define (rmt:start-server . args) #t (print "Got here: rmt:start-server")) (define (rmt:login . args) #t (print "Got here: rmt:login")) (define (rmt:login-no-auto-client-setup . args) #t (print "Got here: rmt:login-no-auto-client-setup")) (define (rmt:general-call . args) #t (print "Got here: rmt:general-call")) (define (rmt:get-latest-host-load . args) #t (print "Got here: rmt:get-latest-host-load")) (define (rmt:sdb-qry . args) #t (print "Got here: rmt:sdb-qry")) (define (rmt:runtests . args) #t (print "Got here: rmt:runtests")) (define (rmt:get-run-record-ids . args) #t (print "Got here: rmt:get-run-record-ids")) (define (rmt:get-changed-record-ids . args) #t (print "Got here: rmt:get-changed-record-ids")) (define (rmt:get-tests-tags . args) #t (print "Got here: rmt:get-tests-tags")) (define (rmt:get-key-val-pairs . args) #t (print "Got here: rmt:get-key-val-pairs")) (define (rmt:get-keys . args) #t (print "Got here: rmt:get-keys")) (define (rmt:get-keys-write . args) #t (print "Got here: rmt:get-keys-write")) (define (rmt:get-key-vals . args) #t (print "Got here: rmt:get-key-vals")) (define (rmt:get-targets . args) #t (print "Got here: rmt:get-targets")) (define (rmt:get-target . args) #t (print "Got here: rmt:get-target")) (define (rmt:get-run-times . args) #t (print "Got here: rmt:get-run-times")) (define (rmt:register-test . args) #t (print "Got here: rmt:register-test")) (define (rmt:get-test-id . args) #t (print "Got here: rmt:get-test-id")) (define (rmt:get-test-info-by-id . args) #t (print "Got here: rmt:get-test-info-by-id")) (define (rmt:test-get-rundir-from-test-id . args) #t (print "Got here: rmt:test-get-rundir-from-test-id")) (define (rmt:open-test-db-by-test-id . args) #t (print "Got here: rmt:open-test-db-by-test-id")) (define (rmt:test-set-state-status-by-id . args) #t (print "Got here: rmt:test-set-state-status-by-id")) (define (rmt:set-tests-state-status . args) #t (print "Got here: rmt:set-tests-state-status")) (define (rmt:get-tests-for-run . args) #t (print "Got here: rmt:get-tests-for-run")) (define (rmt:synchash-get . args) #t (print "Got here: rmt:synchash-get")) (define (rmt:get-tests-for-run-mindata . args) #t (print "Got here: rmt:get-tests-for-run-mindata")) (define (rmt:get-tests-for-runs-mindata . args) #t (print "Got here: rmt:get-tests-for-runs-mindata")) (define (rmt:delete-test-records . args) #t (print "Got here: rmt:delete-test-records")) (define (rmt:test-set-state-status . args) #t (print "Got here: rmt:test-set-state-status")) (define (rmt:test-toplevel-num-items . args) #t (print "Got here: rmt:test-toplevel-num-items")) (define (rmt:get-matching-previous-test-run-records . args) #t (print "Got here: rmt:get-matching-previous-test-run-records")) (define (rmt:test-get-logfile-info . args) #t (print "Got here: rmt:test-get-logfile-info")) (define (rmt:test-get-records-for-index-file . args) #t (print "Got here: rmt:test-get-records-for-index-file")) (define (rmt:get-testinfo-state-status . args) #t (print "Got here: rmt:get-testinfo-state-status")) (define (rmt:test-set-log! . args) #t (print "Got here: rmt:test-set-log!")) (define (rmt:test-set-top-process-pid . args) #t (print "Got here: rmt:test-set-top-process-pid")) (define (rmt:test-get-top-process-pid . args) #t (print "Got here: rmt:test-get-top-process-pid")) (define (rmt:get-run-ids-matching-target . args) #t (print "Got here: rmt:get-run-ids-matching-target")) (define (rmt:test-get-paths-matching-keynames-target-new . args) #t (print "Got here: rmt:test-get-paths-matching-keynames-target-new")) (define (rmt:get-prereqs-not-met . args) #t (print "Got here: rmt:get-prereqs-not-met")) (define (rmt:get-count-tests-running-for-run-id . args) #t (print "Got here: rmt:get-count-tests-running-for-run-id")) (define (rmt:get-count-tests-running . args) #t (print "Got here: rmt:get-count-tests-running")) (define (rmt:get-count-tests-running-for-testname . args) #t (print "Got here: rmt:get-count-tests-running-for-testname")) (define (rmt:get-count-tests-running-in-jobgroup . args) #t (print "Got here: rmt:get-count-tests-running-in-jobgroup")) (define (rmt:set-state-status-and-roll-up-items . args) #t (print "Got here: rmt:set-state-status-and-roll-up-items")) (define (rmt:update-pass-fail-counts . args) #t (print "Got here: rmt:update-pass-fail-counts")) (define (rmt:top-test-set-per-pf-counts . args) #t (print "Got here: rmt:top-test-set-per-pf-counts")) (define (rmt:get-raw-run-stats . args) #t (print "Got here: rmt:get-raw-run-stats")) (define (rmt:get-test-times . args) #t (print "Got here: rmt:get-test-times")) (define (rmt:get-run-info . args) #t (print "Got here: rmt:get-run-info")) (define (rmt:get-num-runs . args) #t (print "Got here: rmt:get-num-runs")) (define (rmt:get-runs-cnt-by-patt . args) #t (print "Got here: rmt:get-runs-cnt-by-patt")) (define (rmt:register-run . args) #t (print "Got here: rmt:register-run")) (define (rmt:get-run-name-from-id . args) #t (print "Got here: rmt:get-run-name-from-id")) (define (rmt:delete-run . args) #t (print "Got here: rmt:delete-run")) (define (rmt:update-run-stats . args) #t (print "Got here: rmt:update-run-stats")) (define (rmt:delete-old-deleted-test-records . args) #t (print "Got here: rmt:delete-old-deleted-test-records")) (define (rmt:get-runs . args) #t (print "Got here: rmt:get-runs")) (define (rmt:simple-get-runs . args) #t (print "Got here: rmt:simple-get-runs")) (define (rmt:get-all-run-ids . args) #t (print "Got here: rmt:get-all-run-ids")) (define (rmt:get-prev-run-ids . args) #t (print "Got here: rmt:get-prev-run-ids")) (define (rmt:lock/unlock-run . args) #t (print "Got here: rmt:lock/unlock-run")) (define (rmt:get-run-status . args) #t (print "Got here: rmt:get-run-status")) (define (rmt:set-run-status . args) #t (print "Got here: rmt:set-run-status")) (define (rmt:update-run-event_time . args) #t (print "Got here: rmt:update-run-event_time")) (define (rmt:get-runs-by-patt . args) #t (print "Got here: rmt:get-runs-by-patt")) (define (rmt:find-and-mark-incomplete . args) #t (print "Got here: rmt:find-and-mark-incomplete")) (define (rmt:get-main-run-stats . args) #t (print "Got here: rmt:get-main-run-stats")) (define (rmt:get-var . args) #t (print "Got here: rmt:get-var")) (define (rmt:del-var . args) #t (print "Got here: rmt:del-var")) (define (rmt:set-var . args) #t (print "Got here: rmt:set-var")) (define (rmt:find-and-mark-incomplete-all-runs . args) #t (print "Got here: rmt:find-and-mark-incomplete-all-runs")) (define (rmt:get-previous-test-run-record . args) #t (print "Got here: rmt:get-previous-test-run-record")) (define (rmt:get-run-stats . args) #t (print "Got here: rmt:get-run-stats")) (define (rmt:teststep-set-status! . args) #t (print "Got here: rmt:teststep-set-status!")) (define (rmt:get-steps-for-test . args) #t (print "Got here: rmt:get-steps-for-test")) (define (rmt:get-steps-info-by-id . args) #t (print "Got here: rmt:get-steps-info-by-id")) (define (rmt:read-test-data . args) #t (print "Got here: rmt:read-test-data")) (define (rmt:read-test-data* . args) #t (print "Got here: rmt:read-test-data*")) (define (rmt:get-data-info-by-id . args) #t (print "Got here: rmt:get-data-info-by-id")) (define (rmt:testmeta-add-record . args) #t (print "Got here: rmt:testmeta-add-record")) (define (rmt:testmeta-get-record . args) #t (print "Got here: rmt:testmeta-get-record")) (define (rmt:testmeta-update-field . args) #t (print "Got here: rmt:testmeta-update-field")) (define (rmt:test-data-rollup . args) #t (print "Got here: rmt:test-data-rollup")) (define (rmt:csv->test-data . args) #t (print "Got here: rmt:csv->test-data")) (define (rmt:tasks-find-task-queue-records . args) #t (print "Got here: rmt:tasks-find-task-queue-records")) (define (rmt:tasks-add . args) #t (print "Got here: rmt:tasks-add")) (define (rmt:tasks-set-state-given-param-key . args) #t (print "Got here: rmt:tasks-set-state-given-param-key")) (define (rmt:tasks-get-last . args) #t (print "Got here: rmt:tasks-get-last")) (define (rmt:no-sync-set . args) #t (print "Got here: rmt:no-sync-set")) (define (rmt:no-sync-get/default . args) #t (print "Got here: rmt:no-sync-get/default")) (define (rmt:no-sync-del! . args) #t (print "Got here: rmt:no-sync-del!")) (define (rmt:no-sync-get-lock . args) #t (print "Got here: rmt:no-sync-get-lock")) (define (rmt:archive-get-allocations . args) #t (print "Got here: rmt:archive-get-allocations")) (define (rmt:archive-register-block-name . args) #t (print "Got here: rmt:archive-register-block-name")) (define (rmt:archive-allocate-testsuite/area-to-block . args) #t (print "Got here: rmt:archive-allocate-testsuite/area-to-block")) (define (rmt:archive-register-disk . args) #t (print "Got here: rmt:archive-register-disk")) (define (rmt:test-set-archive-block-id . args) #t (print "Got here: rmt:test-set-archive-block-id")) (define (rmt:test-get-archive-block-info . args) #t (print "Got here: rmt:test-get-archive-block-info")) |
Deleted rpc-transport.scm version [dd887f94ec].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Modified runs.scm from [ec89ed5162] to [0d98a3ef41].
︙ | ︙ | |||
2042 2043 2044 2045 2046 2047 2048 | (states (if state (string-split state ",") '())) (statuses (if status (string-split status ",") '())) (state-status (if (string? new-state-status) (string-split new-state-status ",") '(#f #f))) (rp-mutex (make-mutex)) (bup-mutex (make-mutex)) (keep-records (args:get-arg "-keep-records"))) ;; used in conjunction with -remove-runs to keep the records, TODO: consolidate this with "mode". | | | 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 | (states (if state (string-split state ",") '())) (statuses (if status (string-split status ",") '())) (state-status (if (string? new-state-status) (string-split new-state-status ",") '(#f #f))) (rp-mutex (make-mutex)) (bup-mutex (make-mutex)) (keep-records (args:get-arg "-keep-records"))) ;; used in conjunction with -remove-runs to keep the records, TODO: consolidate this with "mode". (let* ((write-access-actions '(remove-runs set-state-status archive run-wait kill-runs)) (dbfile (conc *toppath* "/megatest.db")) (readonly-mode (not (file-write-access? dbfile)))) (when (and readonly-mode (member action write-access-actions)) (debug:print-error 0 *default-log-port* "megatest.db is readonly. Cannot proceed with action ["action"] in which write-access isrequired .") (exit 1))) |
︙ | ︙ | |||
2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 | '())) (lasttpath "/does/not/exist/I/hope") (worker-thread #f)) (debug:print-info 4 *default-log-port* "runs:operate-on run=" run ", header=" header) (if (not (null? tests)) (begin (case action ((remove-runs) ;; (if (tasks:need-server run-id)(tasks:start-and-wait-for-server tdbdat run-id 10)) ;; seek and kill in flight -runtests with % as testpatt here ;; (if (equal? testpatt "%") (tasks:kill-runner target run-name testpatt) | > > > > < | 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 | '())) (lasttpath "/does/not/exist/I/hope") (worker-thread #f)) (debug:print-info 4 *default-log-port* "runs:operate-on run=" run ", header=" header) (if (not (null? tests)) (begin (case action ((kill-runs) (tasks:kill-runner target run-name "%") (debug:print 1 *default-log-port* "Killing tests for run: " runkey " " (db:get-value-by-header run header "runname")) ) ((remove-runs) ;; (if (tasks:need-server run-id)(tasks:start-and-wait-for-server tdbdat run-id 10)) ;; seek and kill in flight -runtests with % as testpatt here ;; (if (equal? testpatt "%") (tasks:kill-runner target run-name testpatt) ;; (debug:print 0 *default-log-port* "not attempting to kill any run launcher processes as testpatt is " testpatt)) (debug:print 1 *default-log-port* "Removing tests for run: " runkey " " (db:get-value-by-header run header "runname"))) ((set-state-status) ;; (if (tasks:need-server run-id)(tasks:start-and-wait-for-server tdbdat run-id 10)) (debug:print 1 *default-log-port* "Modifying state and staus for tests for run: " runkey " " (db:get-value-by-header run header "runname"))) ((print-run) (debug:print 1 *default-log-port* "Printing info for run " runkey ", run=" run ", tests=" tests ", header=" header) |
︙ | ︙ | |||
2192 2193 2194 2195 2196 2197 2198 | ((started) ;; if last visit was within last second, sleep 1 second (if (< (- now last-visit) 1.0) (thread-sleep! 1.0)) (hash-table-set! backgrounded-remove-last-visit test-fulln (current-seconds)) ;; send to back of line, loop (let ((newtal (append tal (list test)))) | | | 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 | ((started) ;; if last visit was within last second, sleep 1 second (if (< (- now last-visit) 1.0) (thread-sleep! 1.0)) (hash-table-set! backgrounded-remove-last-visit test-fulln (current-seconds)) ;; send to back of line, loop (let ((newtal (append tal (list test)))) (loop (car newtal)(cdr newtal))) ) ((done) ;; drop this one; if remaining, loop, else finish (hash-table-set! backgrounded-remove-last-visit test-fulln (current-seconds)) (let ((subrun-remove-succeeded (hash-table-ref/default backgrounded-remove-result test-fulln 'exception))) (cond ((eq? subrun-remove-succeeded 'exception) |
︙ | ︙ | |||
2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 | (loop new-test-dat tal) (loop (car tal)(append tal (list new-test-dat))))) (begin (runs:remove-test-directory new-test-dat mode) ;; 'remove-all) (if (not (null? tal)) (loop (car tal)(cdr tal))))))) (rmt:update-run-stats run-id (rmt:get-raw-run-stats run-id))) ((set-state-status) (let* ((new-state (car state-status)) (new-status (cadr state-status)) (test-id (db:test-get-id test)) (test-run-dir (db:test-get-rundir new-test-dat)) (has-subrun (and (subrun:subrun-test-initialized? test-run-dir) (not (subrun:subrun-removed? test-run-dir))))) | > > > > > > > > > > > > > > > > > > > > > > | 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 | (loop new-test-dat tal) (loop (car tal)(append tal (list new-test-dat))))) (begin (runs:remove-test-directory new-test-dat mode) ;; 'remove-all) (if (not (null? tal)) (loop (car tal)(cdr tal))))))) (rmt:update-run-stats run-id (rmt:get-raw-run-stats run-id))) ((kill-runs) ;; RUNNING -> KILLREQ ;; LAUNCHED,RUNNING,REMOTEHOSTSTART -> NOT STARTED (cond ((and has-subrun (member test-state (list "RUNNING" "LAUNCHED" "REMOTEHOSTSTART" "KILLREQ"))) (common:send-thunk-to-background-thread (lambda () (let* ((subrun-remove-succeeded (subrun:kill-subrun run-dir keep-records))) #t))) (if (not (null? tal)) (loop (car tal)(cdr tal))) ) ((member test-state (list "RUNNING" "LAUNCHED" "REMOTEHOSTSTART" "KILLREQ")) (debug:print 1 *default-log-port* "INFO: issuing killreq to test "test-fulln) (mt:test-set-state-status-by-id run-id (db:test-get-id test) "KILLREQ" "n/a" #f) (if (not (null? tal)) (loop (car tal)(cdr tal)))) (else (if (not (null? tal)) (loop (car tal)(cdr tal))) ))) ((set-state-status) (let* ((new-state (car state-status)) (new-status (cadr state-status)) (test-id (db:test-get-id test)) (test-run-dir (db:test-get-rundir new-test-dat)) (has-subrun (and (subrun:subrun-test-initialized? test-run-dir) (not (subrun:subrun-removed? test-run-dir))))) |
︙ | ︙ |
Deleted sdb.scm version [3f78d1737e].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Modified server.scm from [8c943654ab] to [9fd201bbc1].
︙ | ︙ | |||
13 14 15 16 17 18 19 20 21 22 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with Megatest. If not, see <http://www.gnu.org/licenses/>. ;; (require-extension (srfi 18) extras tcp s11n) (use srfi-1 posix regex regex-case srfi-69 hostinfo md5 message-digest | > > > > > > > > > | > > > | < > | > | | > > > > < < < < < < < > > > > > | > > > > > > > > > > | | > | > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > < > | < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > | > > > > > > > > > > > > > > > | | > > > | > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > | > > > > | < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 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 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 102 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 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 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 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with Megatest. If not, see <http://www.gnu.org/licenses/>. ;; ;;====================================================================== ;; ;; This is the Megatest specific stuff for starting and maintaining a ;; server. Anything that talks to the server should go in client.scm (maybe - might get rid of client.scm) ;; General nanomsg stuff (not Megatest specific) should go in the ;; nmsg-transport.scm file. ;; ;;====================================================================== (require-extension (srfi 18) extras tcp s11n) (use srfi-1 posix regex regex-case srfi-69 hostinfo md5 message-digest directory-utils posix-extras matchable typed-records pkts) (use spiffy uri-common intarweb http-client spiffy-request-vars) (declare (unit server)) (declare (uses common)) (declare (uses db)) (import db) ;; Basic stuff for safely kicking off a server (declare (uses portlogger)) (import portlogger) (declare (uses nmsg-transport)) (import nmsg-transport) ;; Might want to bring the daemonizing back ;; (declare (uses daemon)) (include "common_records.scm") (include "db_records.scm") ;;====================================================================== ;; P K T S S T U F F ;;====================================================================== ;;====================================================================== ;; N A N O M S G B A S E D S E R V E R ;;====================================================================== ;; information about me as a server ;; (defstruct area (conn #f) (port #f) (myaddr #f) (hosts (make-hash-table)) pktid ;; get pkt from hosts table if needed pktfile pktsdir mtrah (mutex (make-mutex)) ) ;; make it a global? Well, it is local to area module (define *area-info* (make-area)) (define *pktspec* `((server (hostname . h) (port . p) (pid . i) (ipaddr . a) ) (data (hostname . h) ;; sender hostname (port . p) ;; sender port (ipaddr . a) ;; sender ip (hostkey . k) ;; sending host key - store info at server under this key (servkey . s) ;; server key - this needs to match at server end or reject the msg (format . f) ;; sb=serialized-base64, t=text, sx=sexpr, j=json (data . d) ;; base64 encoded slln data ))) (define (server:get-mtrah) (or (get-environment-variable "MT_RUN_AREA_HOME") (if (file-exists? "megatest.config") (current-directory) #f))) ;; get a port ;; start the nmsg server ;; look for other servers ;; contact other servers and compile list of servers ;; there are two types of server ;; main servers - dashboards, runners and dedicated servers - need pkt ;; passive servers - test executers, step calls, list-runs - no pkt ;; (define (server:start-nmsg #!optional (force-server-type #f)) (mutex-lock! (area-mutex *area-info*)) (let* ((server-type (or force-server-type (if (args:any? "-run" "-server") 'main 'passive))) (port-num (portlogger:open-run-close portlogger:find-port)) (best-ip (server:get-my-best-address)) (area-conn (nmsg:start-server port-num)) ;; (pktspec (area-pktspec *area-info*)) (mtdir (or (server:get-mtrah) (begin (print "ERROR: megatest.config not found and MT_RUN_AREA_HOME is not set.") #f))) (pktdir (conc mtdir "/.server-pkts"))) (if (not mtdir) #f (begin (if (not (directory? pktdir))(create-directory pktdir)) ;; server is started, now create pkt if needed (print "Starting server in " server-type " mode") (if (eq? server-type 'main) (begin (area-pktid-set! *area-info* (write-alist->pkt pktdir `((hostname . ,(get-host-name)) (ipaddr . ,best-ip) (port . ,port-num) (pid . ,(current-process-id))) pktspec: *pktspec* ptype: 'server)) (area-pktfile-set! *area-info* (conc pktdir "/" (area-pktid *area-info*) ".pkt")))) ;; set all the area info in the (area-pktsdir-set! *area-info* pktdir) (area-mtrah-set! *area-info* mtdir) (area-conn-set! *area-info* area-conn) (area-port-set! *area-info* port-num) (mutex-unlock! (area-mutex *area-info*)) area-conn)))) ;; action: ;; immediate - quick actions, no need to put in queues ;; dbwrite - put in dbwrite queue ;; dbread - put in dbread queue ;; oslong - os actions, e.g. du, that could take a long time ;; osshort - os actions that should be quick, e.g. df ;; (define (server:std-handler dat) (let* ((from-host (alist-ref 'hostname dat)) (from-port (alist-ref 'port dat)) (servkey (alist-ref 'servkey dat)) (hostkey (alist-ref 'hostkey dat)) (data (alist-ref 'data dat)) (action (alist-ref 'action dat))) ;; first, if you don't know who I am then I'm ignoring you (if (not (equal? servkey (area-pktid *area-info*))) `(#f . "I don't know you") ;; immediately return this (case action ;; else carry on ((immediate) (case data ((ping) `(#t "success")) (else `(#t "I didn't recognise " data)))) ((dbwrite) `(#t "db write submitted")) ((dbread) `(#t "db read submitted")) ((oslong) `(#t "os long submitted")) ((dbwrite) `(#t "os short submitted")) (else `(#f "unrecognised action" action)))))) ;; Call this to start the actual server ;; ;; start_server ;; ;; mode: ' ;; handler: proc which takes pktrecieved as argument ;; (define (server:launch mode #!optional (proc server:std-handler)) (let* ((start-time (current-seconds)) (rep (server:start-nmsg mode)) (last-msg-time (current-seconds)) (th1 (make-thread (lambda () (let loop () (let ((dat (server:receive rep))) (set! last-msg-time (current-seconds)) ;; (print "received: " pktdat) (if (not (eof-object? dat)) (let ((resdat (proc dat))) (print "Got " dat) (print "Responding with " resdat) (nmsg:send rep (sexpr->string resdat)) ;; (with-output-to-string (lambda ()(write resdat)))) (loop)))))) "message handler")) (th2 (make-thread (lambda () (let loop () (thread-sleep! 10) (if (> (- (current-seconds) last-msg-time) 60) ;; timeout after 60 seconds (begin (print "Waited for 60 seconds and no messages, exiting now.") (exit)) (loop))))))) (thread-start! th1) (thread-start! th2) (thread-join! th1))) ;; get the response ;; (define (server:receive rep) (let ((instr (nmsg:recv rep))) (if (string? instr) (string->sexpr instr) ;; (with-input-from-string instr read) instr))) (define (server:shutdown) (let ((conn (area-conn *area-info*)) (pktf (area-pktfile *area-info*)) (port (area-port *area-info*))) (if conn (begin (if pktf (delete-file* pktf)) (server:send-all "imshuttingdown") (nmsg:close conn) (portlogger:open-run-close portlogger:release-port port))))) (define (server:send-all msg) #f) ;; given a area record look up all the packets ;; (define (server:get-all-server-pkts rec) (let ((all-pkt-files (glob (conc (area-pktsdir rec) "/*.pkt")))) ;; (pktspec (area-pktspec rec))) (map (lambda (pkt-file) (read-pkt->alist pkt-file pktspec: *pktspec*)) all-pkt-files))) #;((Z . "9a0212302295a19610d5796fce0370fa130758e9") (port . "34827") (pid . "28748") (hostname . "zeus") (T . "server") (D . "1549427032.0")) ;; srvpkt is the info for the server we wish to send the message to ;; (define (server:send servpkt data action) (let* ((port (alist-ref 'port servpkt)) (host (alist-ref 'hostname servpkt)) (ip (alist-ref 'ipaddr servpkt)) (hkey (alist-ref 'Z servpkt)) (addr (conc (or ip host) ":" port)) ;; fall back to host if ip not provided (myport (area-port *area-info*)) (myhost (area-myaddr *area-info*)) (mykey (area-pktid *area-info*)) (msg (with-output-to-string (lambda () (write `((hostname . ,myhost) (port . ,myport) (servkey . ,hkey) ;; server looks at this to ensure message is for them (hostkey . ,mykey) (action . ,action) ;; formating of the message (data . ,data)) ;; *pktspec* ;; ptype: 'data)) ))))) ;; (print "msg: " msg) (if (and port host) (string->sexpr ;; begin ;; (print "sending ")(pp msg)(print " to " addr) (nmsg:open-send-receive addr msg)) #f))) (define (server:get-my-best-address) (ip->string (car (filter (lambda (x) (not (eq? (u8vector-ref x 0) 127))) (vector->list (hostinfo-addresses (hostname->hostinfo "zeus"))))))) ;; whoami? I am my pkt ;; (define (server:whoami? area) (hash-table-ref/default (area-hosts area)(area-pktid area) #f)) ;;====================================================================== ;; "Client side" operations ;;====================================================================== ;; convert to/from string / sexpr (define (string->sexpr str) (if (string? str) (with-input-from-string str read) str)) (define (sexpr->string s) (with-output-to-string (lambda ()(write s)))) ;; is the server alive? ;; (define (server:ping servpkt) (let* ((start-time (current-milliseconds)) (res (server:send servpkt 'ping 'immediate))) (cons (- (current-milliseconds) start-time) res))) ;; (equal? res "got ping")))) ;; look up all pkts and get the server id (the hash), port, host/ip ;; store this info in the global struct *area-info* ;; ;; pass in *area-info* as rec ;; (define (server:update-known-servers rec) ;; readll all pkts ;; foreach pkt; if it isn't me ping the server; if alive, add to hosts hash, else rm the pkt (let ((all-pkts (delete-duplicates (append (server:get-all-server-pkts rec) (hash-table-values (area-hosts rec))))) (hostshash (area-hosts rec)) (my-id (area-pktid rec)) (pktsdir (area-pktsdir rec)) ;; needed to remove pkts from non-responsive servers ) (for-each (lambda (servpkt) (let* ((res (server:ping servpkt)) (sid (alist-ref 'Z servpkt)) ;; Z code is our name for the server ) (match res ((qduration . payload) (print "Server pkt:")(pp servpkt) (print "res: ")(pp res) (match payload ((code message) (print "code: " code " message: " message) (if code (hash-table-set! hostshash sid servpkt) (print "got #f from the server, not sure what that means!"))) (else (print "Got ")(pp res)(print " from server ")(pp servpkt) " but response did not match (#f/#t . msg)"))) (else ;; here we delete the pkt - can't reach the server, remove it ;; however this logic is inadequate. we should mark the server as checked ;; and not good, if it happens a second time - then remove the pkt ;; or something similar. I.e. don't be too quick to assume the server is wedged or dead ;; could be it is simply too busy to reply (print "clearing out server " sid) (delete-file* (conc pktsdir "/" sid ".pkt")) (hash-table-delete! hostshash side))))) all-pkts))) ;; send out an "I'm about to exit notice to all known servers" ;; (define (server:imminent-death) '()) ;;====================================================================== ;; S E R V E R U T I L I T I E S ;;====================================================================== ;; get a signature for identifing this process (define (server:get-process-signature) (cons (get-host-name)(current-process-id))) |
Modified subrun.scm from [bb7061fde4] to [ad3bd444b3].
︙ | ︙ | |||
116 117 118 119 120 121 122 123 124 125 126 127 128 129 | (subrun:exec-sub-megatest test-run-dir action-switches-str "remove"))) (if remove-result (begin (subrun:set-subrun-removed test-run-dir) #t) #f)) #t)) (define (subrun:launch-cmd test-run-dir) (if (subrun:subrun-removed? test-run-dir) (subrun:unset-subrun-removed test-run-dir)) (let* ((log-prefix "run") (switches (subrun:selector+log-switches test-run-dir log-prefix)) | > > > > > > > > > | 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | (subrun:exec-sub-megatest test-run-dir action-switches-str "remove"))) (if remove-result (begin (subrun:set-subrun-removed test-run-dir) #t) #f)) #t)) (define (subrun:kill-subrun test-run-dir ) (if (and (not (subrun:subrun-removed? test-run-dir)) (subrun:subrun-test-initialized? test-run-dir)) (let* ((action-switches-str (conc "-kill-runs" )) (kill-result (subrun:exec-sub-megatest test-run-dir action-switches-str "kill"))) kill-result) #t)) (define (subrun:launch-cmd test-run-dir) (if (subrun:subrun-removed? test-run-dir) (subrun:unset-subrun-removed test-run-dir)) (let* ((log-prefix "run") (switches (subrun:selector+log-switches test-run-dir log-prefix)) |
︙ | ︙ |
Added util.scm version [8fad541d3c].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 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 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 102 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 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 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 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 | ;;====================================================================== ;; Copyright 2018, Matthew Welland. ;; ;; This file is part of Megatest. ;; ;; Megatest is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; ;; Megatest is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with Megatest. If not, see <http://www.gnu.org/licenses/>. ;; ;;====================================================================== ;;====================================================================== ;; Tests ;;====================================================================== (declare (unit util)) (declare (uses common)) (module util * (import chicken scheme data-structures extras srfi-13 ports ) ;;====================================================================== ;; L O C K I N G M E C H A N I S M S ;;====================================================================== ;; faux-lock is deprecated. Please use simple-lock below ;; (define (common:faux-lock keyname #!key (wait-time 8)(allow-lock-steal #t)) (if (rmt:no-sync-get/default keyname #f) ;; do not be tempted to compare to pid. locking is a one-shot action, if already locked for this pid it doesn't actually count (if (> wait-time 0) (begin (thread-sleep! 1) (if (eq? wait-time 1) ;; only one second left, steal the lock (begin (debug:print-info 0 *default-log-port* "stealing lock for " keyname) (common:faux-unlock keyname force: #t))) (common:faux-lock keyname wait-time: (- wait-time 1))) #f) (begin (rmt:no-sync-set keyname (conc (current-process-id))) (equal? (conc (current-process-id)) (conc (rmt:no-sync-get/default keyname #f)))))) (define (common:faux-unlock keyname #!key (force #f)) (if (or force (equal? (conc (current-process-id)) (conc (rmt:no-sync-get/default keyname #f)))) (begin (if (rmt:no-sync-get/default keyname #f) (rmt:no-sync-del! keyname)) #t) #f)) ;; simple lock. improve and converge on this one. ;; (define (common:simple-lock keyname) (rmt:no-sync-get-lock keyname)) (define (common:run-a-command cmd #!key (with-vars #f)) (let* ((pre-cmd (dtests:get-pre-command)) (post-cmd (dtests:get-post-command)) (fullcmd (if (or pre-cmd post-cmd) (conc pre-cmd cmd post-cmd) (conc "viewscreen " cmd)))) (debug:print-info 02 *default-log-port* "Running command: " fullcmd) (if with-vars (common:without-vars cmd) (common:without-vars fullcmd "MT_.*")))) ;; ideally put all this info into the db, no need to preserve it across moving homehost ;; ;; return list of ;; ( reachable? cpuload update-time ) (define (common:get-host-info hostname) (let* ((loadinfo (rmt:get-latest-host-load hostname)) ;; if this host happens to have been recently used by a test reuse the load data (load (car loadinfo)) (load-sample-time (cdr loadinfo)) (load-sample-age (- (current-seconds) load-sample-time)) (loadinfo-timeout-seconds 6) ;; this was 20 seconds, seems way too lax. Switch to 6 seconds (host-last-update-timeout-seconds 4) (host-rec (hash-table-ref/default *host-loads* hostname #f)) ) (cond ((< load-sample-age loadinfo-timeout-seconds) (list #t load-sample-time load)) ((and host-rec (< (current-seconds) (+ (host-last-update host-rec) host-last-update-timeout-seconds))) (list #t (host-last-update host-rec) (host-last-cpuload host-rec ))) ((common:unix-ping hostname) (list #t (current-seconds) (alist-ref 'adj-core-load (common:get-normalized-cpu-load hostname)))) ;; this is cheaper than you might think. get-normalized-cpu-load is cached for up to 5 seconds (else (list #f 0 -1) ;; bad host, don't use! )))) (define (get-uname . params) (let* ((uname-res (process:cmd-run->list (conc "uname " (if (null? params) "-a" (car params))))) (uname #f)) (if (null? (car uname-res)) "unknown" (caar uname-res)))) (define (get-unix-df path) (let* ((df-results (process:cmd-run->list (conc "df " path))) (space-rx (regexp "([0-9]+)\\s+([0-9]+)%")) (freespc #f)) ;; (write df-results) (for-each (lambda (l) (let ((match (string-search space-rx l))) (if match (let ((newval (string->number (cadr match)))) (if (number? newval) (set! freespc newval)))))) (car df-results)) freespc)) ;; given path get free space, allows override in [setup] ;; with free-space-script /path/to/some/script.sh ;; (define (get-df path) (if (configf:lookup *configdat* "setup" "free-space-script") (with-input-from-pipe (conc (configf:lookup *configdat* "setup" "free-space-script") " " path) (lambda () (let ((res (read-line))) (if (string? res) (string->number res))))) (get-unix-df path))) (define (std-exit-procedure) (on-exit (lambda () 0)) ;;(debug:print-info 13 *default-log-port* "std-exit-procedure called; *time-to-exit*="*time-to-exit*) (let ((no-hurry (if *time-to-exit* ;; hurry up #f (begin (set! *time-to-exit* #t) #t)))) (debug:print-info 4 *default-log-port* "starting exit process, finalizing databases.") (if (and no-hurry (debug:debug-mode 18)) (rmt:print-db-stats)) (let ((th1 (make-thread (lambda () ;; thread for cleaning up, give it five seconds (if *dbstruct-db* (db:close-all *dbstruct-db*)) ;; one second allocated (if *task-db* (let ((db (cdr *task-db*))) (if (sqlite3:database? db) (begin (sqlite3:interrupt! db) (sqlite3:finalize! db #t) ;; (vector-set! *task-db* 0 #f) (set! *task-db* #f))))) (http-client#close-all-connections!) ;; (if (and *runremote* ;; (remote-conndat *runremote*)) ;; (begin ;; (http-client#close-all-connections!))) ;; for http-client (if (not (eq? *default-log-port* (current-error-port))) (close-output-port *default-log-port*)) (set! *default-log-port* (current-error-port))) "Cleanup db exit thread")) (th2 (make-thread (lambda () (debug:print 4 *default-log-port* "Attempting clean exit. Please be patient and wait a few seconds...") (if no-hurry (begin (thread-sleep! 5)) ;; give the clean up few seconds to do it's stuff (begin (thread-sleep! 2))) (debug:print 4 *default-log-port* " ... done") ) "clean exit"))) (thread-start! th1) (thread-start! th2) (thread-join! th1) ) ) 0) ;; from metadat lookup MEGATEST_VERSION ;; (define (common:get-last-run-version) ;; RADT => How does this work in send-receive function??; assume it is the value saved in some DB (rmt:get-var "MEGATEST_VERSION")) (define (common:set-last-run-version) (rmt:set-var "MEGATEST_VERSION" (common:version-signature))) ;;====================================================================== ;; D I S K S P A C E ;;====================================================================== (define (common:get-disk-space-used fpath) (with-input-from-pipe (conc "/usr/bin/du -s " fpath) read)) (define (common:check-space-in-dir dirpath required) (let* ((dbspace (if (directory? dirpath) (get-df dirpath) 0))) (list (> dbspace required) dbspace required dirpath))) ;; check space in dbdir and in megatest dir ;; returns: ok/not dbspace required-space ;; (define (common:check-db-dir-space) (let* ((required (string->number (or (configf:lookup *configdat* "setup" "dbdir-space-required") "100000"))) (dbdir (common:get-db-tmp-area)) ;; (db:get-dbdir)) (tdbspace (common:check-space-in-dir dbdir required)) (mdbspace (common:check-space-in-dir *toppath* required))) (sort (list tdbspace mdbspace) (lambda (a b) (< (cadr a)(cadr b)))))) ;; check available space in dbdir, exit if insufficient ;; (define (common:check-db-dir-and-exit-if-insufficient) (let* ((spacedat (car (common:check-db-dir-space))) ;; look only at worst for now (is-ok (car spacedat)) (dbspace (cadr spacedat)) (required (caddr spacedat)) (dbdir (cadddr spacedat))) (if (not is-ok) (begin (debug:print-error 0 *default-log-port* "Insufficient space in " dbdir ", require " required ", have " dbspace ", exiting now.") (exit 1))))) ;; paths is list of lists ((name path) ... ) ;; (define (common:get-disk-with-most-free-space disks minsize) (let ((best #f) (bestsize 0)) (for-each (lambda (disk-num) (let* ((dirpath (cadr (assoc disk-num disks))) (freespc (cond ((not (directory? dirpath)) (if (common:low-noise-print 300 "disks not a dir " disk-num) (debug:print 0 *default-log-port* "WARNING: disk " disk-num " at path \"" dirpath "\" is not a directory - ignoring it.")) -1) ((not (file-write-access? dirpath)) (if (common:low-noise-print 300 "disks not writeable " disk-num) (debug:print 0 *default-log-port* "WARNING: disk " disk-num " at path \"" dirpath "\" is not writeable - ignoring it.")) -1) ((not (eq? (string-ref dirpath 0) #\/)) (if (common:low-noise-print 300 "disks not a proper path " disk-num) (debug:print 0 *default-log-port* "WARNING: disk " disk-num " at path \"" dirpath "\" is not a fully qualified path - ignoring it.")) -1) (else (get-df dirpath))))) (if (> freespc bestsize) (begin (set! best (cons disk-num dirpath)) (set! bestsize freespc))))) (map car disks)) (if (and best (> bestsize minsize)) best #f))) ;; #f means no disk candidate found ;; see defstruct host at top of file. ;; host: reachable last-update last-used last-cpuload ;; (define (common:update-host-loads-table hosts-raw) (let* ((hosts (filter (lambda (x) (string-match (regexp "^\\S+$") x)) hosts-raw))) (for-each (lambda (hostname) (let* ((rec (let ((h (hash-table-ref/default *host-loads* hostname #f))) (if h h (let ((h (make-host))) (hash-table-set! *host-loads* hostname h) h)))) (host-info (common:get-host-info hostname)) (is-reachable (car host-info)) (last-reached-time (cadr host-info)) (load (caddr host-info))) (host-reachable-set! rec is-reachable) (host-last-update-set! rec last-reached-time) (host-last-cpuload-set! rec load))) hosts))) ;; go through the hosts from least recently used to most recently used, pick the first that meets the load criteral from the ;; [host-rules] section. ;; (define (common:get-least-loaded-host hosts-raw host-type configdat) (let* ((rdat (configf:lookup configdat "host-rules" host-type)) (rules (common:val->alist (or rdat "") convert: #t)) ;; maxnload, maxnjobs, maxjobrate (maxnload (common:alist-ref/default 'maxnload rules 1.5)) ;; max normalized load (maxnjobs (common:alist-ref/default 'maxnjobs rules 1.5)) ;; max normalized number of jobs (maxjobrate (common:alist-ref/default 'maxjobrate rules (/ 1 6))) ;; max rate of submitting jobs to a given host in jobs/second (hosts (filter (lambda (x) (string-match (regexp "^\\S+$") x)) hosts-raw)) ;; (best-host #f) (get-rec (lambda (hostname) ;; (print "get-rec hostname=" hostname) (let ((h (hash-table-ref/default *host-loads* hostname #f))) (if h h (let ((h (make-host))) (hash-table-set! *host-loads* hostname h) h))))) (best-load 99999) (curr-time (current-seconds)) (get-hosts-sorted (lambda (hosts) (sort hosts (lambda (a b) (let ((a-rec (get-rec a)) (b-rec (get-rec b))) ;; (print "a=" a " a-rec=" a-rec " host-last-used=" (host-last-used a-rec)) ;; (print "b=" b " b-rec=" b-rec " host-last-used=" (host-last-used b-rec)) (< (host-last-used a-rec) (host-last-used b-rec)))))))) (debug:print 0 *default-log-port* "INFO: hosts-sorted=" (get-hosts-sorted hosts)) (if (null? hosts) #f ;; no hosts to select from. All done and giving up now. (let ((hosts-sorted (get-hosts-sorted hosts))) (common:update-host-loads-table hosts) (let loop ((hostname (car hosts-sorted)) (tal (cdr hosts-sorted)) (best-host #f)) (let* ((rec (get-rec hostname)) (reachable (host-reachable rec)) (load (host-last-cpuload rec)) (last-used (host-last-used rec)) (delta (- curr-time last-used)) (job-rate (if (> delta 0) (/ 1 delta) 999)) ;; jobs per second (new-best (cond ((not reachable) (debug:print 0 *default-log-port* "Skipping host " hostname " as it cannot be reached.") best-host) ((and (< load maxnload) ;; load is acceptable (< job-rate maxjobrate)) ;; job rate is acceptable (set! best-load load) hostname) (else best-host)))) (debug:print 0 *default-log-port* "INFO: Trying host " hostname " with load " load ", last used " delta " seconds ago, with job-rate " job-rate " for running a test." ) (if new-best (begin ;; found a host, return it (debug:print 0 *default-log-port* "INFO: Found host: " new-best " load: " load " last-used: " delta " seconds ago, with job-rate: " job-rate) (host-last-used-set! rec curr-time) new-best) (if (null? tal) #f (loop (car tal)(cdr tal) best-host))))))))) (define (common:wait-for-cpuload maxload-in numcpus-in waitdelay #!key (count 1000) (msg #f)(remote-host #f)) (let* ((loadavg (common:get-cpu-load remote-host)) (numcpus (if (< 1 numcpus-in) ;; not possible (common:get-num-cpus remote-host) numcpus-in)) (maxload (max maxload-in 0.5)) ;; so maxload must be greater than 0.5 for now BUG - FIXME? (first (car loadavg)) (next (cadr loadavg)) (adjload (* maxload (max 1 numcpus))) ;; possible bug where numcpus (or could be maxload) is zero, crude fallback is to at least use 1 (loadjmp (- first next)) (adjwait (+ (random 10)(/ (- 1000 count) 10) waitdelay))) ;; add some randomness to the time to break any alignment where netbatch dumps many jobs to machines simultaneously (cond ((and (> first adjload) (> count 0)) (debug:print-info 0 *default-log-port* "server start delayed " adjwait " seconds due to load " first " exceeding max of " adjload " on server " (or remote-host (get-host-name)) " (normalized load-limit: " maxload ") " (if msg msg "")) (thread-sleep! adjwait) (common:wait-for-cpuload maxload numcpus waitdelay count: (- count 1) msg: msg remote-host: remote-host)) ((and (> loadjmp numcpus) (> count 0)) (debug:print-info 0 *default-log-port* "waiting " adjwait " seconds due to load jump " loadjmp " > numcpus " numcpus (if msg msg "")) (thread-sleep! adjwait) (common:wait-for-cpuload maxload numcpus waitdelay count: (- count 1) msg: msg remote-host: remote-host))))) (define (common:wait-for-homehost-load maxload msg) (let* ((hh-dat (if (common:on-homehost?) ;; if we are on the homehost then pass in #f so the calls are local. #f (common:get-homehost))) (hh (if hh-dat (car hh-dat) #f)) (numcpus (common:get-num-cpus hh))) (common:wait-for-normalized-load maxload msg hh))) (define (common:get-num-cpus remote-host) (let* ((actual-host (or remote-host (get-host-name)))) (or (common:get-cached-info actual-host "num-cpus" age: 86400) ;; hosts had better not be changing the number of cpus too often! (let* ((proc (lambda () (let loop ((numcpu 0) (inl (read-line))) (if (eof-object? inl) (begin (common:write-cached-info remote-host "num-cpus" numcpu) numcpu) (loop (if (string-match "^processor\\s+:\\s+\\d+$" inl) (+ numcpu 1) numcpu) (read-line)))))) (result (if remote-host (with-input-from-pipe (conc "ssh " remote-host " cat /proc/cpuinfo") proc) (with-input-from-file "/proc/cpuinfo" proc)))) (common:write-cached-info actual-host "num-cpus" result) result)))) ;; wait for normalized cpu load to drop below maxload ;; (define (common:wait-for-normalized-load maxload msg remote-host) (let ((num-cpus (common:get-num-cpus remote-host))) (common:wait-for-cpuload maxload num-cpus 15 msg: msg remote-host: remote-host))) ) |
Added utils/gen-list-of-functions.sh version [a5fa0df8c9].
> > > > > > > > | 1 2 3 4 5 6 7 8 | #!/bin/bash # extract a list of functions from a .scm file INFILE=$1 grep -E '^\(define\s+\(' $INFILE|cut -f3 -d\(|tr ')' ' '|cut -f1 -d' ' |
Added utils/get-procedures.sh version [aa92973588].
> > > > > | 1 2 3 4 5 | #!/bin/bash fname=$1 grep '(define (' $fname | tr '()' ' '|awk '{print $2}' |