Overview
Comment: | Runs through test4 pretty well. No server enabled yet |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | v1.62-no-rpc |
Files: | files | file ages | folders |
SHA1: |
6444c1bdfc166bc0eef081e1803eaad7 |
User & Date: | matt on 2016-11-25 22:30:07 |
Other Links: | branch diff | manifest | tags |
Context
2016-11-26
| ||
18:16 | Cleaned up globals. Added audit script to report on globals, where defined and where used. check-in: 22df9fe278 user: matt tags: v1.62-no-rpc | |
2016-11-25
| ||
22:30 | Runs through test4 pretty well. No server enabled yet check-in: 6444c1bdfc user: matt tags: v1.62-no-rpc | |
11:50 | Consolidated to single global for dbstruct. Removed *megatest-db* Removed *inmemdb* Removed *write-frequency* Removed *client-non-blocking-mode* Consolidated db:open-local-db-handle in with db:setup Fixed calls which used db to instead use dbstruct Change repl to use db:setup for getting a db handle check-in: e335fe582a user: matt tags: v1.62-no-rpc | |
Changes
Modified client.scm from [b597605018] to [5c6ba40366].
︙ | |||
178 179 180 181 182 183 184 | 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | - + - + | ;; (car (vector-ref logininfo 1)) ;; #f))) ))) (if (and start-res ping-res) (begin |
︙ |
Modified common.scm from [d6de275ae9] to [03889704ec].
1 2 3 4 5 6 7 8 9 10 11 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | - + | ;;====================================================================== ;; Copyright 2006-2012, Matthew Welland. ;; ;; This program is made available under the GNU GPL version 2.0 or ;; greater. See the accompanying file COPYING for details. ;; ;; This program is distributed WITHOUT ANY WARRANTY; without even the ;; implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ;; PURPOSE. ;;====================================================================== |
︙ | |||
88 89 90 91 92 93 94 | 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 | + - + - + | (define *dbstruct-db* #f) ;; used when local access is triggered in rmt.scm (define *db-stats* (make-hash-table)) ;; hash of vectors < count duration-total > (define *db-stats-mutex* (make-mutex)) (define *db-sync-mutex* (make-mutex)) (define *db-multi-sync-mutex* (make-mutex)) (define *db-local-sync* (make-hash-table)) ;; used to record last touch of db (define *db-last-sync* 0) ;; last time the sync to megatest.db happened |
︙ | |||
198 199 200 201 202 203 204 205 206 207 208 209 210 211 | 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 | + + + + + + + + + + + + + + + + + + + + + + + + | 'dejunk ;; 'adj-testids ;; 'old2new 'new2old 'schema) (if (common:version-changed?) (common:set-last-run-version))) ;; Rotate logs, logic: ;; if > 500k and older than 1 week: ;; remove previous compressed log and compress this log ;; WARNING: This proc operates assuming that it is in the directory above the ;; logs directory you wish to log-rotate. ;; (define (common:rotate-logs) (if (not (directory-exists? "logs"))(create-directory "logs")) (directory-fold (lambda (file rem) (if (and (string-match "^.*.log" file) (> (file-size (conc "logs/" file)) 200000)) (let ((gzfile (conc "logs/" file ".gz"))) (if (file-exists? gzfile) (begin (debug:print-info 0 *default-log-port* "removing " gzfile) (delete-file gzfile))) (debug:print-info 0 *default-log-port* "compressing " file) (system (conc "gzip logs/" file))))) '() "logs")) ;; Force a megatest cleanup-db if version is changed and skip-version-check not specified ;; (define (common:exit-on-version-changed) (if (common:version-changed?) (let ((mtconf (conc (get-environment-variable "MT_RUN_AREA_HOME") "/megatest.config"))) (debug:print 0 *default-log-port* |
︙ | |||
480 481 482 483 484 485 486 | 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 | - - + + - + - + | ;;====================================================================== ;; E X I T H A N D L I N G ;;====================================================================== (define (common:legacy-sync-recommended) (or (and (common:get-homehost) (cdr (common:get-homehost))) |
︙ | |||
534 535 536 537 538 539 540 | 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 | - + | (last-time (current-seconds))) (if (or (common:legacy-sync-recommended) legacy-sync) (let loop () ;; sync for filesystem local db writes ;; (let ((start-time (current-seconds))) |
︙ |
Modified db.scm from [8de1aa48cd] to [05634fcfcf].
︙ | |||
194 195 196 197 198 199 200 | 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | + - + | (file-write (if file-exists (file-write-access? fname) dir-writable ))) (if file-write ;; dir-writable (let (;; (lock (obtain-dot-lock fname 1 5 10)) (db (sqlite3:open-database fname))) (sqlite3:set-busy-handler! db (make-busy-timeout 136000)) ;; (db:set-sync db) |
︙ | |||
308 309 310 311 312 313 314 315 316 317 | 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 | + - - + + + + | ;; (rundb (dbr:dbstruct-rundb dbstruct)) ;; (inmem (dbr:dbstruct-inmem dbstruct)) ;; (maindb (dbr:dbstruct-main dbstruct)) ;; (refdb (dbr:dbstruct-refdb dbstruct)) (tmpdb (dbr:dbstruct-tmpdb dbstruct)) (mtdb (dbr:dbstruct-mtdb dbstruct)) (refndb (dbr:dbstruct-refndb dbstruct)) (start-t (current-seconds)) ;; (runid (dbr:dbstruct-run-id dbstruct)) ) (debug:print-info 4 *default-log-port* "Syncing for run-id: " run-id) |
︙ | |||
369 370 371 372 373 374 375 | 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 | - + | ;; (dbr:dbstruct-localdb-set! dbstruct run-id #f) ;; (dbr:dbstruct-inmem-set! dbstruct #f))))) ;; close all opened run-id dbs (define (db:close-all dbstruct) (if (dbr:dbstruct? dbstruct) (begin |
︙ | |||
3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 | 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 | + + - - - - + + + + + + + + - + | (regexp "_") "=" msg #t))) (lambda ()(deserialize))) (begin (debug:print-error 0 *default-log-port* "reception failed. Received " msg " but cannot translate it.") msg))) ;; crude reply for when things go awry ((zmq nmsg)(with-input-from-string msg (lambda ()(deserialize)))) (else msg))) ;; rpc ;; This is to be the big daddy call (define (db:test-set-status-state dbstruct run-id test-id status state msg) (let ((dbdat (db:get-db dbstruct run-id))) (if (member state '("LAUNCHED" "REMOTEHOSTSTART")) (db:general-call dbdat 'set-test-start-time (list test-id))) |
︙ | |||
3205 3206 3207 3208 3209 3210 3211 | 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 | - + | statuses) statuses))) *common:std-statuses* >)) (newstate (if (null? all-curr-states) "NOT_STARTED" (car all-curr-states))) (newstatus (if (null? all-curr-statuses) "n/a" (car all-curr-statuses)))) ;; (print "Setting toplevel to: " newstate "/" newstatus) (db:test-set-state-status-by-id dbstruct run-id tl-test-id newstate newstatus #f))))))) |
︙ | |||
3313 3314 3315 3316 3317 3318 3319 | 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 | - + - - + | (SELECT status FROM tests WHERE id=?) NOT IN ('WARN','FAIL') THEN 'PASS' ELSE status END WHERE id=?;") ;; DONE '(test-set-log "UPDATE tests SET final_logf=? WHERE id=?;") ;; DONE ;; '(test-set-rundir-by-test-id "UPDATE tests SET rundir=? WHERE id=?") ;; DONE ;; '(test-set-rundir "UPDATE tests SET rundir=? AND testname=? AND item_path=?;") ;; DONE |
︙ | |||
3439 3440 3441 3442 3443 3444 3445 | 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 | - + - - + + | immediate flush sync set-verbosity killserver )) |
︙ |
Modified http-transport.scm from [d70882fd0b] to [9e8b14e328].
︙ | |||
109 110 111 112 113 114 115 | 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | - + | (http-transport:try-start-server run-id ipaddrstr start-port server-id))) ;; This is recursively run by http-transport:run until sucessful ;; (define (http-transport:try-start-server run-id ipaddrstr portnum server-id) (let ((config-hostname (configf:lookup *configdat* "server" "hostname")) (tdbdat (tasks:open-db))) |
︙ | |||
258 259 260 261 262 263 264 | 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | - + | (db:string->obj (handle-exceptions exn (begin (set! success #f) (debug:print 0 *default-log-port* "WARNING: failure in with-input-from-request to " fullurl ".") (debug:print 0 *default-log-port* " message: " ((condition-property-accessor 'exn 'message) exn)) |
︙ | |||
305 306 307 308 309 310 311 | 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | - + | (make-property-condition 'timeout 'message "nmsg-transport:client-api-send-receive-raw timed out talking to server"))))))) ;; careful closing of connections stored in *runremote* ;; (define (http-transport:close-connections run-id) |
︙ | |||
396 397 398 399 400 401 402 | 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 | + + - + | ;; Use this opportunity to sync the tmp db to megatest.db (if *dbstruct-db* (let ((start-time (current-milliseconds)) (sync-time #f) (rem-time #f)) (condition-case ;; (if (and (member (mutex-state *db-sync-mutex*) '(abandoned not-abandoned)) ;; (> (- (current-seconds) *db-last-sync*) 5)) ;; if not currently being synced nor recently synced |
︙ | |||
426 427 428 429 430 431 432 | 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 | - + + | (if (eq? server-state 'available) (let ((new-server-id (tasks:server-am-i-the-server? (db:delay-if-busy tdbdat) run-id))) ;; try to ensure no double registering of servers (if (equal? new-server-id server-id) (begin (tasks:server-set-state! (db:delay-if-busy tdbdat) server-id "dbprep") (thread-sleep! 0.5) ;; give some margin for queries to complete before switching from file based access to server based access (set! *dbstruct-db* (db:setup)) ;; run-id)) |
︙ | |||
483 484 485 486 487 488 489 | 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 | - + | (loop 0 server-state bad-sync-count)) (http-transport:server-shutdown server-id port)))))) (define (http-transport:server-shutdown server-id port) (let ((tdbdat (tasks:open-db))) (debug:print-info 0 *default-log-port* "Starting to shutdown the server.") ;; need to delete only *my* server entry (future use) |
︙ | |||
508 509 510 511 512 513 514 515 516 517 518 519 520 521 | 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 | + + | (if (eq? *number-non-write-queries* 0) "n/a (no queries)" (/ *total-non-write-delay* *number-non-write-queries*)) " ms") (debug:print-info 0 *default-log-port* "Server shutdown complete. Exiting") (tasks:server-delete-record (db:delay-if-busy tdbdat) server-id " http-transport:keep-running complete") ;; if the .server file contained :myport then we can remove it (server:remove-dotserver-file *toppath* port) (exit))) ;; all routes though here end in exit ... ;; ;; start_server? ;; (define (http-transport:launch run-id) |
︙ |
Modified launch.scm from [2ea5c9f7cf] to [8b28cbf454].
︙ | |||
894 895 896 897 898 899 900 | 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 | - + | (lnkbase (conc linktree "/" target "/" runname)) (lnkpath (conc lnkbase "/" testname)) (lnkpathf (conc lnkpath (if not-iterated "" "/") item-path)) (lnktarget (conc lnkpath "/" item-path))) ;; Update the rundir path in the test record for all, rundir=physical, shortdir=logical ;; rundir shortdir |
︙ | |||
967 968 969 970 971 972 973 | 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 | - + | (hash-table-set! *toptest-paths* testname curr-test-path) ;; NB// Was this for the test or for the parent in an iterated test? (rmt:general-call 'test-set-rundir-shortdir run-id lnkpath (if (file-exists? lnkpath) ;; (resolve-pathname lnkpath) (common:nice-path lnkpath) lnkpath) |
︙ |
Modified megatest.scm from [bb00f9be7d] to [db7e42e4e9].
︙ | |||
341 342 343 344 345 346 347 | 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 | - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ;; immediately set MT_TARGET if -reqtarg or -target are available ;; (let ((targ (or (args:get-arg "-reqtarg")(args:get-arg "-target")))) (if targ (setenv "MT_TARGET" targ))) ;; The watchdog is to keep an eye on things like db sync etc. ;; |
︙ | |||
671 672 673 674 675 676 677 | 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 | - + - + | (else (pp data)))))) (if out-file (close-output-port out-port)) (exit) ;; yes, bending the rules here - need to exit since this is a utility )) (if (args:get-arg "-ping") |
︙ | |||
2008 2009 2010 2011 2012 2013 2014 | 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 | - + | (debug:print 0 *default-log-port* "Failed to create HTML output in " toppath "/lt/runs-index.html")) (set! *didsomething* #t))) ;;====================================================================== ;; Exit and clean up ;;====================================================================== |
︙ |
Modified rmt.scm from [ea574182b1] to [2858b3ea4e].
︙ | |||
38 39 40 41 42 43 44 | 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 | - + + + + + + + + + + + + + + | ;; S U P P O R T F U N C T I O N S ;;====================================================================== ;; if a server is either running or in the process of starting call client:setup ;; else return #f to let the calling proc know that there is no server available ;; (define (rmt:get-connection-info run-id) |
︙ | |||
215 216 217 218 219 220 221 | 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | - - - + - - | (loop (car tal)(cdr tal) newmax-cmd currmax))))))) (mutex-unlock! *db-stats-mutex*) res)) (define (rmt:open-qry-close-locally cmd run-id params #!key (remretries 5)) (let* ((qry-is-write (not (member cmd api:read-only-queries))) (db-file-path (db:dbfile-path)) ;; 0)) |
︙ | |||
241 242 243 244 245 246 247 | 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | - + | (thread-sleep! (/ (random 5000) 1000)) ;; some random delay (rmt:open-qry-close-locally cmd run-id params remretries: (- remretries 1))) (begin (debug:print-error 0 *default-log-port* "too many retries in rmt:open-qry-close-locally, giving up") #f)) (begin ;; (rmt:update-db-stats run-id cmd params duration) |
︙ | |||
302 303 304 305 306 307 308 | 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | - - - + + + | (define (rmt:login run-id) (rmt:send-receive 'login run-id (list *toppath* megatest-version run-id *my-client-signature*))) ;; This login does no retries under the hood - it acts a bit like a ping. ;; Deprecated for nmsg-transport. ;; |
︙ |
Modified server.scm from [19061b35b0] to [7b40e2c3b9].
︙ | |||
102 103 104 105 106 107 108 | 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 | - + + - + - + - + - + + - - - + + - - - - - - - - - - - - - - - - - + - + - - + + - - + + - - - - - - + + + + + + + + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + - - - + - - - - - - - - + + + + + + - + - + - - + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + - + - - - + - - - + | result))) ;; Given a run id start a server process ### NOTE ### > file 2>&1 ;; if the run-id is zero and the target-host is set ;; try running on that host ;; incidental: rotate logs in logs/ dir. ;; |
Modified tests.scm from [84fbf4d5d8] to [8ec0971889].
︙ | |||
395 396 397 398 399 400 401 | 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 | - + - - + + | (debug:print 4 *default-log-port* "real-status " real-status ", waived " waived ", status " status) ;; update the primary record IF state AND status are defined (if (and state status) (begin (rmt:test-set-status-state run-id test-id real-status state (if waived waived comment)) |
︙ | |||
479 480 481 482 483 484 485 | 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 | - - + | force) (let ((my-start-time (current-seconds)) (lockf (conc outputfilename ".lock"))) (let loop ((have-lock (common:simple-file-lock lockf))) (if have-lock (let ((script (configf:lookup *configdat* "testrollup" test-name))) (print "Obtained lock for " outputfilename) |
︙ |