Overview
Comment: | rpc calls for iterated test rollup implemented and working in local mode |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | test-specific-db |
Files: | files | file ages | folders |
SHA1: |
0d2f1ac29a1ef57a67bc270cc6b016b9 |
User & Date: | mrwellan on 2012-10-03 10:39:05 |
Other Links: | branch diff | manifest | tags |
Context
2012-10-03
| ||
11:12 | rpc calls for iterated test rollup implemented and appears to work in remote mode check-in: ad930701a2 user: mrwellan tags: test-specific-db | |
10:39 | rpc calls for iterated test rollup implemented and working in local mode check-in: 0d2f1ac29a user: mrwellan tags: test-specific-db | |
2012-10-02
| ||
22:24 | bumped version check-in: 029ed471cf user: matt tags: test-specific-db, v1.4609 | |
Changes
Modified db.scm from [bc17cfd6cb] to [aa4fc1889f].
︙ | ︙ | |||
1011 1012 1013 1014 1015 1016 1017 | ;;====================================================================== ;; QUEUE UP META, TEST STATUS AND STEPS ;;====================================================================== (define (db:updater) (let loop ((start-time (current-time))) | | | > | | | | < < < | | | | | < | | > > > > > > > > | | < < < < | | | | > > | | < | | | < < < < < < < < < < < < < < < < < < < < < < < < | 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 | ;;====================================================================== ;; QUEUE UP META, TEST STATUS AND STEPS ;;====================================================================== (define (db:updater) (let loop ((start-time (current-time))) (thread-sleep! 15) ;; move save time around to minimize regular collisions? (db:write-cached-data) (loop start-time))) (define (cdb:test-set-status-state test-id status state #!key (msg #f)) (debug:print 4 "INFO: Adding status/state to queue: " status "/" state) (mutex-lock! *incoming-mutex*) (if msg (set! *incoming-data* (cons (vector 'state-status-msg (current-seconds) (list state status msg test-id)) *incoming-data*)) (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 (cdb:test-rollup-iterated-pass-fail test-id) (debug:print 4 "INFO: Adding " test-id " for iterated rollup to the queue") (mutex-lock! *incoming-mutex*) (set! *incoming-data* (cons (vector 'iterated-p/f-rollup (current-seconds) (list test-id test-id test-id test-id)) *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))) ;; 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 ((state-status-stmt (sqlite3:prepare db "UPDATE tests SET state=?,status=? WHERE id=?;")) (state-status-msg-stmt (sqlite3:prepare db "UPDATE tests SET state=?,status=?,comment=? WHERE id=?;")) (iterated-rollup-stmt (sqlite3:prepare db "UPDATE tests SET status=CASE WHEN (SELECT fail_count FROM tests WHERE id=?) > 0 THEN 'FAIL' WHEN (SELECT pass_count FROM tests WHERE id=?) > 0 AND (SELECT status FROM tests WHERE id=?) NOT IN ('WARN','FAIL') THEN 'PASS' ELSE status END WHERE id=?;")) (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) (let ((params (vector-ref entry 2))) (debug:print 4 "INFO: flushing " entry " to db") (case (vector-ref entry 0) ((state-status) (apply sqlite3:execute state-status-stmt params)) ((state-status-msg) (apply sqlite3:execute state-status-msg-stmt params)) ((iterated-p/f-rollup) (apply sqlite3:execute iterated-rollup-stmt params)) (else (debug:print 0 "ERROR: Queued entry not recognised " entry))))) data))) (sqlite3:finalize! state-status-stmt) (sqlite3:finalize! state-status-msg-stmt) (sqlite3:finalize! iterated-rollup-stmt) )) #f)) (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") (equal? status "RUNNING"))) |
︙ | ︙ | |||
1277 1278 1279 1280 1281 1282 1283 | (SELECT count(id) FROM test_data WHERE test_id=? AND status like 'pass') AS pass_count;" test-id test-id) (sqlite3:finalize! tdb) ;; Now rollup the counts to the central megatest.db (sqlite3:execute db "UPDATE tests SET fail_count=?,pass_count=? WHERE id=?;" fail-count pass-count test-id) | | | > | | | | | | | | | | | > | 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 | (SELECT count(id) FROM test_data WHERE test_id=? AND status like 'pass') AS pass_count;" test-id test-id) (sqlite3:finalize! tdb) ;; Now rollup the counts to the central megatest.db (sqlite3:execute db "UPDATE tests SET fail_count=?,pass_count=? WHERE id=?;" fail-count pass-count test-id) (thread-sleep! 1) ;; play nice with the queue by ensuring the rollup is at least one second later than the set ;; if the test is not FAIL then set status based on the fail and pass counts. (cdb:test-rollup-iterated-pass-fail test-id) ;; (sqlite3:execute ;; db ;;; NOTE: Should this be WARN,FAIL? A WARN is not a FAIL????? BUG FIXME ;; "UPDATE tests ;; SET status=CASE WHEN (SELECT fail_count FROM tests WHERE id=?) > 0 ;; THEN 'FAIL' ;; WHEN (SELECT pass_count FROM tests WHERE id=?) > 0 AND ;; (SELECT status FROM tests WHERE id=?) NOT IN ('WARN','FAIL') ;; THEN 'PASS' ;; ELSE status ;; END WHERE id=?;" ;; test-id test-id test-id test-id) )))) (define (db:get-prev-tol-for-test db test-id category variable) ;; Finish me? (values #f #f #f)) ;;====================================================================== ;; S T E P S |
︙ | ︙ | |||
1587 1588 1589 1590 1591 1592 1593 | (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))) | > > > > > > > | 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 | (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))) ;; (define (rdb:test-set-status-state 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))) |