Overview
Comment: | partial recovery of rpc mechanism |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | test-specific-db |
Files: | files | file ages | folders |
SHA1: |
541cc327b6d978624cf42d2258665f85 |
User & Date: | mrwellan on 2012-10-01 17:32:30 |
Other Links: | branch diff | manifest | tags |
Context
2012-10-01
| ||
21:48 | Added correct exit back for non-server mode check-in: 4111a3bf40 user: matt tags: test-specific-db | |
17:32 | partial recovery of rpc mechanism check-in: 541cc327b6 user: mrwellan tags: test-specific-db | |
2012-09-30
| ||
23:28 | bumped version check-in: 9d1014508a user: fdk71adm tags: test-specific-db | |
Changes
Modified db.scm from [b3c7d02de9] to [50c1ee9122].
︙ | ︙ | |||
83 84 85 86 87 88 89 | (set! res (apply proc db params)) (if (not idb)(sqlite3:finalize! db)) res)))) (handle-exceptions exn (begin (debug:print 0 "EXCEPTION: database probably overloaded?") | | | 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | (set! res (apply proc db params)) (if (not idb)(sqlite3:finalize! db)) res)))) (handle-exceptions exn (begin (debug:print 0 "EXCEPTION: database probably overloaded?") (debug:print 0 " " ((condition-property-accessor 'exn 'message) exn)) (print-call-chain) (thread-sleep! (random 120)) (debug:print 0 "trying db call one more time....") (runner)) (runner)))) (define open-run-close open-run-close-exception-handling) |
︙ | ︙ | |||
590 591 592 593 594 595 596 | final-res))))) ;; The target is keyval1/keyval2..., cached in *target* as it is used often (define (db:get-target db run-id) (let ((mytarg (hash-table-ref/default *target* run-id #f))) (if mytarg mytarg | | | 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 | final-res))))) ;; The target is keyval1/keyval2..., cached in *target* as it is used often (define (db:get-target db run-id) (let ((mytarg (hash-table-ref/default *target* run-id #f))) (if mytarg mytarg (let* ((keyvals (db:get-key-vals db run-id)) (thekey (string-intersperse (map (lambda (x)(if x x "-na-")) keyvals) "/"))) (hash-table-set! *target* run-id thekey) thekey)))) ;;====================================================================== ;; T E S T S ;;====================================================================== |
︙ | ︙ | |||
1009 1010 1011 1012 1013 1014 1015 | qrystr) res)) ;;====================================================================== ;; QUEUE UP META, TEST STATUS AND STEPS ;;====================================================================== | | | | > | | < | | | > > > > > > > > > > > > > > > > > > | > > | > | > > | > > | | < | | | | > | | | | | > > | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > | | | 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 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 | qrystr) res)) ;;====================================================================== ;; QUEUE UP META, TEST STATUS AND STEPS ;;====================================================================== (define (db:updater) (let loop ((start-time (current-time))) (thread-sleep! 0.5) ;; move save time around to minimize regular collisions? (db:write-cached-data) (loop start-time))) (define (cdb:test-set-state-status test-id status state) (debug:print 4 "INFO: Adding status/state to queue: " status "/" state) (mutex-lock! *incoming-mutex*) (set! *incoming-data* (cons (vector 'state-status (current-seconds) (list state status test-id)) ;; run-id test-name item-path minutes cpuload diskfree tmpfree) *incoming-data*)) (mutex-unlock! *incoming-mutex*) (if *cache-on* (debug:print 6 "INFO: *cache-on* is " *cache-on* ", skipping cache write") (db:write-cached-data))) ;; (define (remote:test-update-meta-info db test-id minutes cpuload diskfree tmpfree) ;; (mutex-lock! *incoming-mutex*) ;; (set! *incoming-data* (cons (vector 'meta-info ;; (current-seconds) ;; (list cpuload ;; diskfree ;; minutes ;; test-id)) ;; run-id test-name item-path minutes cpuload diskfree tmpfree) ;; *incoming-data*)) ;; (mutex-unlock! *incoming-mutex*) ;; (if *cache-on* ;; (debug:print 6 "INFO: *cache-on* is " *cache-on* ", skipping cache write as part of test-update-meta-info") ;; (db:write-cached-data db))) ;; The queue is a list of vectors where the zeroth slot indicates the type of query to ;; apply and the second slot is the time of the query and the third entry is a list of ;; values to be applied ;; (define (db:write-cached-data) (open-run-close (lambda (db . params) (let ((meta-stmt (sqlite3:prepare db "UPDATE tests SET cpuload=?,diskfree=?,run_duration=?,state='RUNNING' WHERE id=? AND state NOT IN ('COMPLETED','KILLREQ','KILLED');")) (state-status-stmt (sqlite3:prepare db "UPDATE tests SET state=?,status=? WHERE id=?;")) (step-stmt (sqlite3:prepare db "INSERT OR REPLACE into test_steps (test_id,stepname,state,status,event_time,comment,logfile) VALUES(?,?,?,?,?,?,?);")) ;; strftime('%s','now')#f) (data #f)) (mutex-lock! *incoming-mutex*) (set! data (sort *incoming-data* (lambda (a b)(< (vector-ref a 1)(vector-ref b 1))))) (set! *incoming-data* '()) (mutex-unlock! *incoming-mutex*) (if (> (length data) 0) (debug:print 4 "INFO: Writing cached data " data)) (sqlite3:with-transaction db (lambda () (for-each (lambda (entry) (debug:print 4 "INFO: flushing " entry " to db") (case (vector-ref entry 0) ((meta-info) (apply sqlite3:execute meta-stmt (vector-ref entry 2))) ((step-status) (apply sqlite3:execute step-stmt (vector-ref entry 2))) ((state-status) (apply sqlite3:execute state-status-stmt (vector-ref entry 2))) (else (debug:print 0 "ERROR: Queued entry not recognised " entry)))) data))) (sqlite3:finalize! meta-stmt) ;; sqlite is the bottleneck, clear the statements asap? (sqlite3:finalize! step-stmt) (sqlite3:finalize! state-status-stmt) )) #f)) ;; (define (db:write-cached-data db) ;; (let ((meta-stmt (sqlite3:prepare db "UPDATE tests SET cpuload=?,diskfree=?,run_duration=?,state='RUNNING' WHERE id=? AND state NOT IN ('COMPLETED','KILLREQ','KILLED');")) ;; (step-stmt (sqlite3:prepare db "INSERT OR REPLACE into test_steps (test_id,stepname,state,status,event_time,comment,logfile) VALUES(?,?,?,?,?,?,?);")) ;; strftime('%s','now')#f) ;; (data (sort *incoming-data* (lambda (a b)(< (vector-ref a 1)(vector-ref b 1)))))) ;; (if (> (length data) 0) ;; (debug:print 4 "Writing cached data " data)) ;; (mutex-lock! *incoming-mutex*) ;; (sqlite3:with-transaction ;; db ;; (lambda () ;; (for-each (lambda (entry) ;; (case (vector-ref entry 0) ;; ((meta-info) ;; (apply sqlite3:execute meta-stmt (vector-ref entry 2))) ;; ((step-status) ;; (apply sqlite3:execute step-stmt (vector-ref entry 2))) ;; (else ;; (debug:print 0 "ERROR: Queued entry not recognised " entry)))) ;; data))) ;; (sqlite3:finalize! meta-stmt) ;; sqlite is the bottleneck, clear the statements asap? ;; (sqlite3:finalize! step-stmt) ;; (set! *incoming-data* '()) ;; (mutex-unlock! *incoming-mutex*))) (define (db:roll-up-pass-fail-counts db run-id test-name item-path status) (if (and (not (equal? item-path "")) (or (equal? status "PASS") (equal? status "WARN") (equal? status "FAIL") (equal? status "WAIVED") |
︙ | ︙ | |||
1188 1189 1190 1191 1192 1193 1194 | '()))) (define (db:load-test-data db test-id) (let loop ((lin (read-line))) (if (not (eof-object? lin)) (begin (debug:print 4 lin) | | | | 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 | '()))) (define (db:load-test-data db test-id) (let loop ((lin (read-line))) (if (not (eof-object? lin)) (begin (debug:print 4 lin) (db:csv->test-data db test-id lin) (loop (read-line))))) ;; roll up the current results. ;; FIXME: Add the status to (db:test-data-rollup db test-id #f)) ;; WARNING: Do NOT call this for the parent test on an iterated test ;; Roll up test_data pass/fail results ;; look at the test_data status field, ;; if all are pass (any case) and the test status is PASS or NULL or '' then set test status to PASS. ;; if one or more are fail (any case) then set test status to PASS, non "pass" or "fail" are ignored (define (db:test-data-rollup db test-id status) |
︙ | ︙ | |||
1521 1522 1523 1524 1525 1526 1527 | ;; (db:extract-ods-file db "outputfile.ods" '(("sysname" "%")("fsname" "%")("datapath" "%")) "%") ;;====================================================================== ;; REMOTE DB ACCESS VIA RPC ;;====================================================================== | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 | ;; (db:extract-ods-file db "outputfile.ods" '(("sysname" "%")("fsname" "%")("datapath" "%")) "%") ;;====================================================================== ;; REMOTE DB ACCESS VIA RPC ;;====================================================================== (define (rdb:open-run-close procname . remargs) (if *runremote* (let ((host (vector-ref *runremote* 0)) (port (vector-ref *runremote* 1))) (apply (rpc:procedure 'rdb:open-run-close host port) procname remargs)) (apply open-run-close (eval procname) remargs))) |
Modified launch.scm from [203b993021] to [372d06f4be].
︙ | ︙ | |||
91 92 93 94 95 96 97 98 99 100 101 102 103 104 | (change-directory top-path) (if (not (setup-for-run)) (begin (debug:print 0 "Failed to setup, exiting") ;; (sqlite3:finalize! db) ;; (sqlite3:finalize! tdb) (exit 1))) (change-directory *toppath*) (open-run-close set-megatest-env-vars #f run-id) ;; these may be needed by the launching process (change-directory work-area) (open-run-close set-run-config-vars #f run-id) ;; environment overrides are done *before* the remaining critical envars. (alist->env-vars env-ovrd) | > > > | 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | (change-directory top-path) (if (not (setup-for-run)) (begin (debug:print 0 "Failed to setup, exiting") ;; (sqlite3:finalize! db) ;; (sqlite3:finalize! tdb) (exit 1))) ;; Can setup as client for server mode now (server:client-setup) (change-directory *toppath*) (open-run-close set-megatest-env-vars #f run-id) ;; these may be needed by the launching process (change-directory work-area) (open-run-close set-run-config-vars #f run-id) ;; environment overrides are done *before* the remaining critical envars. (alist->env-vars env-ovrd) |
︙ | ︙ | |||
241 242 243 244 245 246 247 | (inexact->exact (round (- (current-seconds) start-seconds))))) (kill-tries 0)) (let loop ((minutes (calc-minutes))) | < < < < < < < < < | 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | (inexact->exact (round (- (current-seconds) start-seconds))))) (kill-tries 0)) (let loop ((minutes (calc-minutes))) (begin (set! kill-job? (open-run-close test-get-kill-request #f test-id)) ;; run-id test-name itemdat)) (open-run-close test-set-meta-info #f test-id run-id test-name itemdat minutes) (if kill-job? (begin (mutex-lock! m) (let* ((pid (vector-ref exit-info 0))) (if (number? pid) (begin (debug:print 0 "WARNING: Request received to kill job (attempt # " kill-tries ")") |
︙ | ︙ | |||
291 292 293 294 295 296 297 | (th1 (make-thread monitorjob)) (th2 (make-thread runit))) (set! job-thread th2) (thread-start! th1) (thread-start! th2) (thread-join! th2) (mutex-lock! m) | < < < < < < < < < < < | 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | (th1 (make-thread monitorjob)) (th2 (make-thread runit))) (set! job-thread th2) (thread-start! th1) (thread-start! th2) (thread-join! th2) (mutex-lock! m) (let* ((item-path (item-list->path itemdat)) (testinfo (open-run-close db:get-test-info-by-id #f test-id))) ;; )) ;; run-id test-name item-path))) (if (not (equal? (db:test-get-state testinfo) "COMPLETED")) (begin (debug:print 2 "Test NOT logged as COMPLETED, (state=" (db:test-get-state testinfo) "), updating result, rollup-status is " rollup-status) (open-run-close tests:test-set-status! #f test-id (if kill-job? "KILLED" "COMPLETED") (cond ((not (vector-ref exit-info 1)) "FAIL") ;; job failed to run ((eq? rollup-status 0) ;; if the current status is AUTO the defer to the calculated value (i.e. leave this AUTO) (if (equal? (db:test-get-status testinfo) "AUTO") "AUTO" "PASS")) ((eq? rollup-status 1) "FAIL") ((eq? rollup-status 2) |
︙ | ︙ |
Modified megatest.scm from [95fcbb68a8] to [ba111cbf36].
︙ | ︙ | |||
269 270 271 272 273 274 275 | (operate-on 'set-state-status)))) ;;====================================================================== ;; Query runs ;;====================================================================== (if (args:get-arg "-list-runs") | < | | | | | | | | | | < < < < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 | (operate-on 'set-state-status)))) ;;====================================================================== ;; Query runs ;;====================================================================== (if (args:get-arg "-list-runs") (if (setup-for-run) (let* ((db #f) (runpatt (args:get-arg "-list-runs")) (testpatt (args:get-arg "-testpatt")) (itempatt (args:get-arg "-itempatt")) (runsdat (open-run-close db:get-runs db runpatt #f #f '())) (runs (db:get-rows runsdat)) (header (db:get-header runsdat)) (keys (open-run-close db:get-keys db)) (keynames (map key:get-fieldname keys))) ;; Each run (for-each (lambda (run) (debug:print 1 "Run: " (string-intersperse (map (lambda (x) (db:get-value-by-header run header x)) keynames) "/") "/" (db:get-value-by-header run header "runname") " status: " (db:get-value-by-header run header "state")) (let ((run-id (open-run-close db:get-value-by-header run header "id"))) (let ((tests (open-run-close db:get-tests-for-run db run-id testpatt itempatt '() '()))) ;; Each test (for-each (lambda (test) (format #t " Test: ~25a State: ~15a Status: ~15a Runtime: ~5@as Time: ~22a Host: ~10a\n" (conc (db:test-get-testname test) (if (equal? (db:test-get-item-path test) "") "" (conc "(" (db:test-get-item-path test) ")"))) (db:test-get-state test) (db:test-get-status test) (db:test-get-run_duration test) (db:test-get-event_time test) (db:test-get-host test)) (if (not (or (equal? (db:test-get-status test) "PASS") (equal? (db:test-get-status test) "WARN") (equal? (db:test-get-state test) "NOT_STARTED"))) (begin (print " cpuload: " (db:test-get-cpuload test) "\n diskfree: " (db:test-get-diskfree test) "\n uname: " (db:test-get-uname test) "\n rundir: " (db:test-get-rundir test) ) ;; Each test (let ((steps (open-run-close db:get-steps-for-test db (db:test-get-id test)))) (for-each (lambda (step) (format #t " Step: ~20a State: ~10a Status: ~10a Time ~22a\n" (db:step-get-stepname step) (db:step-get-state step) (db:step-get-status step) (db:step-get-event_time step))) steps))))) tests)))) runs) (set! *didsomething* #t) ))) ;;====================================================================== ;; Start the server - can be done in conjunction with -runall or -runtests (one day...) ;;====================================================================== (if (and (args:get-arg "-server") (not (or (args:get-arg "-runall") (args:get-arg "-runtests")))) |
︙ | ︙ | |||
475 476 477 478 479 480 481 | (begin (debug:print 0 "ERROR: -target is required.") (exit 1))) (if (not (setup-for-run)) (begin (debug:print 0 "Failed to setup, giving up on -test-paths or -test-files, exiting") (exit 1))) | < < < < < < | 470 471 472 473 474 475 476 477 478 479 480 481 482 483 | (begin (debug:print 0 "ERROR: -target is required.") (exit 1))) (if (not (setup-for-run)) (begin (debug:print 0 "Failed to setup, giving up on -test-paths or -test-files, exiting") (exit 1))) (let* ((itempatt (args:get-arg "-itempatt")) (keys (open-run-close db:get-keys db)) (keynames (map key:get-fieldname keys)) (paths (open-run-close db:test-get-paths-matching db keynames target (args:get-arg "-test-files")))) (set! *didsomething* #t) (for-each (lambda (path) (print path)) |
︙ | ︙ | |||
606 607 608 609 610 611 612 | (status (args:get-arg ":status")) (logfile (args:get-arg "-setlog"))) (change-directory testpath) (if (not (setup-for-run)) (begin (debug:print 0 "Failed to setup, exiting") (exit 1))) | < < < < < < | 595 596 597 598 599 600 601 602 603 604 605 606 607 608 | (status (args:get-arg ":status")) (logfile (args:get-arg "-setlog"))) (change-directory testpath) (if (not (setup-for-run)) (begin (debug:print 0 "Failed to setup, exiting") (exit 1))) (if (and state status) (open-run-close db:teststep-set-status! db test-id step state status itemdat (args:get-arg "-m") logfile) (begin (debug:print 0 "ERROR: You must specify :state and :status with every call to -step") (exit 6))) (if db (sqlite3:finalize! db)) (set! *didsomething* #t)))) |
︙ | ︙ | |||
648 649 650 651 652 653 654 | (state (args:get-arg ":state")) (status (args:get-arg ":status"))) (change-directory testpath) (if (not (setup-for-run)) (begin (debug:print 0 "Failed to setup, exiting") (exit 1))) | | | | | < < | 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 | (state (args:get-arg ":state")) (status (args:get-arg ":status"))) (change-directory testpath) (if (not (setup-for-run)) (begin (debug:print 0 "Failed to setup, exiting") (exit 1))) ;; can setup as client for server mode now (server:client-setup) (if (args:get-arg "-load-test-data") ;; has sub commands that are rdb: (open-run-close db:load-test-data db test-id)) (if (args:get-arg "-setlog") (let ((logfname (args:get-arg "-setlog"))) (open-run-close db:test-set-log! db test-id logfname))) (if (args:get-arg "-set-toplog") |
︙ | ︙ | |||
730 731 732 733 734 735 736 | (not status))) (begin (debug:print 0 "ERROR: You must specify :state and :status with every call to -test-status\n" help) ;; (sqlite3:finalize! db) (exit 6))) (let ((msg (args:get-arg "-m"))) ;; Convert to rpc | | > < < < < < < | 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 | (not status))) (begin (debug:print 0 "ERROR: You must specify :state and :status with every call to -test-status\n" help) ;; (sqlite3:finalize! db) (exit 6))) (let ((msg (args:get-arg "-m"))) ;; Convert to rpc ;; (rdb:open-run-close 'tests:test-set-status! #f test-id state newstatus msg otherdata)))) (tests:test-set-status! db test-id state newstatus msg otherdata)))) (if db (sqlite3:finalize! db)) (set! *didsomething* #t)))) ;;====================================================================== ;; Various helper commands can go below here ;;====================================================================== (if (args:get-arg "-showkeys") (let ((db #f) (keys #f)) (if (not (setup-for-run)) (begin (debug:print 0 "Failed to setup, exiting") (exit 1))) (set! keys (open-run-close db:get-keys db)) (debug:print 1 "Keys: " (string-intersperse (map key:get-fieldname keys) ", ")) (if db (sqlite3:finalize! db)) (set! *didsomething* #t))) (if (args:get-arg "-gui") (begin |
︙ | ︙ | |||
796 797 798 799 800 801 802 | (if (args:get-arg "-update-meta") (begin (if (not (setup-for-run)) (begin (debug:print 0 "Failed to setup, exiting") (exit 1))) ;; now can find our db | < < < < < < < | 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 | (if (args:get-arg "-update-meta") (begin (if (not (setup-for-run)) (begin (debug:print 0 "Failed to setup, exiting") (exit 1))) ;; now can find our db (open-run-close runs:update-all-test_meta db) (set! *didsomething* #t))) ;;====================================================================== ;; Start a repl ;;====================================================================== (if (args:get-arg "-repl") |
︙ | ︙ |
Modified runs.scm from [e8b32cf957] to [985ca1292d].
︙ | ︙ | |||
521 522 523 524 525 526 527 | ;; we get here on "drop through" - loop for next test in queue (if (null? tal) (begin ;; FIXME!!!! THIS SHOULD NOT REQUIRE AN EXIT!!!!!!! (debug:print 1 "INFO: All tests launched") (thread-sleep! 0.5) ;; FIXME! This harsh exit should not be necessary.... | | | 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 | ;; we get here on "drop through" - loop for next test in queue (if (null? tal) (begin ;; FIXME!!!! THIS SHOULD NOT REQUIRE AN EXIT!!!!!!! (debug:print 1 "INFO: All tests launched") (thread-sleep! 0.5) ;; FIXME! This harsh exit should not be necessary.... ;; (if (not *runremote*)(exit)) ;; #f) ;; return a #f as a hint that we are done ;; Here we need to check that all the tests remaining to be run are eligible to run ;; and are not blocked by failed (let* ((newlst (open-run-close tests:filter-non-runnable #f run-id tal test-records)) ;; i.e. not FAIL, WAIVED, INCOMPLETE, PASS, KILLED, (junked (lset-difference equal? tal newlst))) (debug:print 4 "INFO: full drop through, if reruns is less than 100 we will force retry them: " reruns) (if (< num-retries max-retries) |
︙ | ︙ | |||
795 796 797 798 799 800 801 | (else (let ((db #f) (keys #f)) (if (not (setup-for-run)) (begin (debug:print 0 "Failed to setup, exiting") (exit 1))) | < | | < < < | 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 | (else (let ((db #f) (keys #f)) (if (not (setup-for-run)) (begin (debug:print 0 "Failed to setup, exiting") (exit 1))) (if (args:get-arg "-server") (open-run-close server:start db (args:get-arg "-server")) (if (not (or (args:get-arg "-runall") ;; runall and runtests are allowed to be servers (args:get-arg "-runtests"))) (server:client-setup))) (set! keys (open-run-close db:get-keys db)) ;; have enough to process -target or -reqtarg here (if (args:get-arg "-reqtarg") (let* ((runconfigf (conc *toppath* "/runconfigs.config")) ;; DO NOT EVALUATE ALL (runconfig (read-config runconfigf #f #f environ-patt: #f))) (if (hash-table-ref/default runconfig (args:get-arg "-reqtarg") #f) (keys:target-set-args keys (args:get-arg "-reqtarg") args:arg-hash) |
︙ | ︙ |
Modified server.scm from [3dd064bd19] to [57e8a67dda].
︙ | ︙ | |||
32 33 34 35 36 37 38 | (apply (eval (string->symbol procstr)) params)) ;; (if *runremote* ;; (apply (eval (string->symbol (conc "remote:" procstr))) params) (apply (eval (string->symbol procstr)) params))) (define (server:start db hostn) (debug:print 0 "Attempting to start the server ...") | > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < < < < < < < < < < < < < < < < < < | < < < < < < | < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | | | | | | | | | | | | | 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 | (apply (eval (string->symbol procstr)) params)) ;; (if *runremote* ;; (apply (eval (string->symbol (conc "remote:" procstr))) params) (apply (eval (string->symbol procstr)) params))) (define (server:start db hostn) (debug:print 0 "Attempting to start the server ...") (let ((host:port (db:get-var db "SERVER"))) ;; do whe already have a server running? (if host:port (set! *runremote* #t) (let* ((rpc:listener (server:find-free-port-and-open (rpc:default-server-port))) (th1 (make-thread (cute (rpc:make-server rpc:listener) "rpc:server") 'rpc:server)) (th2 (make-thread (lambda ()(db:updater)))) (hostname (if (string=? "-" hostn) (get-host-name) hostn)) (ipaddrstr (if (string=? "-" hostn) (string-intersperse (map number->string (u8vector->list (hostname->ip hostname))) ".") #f)) (host:port (conc (if ipaddrstr ipaddrstr hostname) ":" (rpc:default-server-port)))) (db:set-var db "SERVER" host:port) (set! *cache-on* #t) ;; can use this to run most anything at the remote (rpc:publish-procedure! 'remote:run (lambda (procstr . params) (server:autoremote procstr params))) ;;====================================================================== ;; db specials here ;;====================================================================== ;; remote call to open-run-close (rpc:publish-procedure! 'rdb:open-run-close (lambda (procname . remargs) (debug:print 4 "INFO: rdb:open-run-close " procname " " remargs) (set! *last-db-access* (current-seconds)) (apply open-run-close (eval procname) remargs))) (rpc:publish-procedure! 'cdb:test-set-state-status (lambda (test-id status state) (debug:print 4 "INFO: cdb:test-set-state-status " procname " " remargs) (apply cdb:test-set-state-status remargs))) ;;====================================================================== ;; end of publish-procedure section ;;====================================================================== (set! *rpc:listener* rpc:listener) (on-exit (lambda () (sqlite3:execute db "DELETE FROM metadat WHERE var='SERVER' and val=?;" host:port) (sqlite3:finalize! db))) (thread-start! th1) (thread-start! th2) ;; (thread-join! th2) ;; return th2 for the calling process to do a join with th2 )))) ;; rpc:server))) (define (server:keep-running db) ;; if none running or if > 20 seconds since ;; server last used then start shutdown (let loop ((count 0)) (thread-sleep! 20) ;; no need to do this very often (let ((numrunning (db:get-count-tests-running db))) |
︙ | ︙ | |||
295 296 297 298 299 300 301 | exn (begin (print "Failed to bind to port " (rpc:default-server-port) ", trying next port") (server:find-free-port-and-open (+ port 1))) (rpc:default-server-port port) (tcp-listen (rpc:default-server-port)))) | | | | | | > > > > | 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 | exn (begin (print "Failed to bind to port " (rpc:default-server-port) ", trying next port") (server:find-free-port-and-open (+ port 1))) (rpc:default-server-port port) (tcp-listen (rpc:default-server-port)))) (define (server:client-setup) (if *runremote* (begin (debug:print 0 "ERROR: Attempt to connect to server but already connected") #f) (let* ((hostinfo (open-run-close db:get-var #f "SERVER")) (hostdat (if hostinfo (string-split hostinfo ":") #f)) (host (if hostinfo (car hostdat) #f)) (port (if (and hostinfo (> (length hostdat) 1))(cadr hostdat) #f))) (if (and port (string->number port)) (let ((portn (string->number port))) (debug:print 2 "INFO: Setting up to connect to host " host ":" port) (handle-exceptions exn (begin (print "Exception: " ((condition-property-accessor 'exn 'message) exn)) (open-run-close (lambda (db . param) (sqlite3:execute db "DELETE FROM metadat WHERE var='SERVER'")) #f) (set! *runremote* #f)) (if (and (not (args:get-arg "-server")) ;; no point in the server using the server using the server ((rpc:procedure 'serve:login host portn) *toppath*)) (begin (debug:print 2 "INFO: Connected to " host ":" port) (set! *runremote* (vector host portn))) (begin (debug:print 2 "INFO: Failed to connect to " host ":" port) (set! *runremote* #f))))) (debug:print 2 "INFO: no server available"))))) |
Modified tests.scm from [015515b8a1] to [35c75741ff].
︙ | ︙ | |||
108 109 110 111 112 113 114 | ;; this test is younger, store it in the hash (hash-table-set! tests-hash full-testname testdat)))) results) (if (null? tal) (map cdr (hash-table->alist tests-hash)) ;; return a list of the most recent tests (loop (car tal)(cdr tal)))))))))) | | | | 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | ;; this test is younger, store it in the hash (hash-table-set! tests-hash full-testname testdat)))) results) (if (null? tal) (map cdr (hash-table->alist tests-hash)) ;; return a list of the most recent tests (loop (car tal)(cdr tal)))))))))) ;; Do not rpc this one, do the underlying calls!!! (define (tests:test-set-status! db test-id state status comment dat) (let* ((real-status status) (otherdat (if dat dat (make-hash-table))) (testdat (open-run-close db:get-test-info-by-id db test-id)) (run-id (db:test-get-run_id testdat)) (test-name (db:test-get-testname testdat)) (item-path (db:test-get-item-path testdat)) ;; before proceeding we must find out if the previous test (where all keys matched except runname) ;; was WAIVED if this test is FAIL (waived (if (equal? status "FAIL") (let ((prev-test (test:get-previous-test-run-record db run-id test-name item-path))) |
︙ | ︙ | |||
136 137 138 139 140 141 142 | #f)) #f))) (if waived (set! real-status "WAIVED")) (debug:print 4 "real-status " real-status ", waived " waived ", status " status) ;; update the primary record IF state AND status are defined (if (and state status) | > | | | | 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | #f)) #f))) (if waived (set! real-status "WAIVED")) (debug:print 4 "real-status " real-status ", waived " waived ", status " status) ;; update the primary record IF state AND status are defined (if (and state status) ;; (rdb:open-run-close 'cdb:test-set-state-status #f test-id real-status state)) ;; this one works (cdb:test-set-state-status test-id real-status state)) ;; if status is "AUTO" then call rollup (note, this one modifies data in test ;; run area, do not rpc it (yet) (if (and test-id state status (equal? status "AUTO")) (open-run-close db:test-data-rollup db test-id status)) ;; add metadata (need to do this way to avoid SQL injection issues) ;; :first_err ;; (let ((val (hash-table-ref/default otherdat ":first_err" #f))) ;; (if val ;; (sqlite3:execute db "UPDATE tests SET first_err=? WHERE run_id=? AND testname=? AND item_path=?;" val run-id test-name item-path))) |
︙ | ︙ | |||
175 176 177 178 179 180 181 | variable "," value "," expected "," tol "," units "," dcomment ",," ;; extra comma for status type ))) | | | | | 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 | variable "," value "," expected "," tol "," units "," dcomment ",," ;; extra comma for status type ))) (open-run-close db:csv->test-data db test-id dat)))) ;; need to update the top test record if PASS or FAIL and this is a subtest (open-run-close db:roll-up-pass-fail-counts db run-id test-name item-path status) (if (or (and (string? comment) (string-match (regexp "\\S+") comment)) waived) (let ((cmt (if waived waived comment))) (open-run-close db:test-set-comment db test-id cmt))) )) (define (tests:test-set-toplog! db run-id test-name logf) (sqlite3:execute db "UPDATE tests SET final_logf=? WHERE run_id=? AND testname=? AND item_path='';" logf run-id test-name)) (define (tests:summarize-items db run-id test-name force) |
︙ | ︙ |
Modified tests/Makefile from [bc9090b62c] to [53526c0eed].
︙ | ︙ | |||
18 19 20 21 22 23 24 | test2 : fullprep cd fullrun;$(MEGATEST) -runtests ez_pass -reqtarg ubuntu/nfs/none :runname $(RUNNAME)_a $(SERVER) test3 : fullprep cd fullrun;$(MEGATEST) -runtests runfirst -reqtarg ubuntu/nfs/none :runname $(RUNNAME)_b $(SERVER) -debug 10 test4 : fullprep | > | > > | | | | | | | 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 | test2 : fullprep cd fullrun;$(MEGATEST) -runtests ez_pass -reqtarg ubuntu/nfs/none :runname $(RUNNAME)_a $(SERVER) test3 : fullprep cd fullrun;$(MEGATEST) -runtests runfirst -reqtarg ubuntu/nfs/none :runname $(RUNNAME)_b $(SERVER) -debug 10 test4 : fullprep cd fullrun;$(MEGATEST) $(SERVER) & cd fullrun;sleep 5;$(MEGATEST) -debug $(DEBUG) -runall -reqtarg ubuntu/nfs/none :runname $(RUNNAME)_b -m "This is a comment specific to a run" -v # NOTE: Only one instance can be a server test5 : fullprep cd fullrun;$(MEGATEST) $(SERVER) & cd fullrun;sleep 10;$(MEGATEST) -runall -reqtarg ubuntu/nfs/none :runname $(RUNNAME)_aa -debug $(DEBUG) > aa.log 2> aa.log & cd fullrun;sleep 10;$(MEGATEST) -runall -reqtarg ubuntu/nfs/none :runname $(RUNNAME)_ab -debug $(DEBUG) > ab.log 2> ab.log & cd fullrun;sleep 10;$(MEGATEST) -runall -reqtarg ubuntu/nfs/none :runname $(RUNNAME)_ac -debug $(DEBUG) > ac.log 2> ac.log & cd fullrun;sleep 10;$(MEGATEST) -runall -reqtarg ubuntu/nfs/none :runname $(RUNNAME)_ad -debug $(DEBUG) > ad.log 2> ad.log & # cd fullrun;sleep 10;$(MEGATEST) -runall -reqtarg ubuntu/nfs/none :runname $(RUNNAME)_ae -debug $(DEBUG) > ae.log 2> ae.log & # cd fullrun;sleep 10;$(MEGATEST) -runall -reqtarg ubuntu/nfs/none :runname $(RUNNAME)_af -debug $(DEBUG) > af.log 2> af.log & test6: fullprep cd fullrun;$(MEGATEST) -runtests runfirst -itempatt %/1 -reqtarg ubuntu/nfs/none :runname $(RUNNAME)_itempatt -v cd fullrun;$(MEGATEST) -runtests runfirst -itempatt %blahha% -reqtarg ubuntu/nfs/none :runname $(RUNNAME)_itempatt -debug 10 cleanprep : ../*.scm Makefile */*.config # if [ -e fullrun/megatest.db ]; then sqlite3 fullrun/megatest.db "delete from metadat where var='SERVER';";fi |
︙ | ︙ |