Overview
Comment: | Implemented fine grained deletion of runs and tests |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
09102f8425e4423c35d3cf292d1b704e |
User & Date: | matt on 2011-05-11 01:21:54 |
Other Links: | manifest | tags |
Context
2011-05-11
| ||
01:24 | Bumped version to 1.04 check-in: 28b7497853 user: matt tags: trunk | |
01:21 | Implemented fine grained deletion of runs and tests check-in: 09102f8425 user: matt tags: trunk | |
2011-05-09
| ||
18:06 | Exit status handling has to be hard coded to a number, can't seem to get a variable to work check-in: 290c7d7cc8 user: mrwellan tags: trunk | |
Changes
Modified db.scm from [499db9fa5f] to [5decf9595d].
︙ | ︙ | |||
108 109 110 111 112 113 114 115 116 117 118 119 120 121 | (vector-ref row n) (if (null? tal) #f (loop (car tal)(cdr tal)(+ n 1))))))) ;;====================================================================== ;; R U N S ;;====================================================================== (define (db-get-runs db runpatt . count) (let* ((res '()) (keys (db-get-keys db)) (remfields (list "id" "runname" "state" "status" "owner" "event_time")) (header (append (map key:get-fieldname keys) remfields)) (keystr (conc (keys->keystr keys) "," | > > > > > > > > | 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | (vector-ref row n) (if (null? tal) #f (loop (car tal)(cdr tal)(+ n 1))))))) ;;====================================================================== ;; R U N S ;;====================================================================== (define (runs:get-std-run-fields keys remfields) (let* ((header (append (map key:get-fieldname keys) remfields)) (keystr (conc (keys->keystr keys) "," (string-intersperse remfields ",")))) (list keystr header))) ;; replace header and keystr with a call to runs:get-std-run-fields (define (db-get-runs db runpatt . count) (let* ((res '()) (keys (db-get-keys db)) (remfields (list "id" "runname" "state" "status" "owner" "event_time")) (header (append (map key:get-fieldname keys) remfields)) (keystr (conc (keys->keystr keys) "," |
︙ | ︙ | |||
155 156 157 158 159 160 161 162 163 164 165 166 167 168 | (conc "SELECT " keystr " FROM runs WHERE id=?;") run-id) (vector header res))) (define (db:set-comment-for-run db run-id comment) (sqlite3:execute db "UPDATE runs SET comment=? WHERE id=?;" comment run-id)) ;;====================================================================== ;; T E S T S ;;====================================================================== (define (make-db:test)(make-vector 6)) (define-inline (db:test-get-id vec) (vector-ref vec 0)) (define-inline (db:test-get-run_id vec) (vector-ref vec 1)) | > > > | 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | (conc "SELECT " keystr " FROM runs WHERE id=?;") run-id) (vector header res))) (define (db:set-comment-for-run db run-id comment) (sqlite3:execute db "UPDATE runs SET comment=? WHERE id=?;" comment run-id)) (define (db:delete-run db run-id) (sqlite3:execute db "DELETE FROM runs WHERE id=?;" run-id)) ;;====================================================================== ;; T E S T S ;;====================================================================== (define (make-db:test)(make-vector 6)) (define-inline (db:test-get-id vec) (vector-ref vec 0)) (define-inline (db:test-get-run_id vec) (vector-ref vec 1)) |
︙ | ︙ | |||
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | (lambda (id run-id testname state status event-time host cpuload diskfree uname rundir item-path run-duration final-logf comment) (set! res (cons (vector id run-id testname state status event-time host cpuload diskfree uname rundir item-path run-duration final-logf comment) res))) db "SELECT id,run_id,testname,state,status,event_time,host,cpuload,diskfree,uname,rundir,item_path,run_duration,final_logf,comment FROM tests WHERE run_id=? AND testname like ? AND item_path LIKE ? ORDER BY id DESC;" run-id testpatt (if itempatt itempatt "%")) res)) (define (db:delete-test-step-records db run-id test-name) (sqlite3:execute db "DELETE FROM test_steps WHERE test_id in (SELECT id FROM tests WHERE run_id=? AND testname=?);" run-id test-name)) (define (db:get-count-tests-running db) (let ((res 0)) (sqlite3:for-each-row (lambda (count) (set! res count)) db "SELECT count(id) FROM tests WHERE state = 'RUNNING' OR state = 'LAUNCHED' OR state = 'REMOTEHOSTSTART';") | > > > > > > | 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | (lambda (id run-id testname state status event-time host cpuload diskfree uname rundir item-path run-duration final-logf comment) (set! res (cons (vector id run-id testname state status event-time host cpuload diskfree uname rundir item-path run-duration final-logf comment) res))) db "SELECT id,run_id,testname,state,status,event_time,host,cpuload,diskfree,uname,rundir,item_path,run_duration,final_logf,comment FROM tests WHERE run_id=? AND testname like ? AND item_path LIKE ? ORDER BY id DESC;" run-id testpatt (if itempatt itempatt "%")) res)) ;; this one is a bit broken BUG FIXME (define (db:delete-test-step-records db run-id test-name) (sqlite3:execute db "DELETE FROM test_steps WHERE test_id in (SELECT id FROM tests WHERE run_id=? AND testname=?);" run-id test-name)) ;; (define (db:delete-test-records db test-id) (sqlite3:execute db "DELETE FROM test_steps WHERE test_id=?;" test-id) (sqlite3:execute db "DELETE FROM tests WHERE id=?;" test-id)) (define (db:get-count-tests-running db) (let ((res 0)) (sqlite3:for-each-row (lambda (count) (set! res count)) db "SELECT count(id) FROM tests WHERE state = 'RUNNING' OR state = 'LAUNCHED' OR state = 'REMOTEHOSTSTART';") |
︙ | ︙ |
Modified megatest.scm from [3711174da5] to [660b628f9e].
︙ | ︙ | |||
42 43 44 45 46 47 48 49 50 | -testpatt patt : in list-runs show only these tests, % is the wildcard -itempatt patt : in list-runs show only tests with items that match patt -showkeys : show the keys used in this megatest setup Misc -force : override some checks -xterm : start an xterm instead of launching the test Helpers | > > > | | | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | -testpatt patt : in list-runs show only these tests, % is the wildcard -itempatt patt : in list-runs show only tests with items that match patt -showkeys : show the keys used in this megatest setup Misc -force : override some checks -xterm : start an xterm instead of launching the test -remove-runs : remove the data for a run, requires fields, :runname and -testpatt -testpatt patt : remove tests matching patt (requires -remove-runs) Helpers -runstep stepname ... : take remaining params as comand and execute as stepname log will be in stepname.log. Best to put command in quotes -logpro file : with -exec apply logpro file to stepname.log, creates stepname.html and sets log to same If using make use stepname_logpro.log as your target Called as " (string-intersperse (argv) " "))) ;; -gui : start a gui interface |
︙ | ︙ | |||
73 74 75 76 77 78 79 | ":status" "-list-runs" "-testpatt" "-itempatt" "-setlog" "-runstep" "-logpro" | < | | 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | ":status" "-list-runs" "-testpatt" "-itempatt" "-setlog" "-runstep" "-logpro" "-m" ) (list "-h" "-force" "-xterm" "-showkeys" "-test-status" "-gui" "-runall" ;; run all tests "-remove-runs" ) args:arg-hash 0)) (if (args:get-arg "-h") (begin (print help) |
︙ | ︙ | |||
263 264 265 266 267 268 269 | (runtests)) ;;====================================================================== ;; Remove old run(s) ;;====================================================================== (define (remove-runs) | > | < | | > > > > > > | | | | | | | | | | | > | | < > | < | | | | 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 | (runtests)) ;;====================================================================== ;; Remove old run(s) ;;====================================================================== (define (remove-runs) (cond ((not (args:get-arg ":runname")) (print "ERROR: Missing required parameter for -remove-runs, you must specify the run name pattern with :runname patt") (exit 2)) ((not (args:get-arg "-testpatt")) (print "ERROR: Missing required parameter for -remove-runs, you must specify the test pattern with -testpatt") (exit 3)) ((not (args:get-arg "-itempatt")) (print "ERROR: Missing required parameter for -remove-runs, you must specify the items with -itempatt") (exit 4)) ((let ((db #f)) (if (not (setup-for-run)) (begin (print "Failed to setup, exiting") (exit 1))) (set! db (open-db)) (if (not (car *configinfo*)) (begin (print "ERROR: Attempted to remove test(s) but run area config file not found") (exit 1)) ;; put test parameters into convenient variables (runs:remove-runs db (args:get-arg ":runname") (args:get-arg "-testpatt") (args:get-arg "-itempatt"))) (sqlite3:finalize! db) (set! *didsomething* #t))))) (if (args:get-arg "-remove-runs") (remove-runs)) ;;====================================================================== ;; execute the test ;; - gets called on remote host ;; - receives info from the -execute param ;; - passes info to steps via MT_CMDINFO env var (future is to use a dot file) ;; - gathers host info and |
︙ | ︙ |
Modified runs.scm from [55dbaeab50] to [40e5373888].
︙ | ︙ | |||
12 13 14 15 16 17 18 | ;; register a test run with the db (define (register-run db keys) ;; test-name) (let* ((keystr (keys->keystr keys)) (comma (if (> (length keys) 0) "," "")) (andstr (if (> (length keys) 0) " AND " "")) (valslots (keys->valslots keys)) ;; ?,?,? ... | | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ;; register a test run with the db (define (register-run db keys) ;; test-name) (let* ((keystr (keys->keystr keys)) (comma (if (> (length keys) 0) "," "")) (andstr (if (> (length keys) 0) " AND " "")) (valslots (keys->valslots keys)) ;; ?,?,? ... (keyvallst (keys->vallist keys)) ;; extracts the values from remainder of (argv) (runname (get-with-default ":runname" #f)) (state (get-with-default ":state" "no")) (status (get-with-default ":status" "n/a")) (allvals (append (list runname state status user) keyvallst)) (qryvals (append (list runname) keyvallst)) (key=?str (string-intersperse (map (lambda (k)(conc (key:get-fieldname k) "=?")) keys) " AND "))) ;; (print "keys: " keys " allvals: " allvals " keyvallst: " keyvallst) |
︙ | ︙ | |||
39 40 41 42 43 44 45 46 47 48 49 50 51 52 | qryvals) (sqlite3:execute db "UPDATE runs SET state=?,status=? WHERE id=?;" state status res) res) (begin (print "ERROR: Called without all necessary keys") #f)))) (define (register-test db run-id test-name item-path) (sqlite3:execute db "INSERT OR IGNORE INTO tests (run_id,testname,event_time,item_path) VALUES (?,?,strftime('%s','now'),?);" run-id test-name item-path)) (define (test-set-status! db run-id test-name state status itemdat-or-path . comment) (let ((item-path (if (string? itemdat-or-path) itemdat-or-path (item-list->path itemdat-or-path)))) (sqlite3:execute db "UPDATE tests SET state=?,status=?,event_time=strftime('%s','now') WHERE run_id=? AND testname=? AND item_path=?;" state status run-id test-name item-path) | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | qryvals) (sqlite3:execute db "UPDATE runs SET state=?,status=? WHERE id=?;" state status res) res) (begin (print "ERROR: Called without all necessary keys") #f)))) ;; runs:get-runs-by-patt ;; get runs by list of criteria ;; register a test run with the db ;; ;; Use: (db-get-value-by-header (db:get-header runinfo)(db:get-row runinfo)) ;; to extract info from the structure returned ;; (define (runs:get-runs-by-patt db keys runnamepatt) ;; test-name) (let* ((keyvallst (keys->vallist keys)) (tmp (runs:get-std-run-fields keys '("id" "runname" "state" "status" "owner" "event_time"))) (keystr (car tmp)) (header (cadr tmp)) (res '()) (key-patt "")) (for-each (lambda (keyval) (let* ((key (vector-ref keyval 0)) (fulkey (conc ":" key)) (patt (args:get-arg fulkey))) (if patt (set! key-patt (conc key-patt " AND " key " like '" patt "'")) (begin (print "ERROR: searching for runs with no pattern set for " fulkey) (exit 6))))) keys) (sqlite3:for-each-row (lambda (a . r) (set! res (cons (list->vector (cons a r)) res))) db (conc "SELECT " keystr " FROM runs WHERE runname like ? " key-patt ";") runnamepatt) (vector header res))) (define (register-test db run-id test-name item-path) (sqlite3:execute db "INSERT OR IGNORE INTO tests (run_id,testname,event_time,item_path) VALUES (?,?,strftime('%s','now'),?);" run-id test-name item-path)) (define (test-set-status! db run-id test-name state status itemdat-or-path . comment) (let ((item-path (if (string? itemdat-or-path) itemdat-or-path (item-list->path itemdat-or-path)))) (sqlite3:execute db "UPDATE tests SET state=?,status=?,event_time=strftime('%s','now') WHERE run_id=? AND testname=? AND item_path=?;" state status run-id test-name item-path) |
︙ | ︙ | |||
322 323 324 325 326 327 328 | ((cadr testdat)) (hash-table-delete! *waiting-queue* testname))) (if (not db) (sqlite3:finalize! ldb)))) waiting-test-names) (sleep 10) ;; no point in rushing things at this stage? (loop (hash-table-keys *waiting-queue*))))))) | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | ((cadr testdat)) (hash-table-delete! *waiting-queue* testname))) (if (not db) (sqlite3:finalize! ldb)))) waiting-test-names) (sleep 10) ;; no point in rushing things at this stage? (loop (hash-table-keys *waiting-queue*))))))) ;; Remove runs ;; fields are passing in through (define (runs:remove-runs db runnamepatt testpatt itempatt) (let* ((keys (db-get-keys db)) (rundat (runs:get-runs-by-patt db keys runnamepatt)) (header (vector-ref rundat 0)) (runs (vector-ref rundat 1))) (print "Header: " header) (for-each (lambda (run) (let ((runkey (string-intersperse (map (lambda (k) (db-get-value-by-header run header (vector-ref k 0))) keys) "/"))) (let* ((run-id (db-get-value-by-header run header "id") ) (tests (db-get-tests-for-run db (db-get-value-by-header run header "id") testpatt itempatt))) (if (not (null? tests)) (begin (print "Removing tests for run: " runkey " " (db-get-value-by-header run header "runname")) (for-each (lambda (test) (print " " (db:test-get-testname test) " id: " (db:test-get-id test) " " (db:test-get-item-path test)) (db:delete-test-records db (db:test-get-id test)) (if (> (string-length (db:test-get-rundir test)) 5) ;; bad heuristic but should prevent /tmp /home etc. (let ((fullpath (db:test-get-rundir test))) ;; "/" (db:test-get-item-path test)))) (print "rm -rf " fullpath) (system (conc "rm -rf " fullpath))))) tests) (let ((remtests (db-get-tests-for-run db (db-get-value-by-header run header "id")))) (if (null? remtests) ;; no more tests remaining (begin (print "Removing run: " runkey " " (db-get-value-by-header run header "runname")) (db:delete-run db run-id)))) ))))) runs))) |
Modified tests/megatest.config from [bf33696f68] to [0d07485d64].
1 2 3 4 5 6 7 | [fields] sysname TEXT fsname TEXT datapath TEXT [setup] # exectutable /path/to/megatest | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | [fields] sysname TEXT fsname TEXT datapath TEXT [setup] # exectutable /path/to/megatest max_concurrent_jobs 405 runsdir /tmp/runs [jobtools] # ## launcher launches jobs, the job is managed on the target host ## by megatest, comment out launcher to run local # workhosts localhost hermes launcher nbfake |
︙ | ︙ |
Modified tests/tests/sqlitespeed/runscript.rb from [0c7cdb0a88] to [404979dd42].
︙ | ︙ | |||
11 12 13 14 15 16 17 | num_records=rand(60) # 0000 record_step("add #{num_records}","start","n/a") status=false (0..num_records).each do |i| randstring="a;lskdfja;sdfj;alsdfj;aslfdj;alsfja;lsfdj;alsfja;lsjfd;lasfjl;asdfja;slfj;alsjf;asljf;alsjf;lasdjf;lasjf;lasjf;alsjf;lashflkashflkerhflkdsvnlasldhlfaldf" # status=system "sqlite3 testing.db \"insert into blah (name) values ('#{randstring}');\"" system "megatest -step testing :state wrote_junk :status #{num_records}" | | | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | num_records=rand(60) # 0000 record_step("add #{num_records}","start","n/a") status=false (0..num_records).each do |i| randstring="a;lskdfja;sdfj;alsdfj;aslfdj;alsfja;lsfdj;alsfja;lsjfd;lasfjl;asdfja;slfj;alsjf;asljf;alsjf;lasdjf;lasjf;lasjf;alsjf;lashflkashflkerhflkdsvnlasldhlfaldf" # status=system "sqlite3 testing.db \"insert into blah (name) values ('#{randstring}');\"" system "megatest -step testing :state wrote_junk :status #{num_records}" sleep(5) puts "i=#{i}" end if status==0 status='pass' else status='fail' end |
︙ | ︙ |