Overview
| SHA1 Hash: | 3bb0b5e9f9774139e657a36648bee7816bead1ae |
|---|---|
| Date: | 2011-07-18 23:13:18 |
| User: | matt |
| Comment: | Added mechanism to update db schema |
| Timelines: | family | ancestors | descendants | both | trunk |
| Downloads: | Tarball | ZIP archive |
| Other Links: | files | file ages | manifest |
Tags And Properties
- branch=trunk inherited from [d673a9367e]
- sym-trunk inherited from [d673a9367e]
Changes
Modified dashboard.scm from [e9212eda7d2fcf5a] to [74244af35f577be4].
26 (include "db.scm") 26 (include "db.scm") 27 (include "configf.scm") 27 (include "configf.scm") 28 (include "process.scm") 28 (include "process.scm") 29 (include "launch.scm") 29 (include "launch.scm") 30 (include "runs.scm") 30 (include "runs.scm") 31 (include "gui.scm") 31 (include "gui.scm") 32 (include "dashboard-tests.scm") 32 (include "dashboard-tests.scm") > 33 (include "megatest-version.scm") 33 34 34 (define help " 35 (define help " 35 Megatest Dashboard, documentation at http://www.kiatoa.com/fossils/megatest 36 Megatest Dashboard, documentation at http://www.kiatoa.com/fossils/megatest 36 version 0.2 37 version 0.2 37 license GPL, Copyright Matt Welland 2011 38 license GPL, Copyright Matt Welland 2011 38 39 39 Usage: dashboard [options] 40 Usage: dashboard [options]
Modified db.scm from [5c1eda37b38d0b1f] to [88fcf141f544e4bb].
48 (id INTEGER PRIMARY KEY, 48 (id INTEGER PRIMARY KEY, 49 run_id INTEGER, 49 run_id INTEGER, 50 testname TEXT, 50 testname TEXT, 51 host TEXT DEFAULT 'n/a', 51 host TEXT DEFAULT 'n/a', 52 cpuload REAL DEFAULT -1, 52 cpuload REAL DEFAULT -1, 53 diskfree INTEGER DEFAULT -1, 53 diskfree INTEGER DEFAULT -1, 54 uname TEXT DEFAULT 'n/a', 54 uname TEXT DEFAULT 'n/a', 55 rundir TEXT DEFAULT 'n/a', | 55 rundir TEXT DEFAULT 'n/a', 56 item_path TEXT DEFAULT '', 56 item_path TEXT DEFAULT '', 57 state TEXT DEFAULT 'NOT_STARTED', 57 state TEXT DEFAULT 'NOT_STARTED', 58 status TEXT DEFAULT 'FAIL', 58 status TEXT DEFAULT 'FAIL', 59 attemptnum INTEGER DEFAULT 0, 59 attemptnum INTEGER DEFAULT 0, 60 final_logf TEXT DEFAULT 'logs/final.log', 60 final_logf TEXT DEFAULT 'logs/final.log', 61 logdat BLOB, 61 logdat BLOB, 62 run_duration INTEGER DEFAULT 0, 62 run_duration INTEGER DEFAULT 0, 63 comment TEXT DEFAULT '', 63 comment TEXT DEFAULT '', 64 event_time TIMESTAMP, 64 event_time TIMESTAMP, 65 fail_count INTEGER DEFAULT 0, 65 fail_count INTEGER DEFAULT 0, 66 pass_count INTEGER DEFAULT 0, 66 pass_count INTEGER DEFAULT 0, > 67 tags TEXT DEFAULT '', 67 CONSTRAINT testsconstraint UNIQUE (run_id, testname, item_p 68 CONSTRAINT testsconstraint UNIQUE (run_id, testname, item_p 68 );") 69 );") 69 (sqlite3:execute db "CREATE INDEX tests_index ON tests (run_id, testna 70 (sqlite3:execute db "CREATE INDEX tests_index ON tests (run_id, testna 70 (sqlite3:execute db "CREATE VIEW runs_tests AS SELECT * FROM runs INNE 71 (sqlite3:execute db "CREATE VIEW runs_tests AS SELECT * FROM runs INNE 71 (sqlite3:execute db "CREATE TABLE test_steps 72 (sqlite3:execute db "CREATE TABLE test_steps 72 (id INTEGER PRIMARY KEY, 73 (id INTEGER PRIMARY KEY, 73 test_id INTEGER, 74 test_id INTEGER, 74 stepname TEXT, 75 stepname TEXT, 75 state TEXT DEFAULT 'NOT_STARTED', 76 state TEXT DEFAULT 'NOT_STARTED', 76 status TEXT DEFAULT 'n/a',event_time TIMESTAMP, 77 status TEXT DEFAULT 'n/a',event_time TIMESTAMP, 77 comment TEXT DEFAULT '', 78 comment TEXT DEFAULT '', 78 CONSTRAINT test_steps_constraint UNIQUE (test_id, 79 CONSTRAINT test_steps_constraint UNIQUE (test_id, 79 (sqlite3:execute db "CREATE TABLE extradat (id INTEGER PRIMARY KEY, ru 80 (sqlite3:execute db "CREATE TABLE extradat (id INTEGER PRIMARY KEY, ru > 81 (sqlite3:execute db "CREATE TABLE metadat (id INTEGER PRIMARY KEY, var > 82 CONSTRAINT metadat_constraint UNIQUE (id,var)) > 83 (db:set-var db "MEGATEST_VERSION" megatest-version) 80 (sqlite3:execute db "CREATE TABLE access_log (id INTEGER PRIMARY KEY, 84 (sqlite3:execute db "CREATE TABLE access_log (id INTEGER PRIMARY KEY, 81 db)) 85 db)) 82 86 83 ;; (if (args:get-arg "-db") | 87 (define (patch-db db) 84 ;; (set! db (open-db (args:get-arg "-db")))) | 88 (handle-exceptions > 89 exn > 90 (begin > 91 (print "Exception: " exn) > 92 (print "ERROR: Possible out of date schema, attempting to add table metadat > 93 (sqlite3:execute db "CREATE TABLE metadat (id INTEGER PRIMARY KEY, var TEXT > 94 CONSTRAINT metadat_constraint UNIQUE (id,var)) > 95 (db:set-var db "MEGATEST_VERSION" megatest-version) > 96 (print-call-chain)) > 97 (let ((mver (db:get-var db "MEGATEST_VERSION"))) > 98 (cond > 99 ((not mver) > 100 (print "Adding megatest-version to metadata") > 101 (sqlite3:execute db (db:set-var db "MEGATEST_VERSION" megatest-version))) > 102 ((< mver 1.18) > 103 (print "Adding tags column to tests table") > 104 (sqlite3:execute db "ALTER TABLE tests ADD COLUMN tags TEXT DEFAULT '';") > 105 )) > 106 (db:set-var db "MEGATEST_VERSION" megatest-version) > 107 ))) 85 108 86 ;; TODO | 109 ;;====================================================================== 87 ;; | 110 ;; meta get and set vars 88 ;; 1. Implement basic registering of records | 111 ;;====================================================================== 89 ;; 2. Implement basic querying of records < > 112 90 ;; eh? | 113 ;; returns number if string->number is successful, string otherwise > 114 (define (db:get-var db var) > 115 (let ((res #f)) > 116 (sqlite3:for-each-row > 117 (lambda (val) > 118 (set! res val)) > 119 db "SELECT val FROM metadat WHERE var=?;" var) > 120 (if (string? res) > 121 (let ((valnum (string->number res))) > 122 (if valnum valnum res)) > 123 res))) > 124 > 125 (define (db:set-var db var val) > 126 (sqlite3:execute db "INSERT OR REPLACE INTO metadat (var,val) VALUES (?,?);" v 91 127 92 (define (db-get-keys db) 128 (define (db-get-keys db) 93 (let ((res '())) 129 (let ((res '())) 94 (sqlite3:for-each-row 130 (sqlite3:for-each-row 95 (lambda (key keytype) 131 (lambda (key keytype) 96 (set! res (cons (vector key keytype) res))) 132 (set! res (cons (vector key keytype) res))) 97 db 133 db
Added megatest-version.scm version [d7a309cb03bb8fa4]
Modified megatest.scm from [dddaf7ea576442ae] to [95886c7e3041b227].
4 ;; greater. See the accompanying file COPYING for details. 4 ;; greater. See the accompanying file COPYING for details. 5 ;; 5 ;; 6 ;; This program is distributed WITHOUT ANY WARRANTY; without even the 6 ;; This program is distributed WITHOUT ANY WARRANTY; without even the 7 ;; implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 7 ;; implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 8 ;; PURPOSE. 8 ;; PURPOSE. 9 9 10 (include "common.scm") 10 (include "common.scm") 11 (define megatest-version 1.17) | 11 (include "megatest-version.scm") 12 12 13 (define help (conc " 13 (define help (conc " 14 Megatest, documentation at http://www.kiatoa.com/fossils/megatest 14 Megatest, documentation at http://www.kiatoa.com/fossils/megatest 15 version " megatest-version " 15 version " megatest-version " 16 license GPL, Copyright Matt Welland 2006-2011 16 license GPL, Copyright Matt Welland 2006-2011 17 17 18 Usage: megatest [options] 18 Usage: megatest [options] ................................................................................................................................................................................ 50 -remove-runs : remove the data for a run, requires all fields be sp 50 -remove-runs : remove the data for a run, requires all fields be sp 51 and :runname ,-testpatt and -itempatt 51 and :runname ,-testpatt and -itempatt 52 and -testpatt 52 and -testpatt 53 -keepgoing : continue running until no jobs are \"LAUNCHED\" or 53 -keepgoing : continue running until no jobs are \"LAUNCHED\" or 54 \"NOT_STARTED\" 54 \"NOT_STARTED\" 55 -rerun FAIL,WARN... : re-run if called on a test that previously ran (null 55 -rerun FAIL,WARN... : re-run if called on a test that previously ran (null 56 if -keepgoing is also specified) 56 if -keepgoing is also specified) > 57 -rebuild-db : bring the database schema up to date 57 58 58 Helpers 59 Helpers 59 -runstep stepname ... : take remaining params as comand and execute as stepn 60 -runstep stepname ... : take remaining params as comand and execute as stepn 60 log will be in stepname.log. Best to put command in 61 log will be in stepname.log. Best to put command in 61 -logpro file : with -exec apply logpro file to stepname.log, create 62 -logpro file : with -exec apply logpro file to stepname.log, create 62 stepname.html and sets log to same 63 stepname.html and sets log to same 63 If using make use stepname_logpro.log as your target 64 If using make use stepname_logpro.log as your target ................................................................................................................................................................................ 96 "-showkeys" 97 "-showkeys" 97 "-test-status" 98 "-test-status" 98 "-gui" 99 "-gui" 99 "-runall" ;; run all tests 100 "-runall" ;; run all tests 100 "-remove-runs" 101 "-remove-runs" 101 "-keepgoing" 102 "-keepgoing" 102 "-usequeue" 103 "-usequeue" > 104 "-rebuild-db" 103 "-v" ;; verbose 2, more than normal (normal is 1) 105 "-v" ;; verbose 2, more than normal (normal is 1) 104 "-q" ;; quiet 0, errors/warnings only 106 "-q" ;; quiet 0, errors/warnings only 105 ) 107 ) 106 args:arg-hash 108 args:arg-hash 107 0)) 109 0)) 108 110 109 (if (args:get-arg "-h") 111 (if (args:get-arg "-h") ................................................................................................................................................................................ 651 (set! *didsomething* #t))) 653 (set! *didsomething* #t))) 652 654 653 (if (args:get-arg "-gui") 655 (if (args:get-arg "-gui") 654 (begin 656 (begin 655 (debug:print 0 "Look at the dashboard for now") 657 (debug:print 0 "Look at the dashboard for now") 656 ;; (megatest-gui) 658 ;; (megatest-gui) 657 (set! *didsomething* #t))) 659 (set! *didsomething* #t))) > 660 > 661 ;;====================================================================== > 662 ;; Update the database schema on request > 663 ;;====================================================================== > 664 > 665 (if (args:get-arg "-rebuild-db") > 666 (begin > 667 (if (not (setup-for-run)) > 668 (begin > 669 (debug:print 0 "Failed to setup, exiting") > 670 (exit 1))) > 671 ;; now can find our db > 672 (set! db (open-db)) > 673 (patch-db db) > 674 (sqlite3:finalize! db) > 675 (set! *didsomething* #t))) 658 676 659 (if (not *didsomething*) 677 (if (not *didsomething*) 660 (debug:print 0 help)) 678 (debug:print 0 help)) 661 679 662 (if (not (eq? *globalexitstatus* 0)) 680 (if (not (eq? *globalexitstatus* 0)) 663 (if (or (args:get-arg "-runtests")(args:get-arg "-runall")) 681 (if (or (args:get-arg "-runtests")(args:get-arg "-runall")) 664 (begin 682 (begin
Modified tests/tests.scm from [6fc7061e87095edb] to [51a14a852438535d].
5 (include "../keys.scm") 5 (include "../keys.scm") 6 (include "../db.scm") 6 (include "../db.scm") 7 (include "../configf.scm") 7 (include "../configf.scm") 8 (include "../process.scm") 8 (include "../process.scm") 9 (include "../launch.scm") 9 (include "../launch.scm") 10 (include "../items.scm") 10 (include "../items.scm") 11 (include "../runs.scm") 11 (include "../runs.scm") > 12 (include "../megatest-version.scm") 12 13 13 (define conffile #f) 14 (define conffile #f) 14 (test "Read a config" #t (hash-table? (read-config "test.config"))) 15 (test "Read a config" #t (hash-table? (read-config "test.config"))) 15 (test "Read a config that doesn't exist" #t (hash-table? (read-config "nada.conf 16 (test "Read a config that doesn't exist" #t (hash-table? (read-config "nada.conf 16 17 17 (set! conffile (read-config "test.config")) 18 (set! conffile (read-config "test.config")) 18 (test "Get available diskspace" #t (number? (get-df "./"))) 19 (test "Get available diskspace" #t (number? (get-df "./"))) ................................................................................................................................................................................ 28 ;; (define *toppath* "tests") 29 ;; (define *toppath* "tests") 29 (define *db* #f) 30 (define *db* #f) 30 (test "setup for run" #t (begin (setup-for-run) 31 (test "setup for run" #t (begin (setup-for-run) 31 (string? (getenv "MT_RUN_AREA_HOME")))) 32 (string? (getenv "MT_RUN_AREA_HOME")))) 32 (test "open-db" #t (begin 33 (test "open-db" #t (begin 33 (set! *db* (open-db)) 34 (set! *db* (open-db)) 34 (if *db* #t #f))) 35 (if *db* #t #f))) > 36 > 37 ;; quit wasting time changing db to *db* > 38 (define db *db*) 35 39 36 (test "get cpu load" #t (number? (get-cpu-load))) 40 (test "get cpu load" #t (number? (get-cpu-load))) 37 (test "get uname" #t (string? (get-uname))) 41 (test "get uname" #t (string? (get-uname))) 38 42 39 (test "get validvalues as list" (list "start" "end" "completed") 43 (test "get validvalues as list" (list "start" "end" "completed") 40 (string-split (config-lookup *configdat* "validvalues" "state"))) 44 (string-split (config-lookup *configdat* "validvalues" "state"))) 41 45