Index: configf.scm ================================================================== --- configf.scm +++ configf.scm @@ -38,10 +38,11 @@ (let ((inp (open-input-file path)) (res (if (null? ht)(make-hash-table)(car ht))) (include-rx (regexp "^\\[include\\s+(.*)\\]\\s*$")) (section-rx (regexp "^\\[(.*)\\]\\s*$")) (blank-l-rx (regexp "^\\s*$")) + (key-sys-pr (regexp "^(\\S+)\\s+\\[system\\s+(\\S+.*)\\]\\s*$")) (key-val-pr (regexp "^(\\S+)\\s+(.*)$")) (comment-rx (regexp "^\\s*#.*"))) (let loop ((inl (read-line inp)) (curr-section-name "default")) (if (eof-object? inl) res @@ -51,10 +52,19 @@ (blank-l-rx _ (loop (read-line inp) curr-section-name)) (include-rx ( x include-file ) (begin (read-config include-file res) (loop (read-line inp) curr-section-name))) (section-rx ( x section-name ) (loop (read-line inp) section-name)) + (key-sys-pr ( x key cmd ) (let ((alist (hash-table-ref/default res curr-section-name '())) + (val (let ((res (car (cmd-run->list cmd)))) + (if (null? res) + "" + (string-intersperse res " "))))) + (hash-table-set! res curr-section-name + (config:assoc-safe-add alist key val)) + ;; (append alist (list (list key val)))) + (loop (read-line inp) curr-section-name))) (key-val-pr ( x key val ) (let ((alist (hash-table-ref/default res curr-section-name '()))) (hash-table-set! res curr-section-name (config:assoc-safe-add alist key val)) ;; (append alist (list (list key val)))) (loop (read-line inp) curr-section-name))) Index: db.scm ================================================================== --- db.scm +++ db.scm @@ -37,32 +37,35 @@ "state TEXT DEFAULT ''," "status TEXT DEFAULT ''," "owner TEXT DEFAULT ''," "event_time TIMESTAMP," "comment TEXT DEFAULT ''," + "fail_count INTEGER DEFAULT 0," + "pass_count INTEGER DEFAULT 0," "CONSTRAINT runsconstraint UNIQUE (runname" (if havekeys "," "") keystr "));")) (sqlite3:execute db (conc "CREATE INDEX runs_index ON runs (runname" (if havekeys "," "") keystr ");")) (sqlite3:execute db "CREATE TABLE tests (id INTEGER PRIMARY KEY, run_id INTEGER, testname TEXT, - itempath TEXT, host TEXT DEFAULT 'n/a', cpuload REAL DEFAULT -1, diskfree INTEGER DEFAULT -1, uname TEXT DEFAULT 'n/a', rundir TEXT DEFAULT 'n/a', item_path TEXT DEFAULT '', state TEXT DEFAULT 'NOT_STARTED', - status TEXT DEFAULT 'n/a', + status TEXT DEFAULT 'FAIL', attemptnum INTEGER DEFAULT 0, final_logf TEXT DEFAULT 'logs/final.log', logdat BLOB, run_duration INTEGER DEFAULT 0, comment TEXT DEFAULT '', event_time TIMESTAMP, + fail_count INTEGER DEFAULT 0, + pass_count INTEGER DEFAULT 0, CONSTRAINT testsconstraint UNIQUE (run_id, testname, item_path) );") (sqlite3:execute db "CREATE INDEX tests_index ON tests (run_id, testname);") (sqlite3:execute db "CREATE VIEW runs_tests AS SELECT * FROM runs INNER JOIN tests ON runs.id=tests.run_id;") (sqlite3:execute db "CREATE TABLE test_steps @@ -237,11 +240,20 @@ (sqlite3:execute db "UPDATE tests SET comment=? WHERE run_id=? AND testname=? AND item_path=?;" comment run-id testname item-path)) +;; +(define (db:test-set-rundir! db run-id testname item-path rundir) + (sqlite3:execute + db + "UPDATE tests SET rundir=? WHERE run_id=? AND testname=? AND item_path=?;" + rundir run-id testname item-path)) + +;;====================================================================== ;; Steps +;;====================================================================== ;; Run steps ;; make-vector-record "Run steps" db step id test_id stepname step_complete step_pass event_time (define (make-db:step)(make-vector 6)) (define-inline (db:step-get-id vec) (vector-ref vec 0)) (define-inline (db:step-get-test_id vec) (vector-ref vec 1)) Index: docs/megatest.html ================================================================== --- docs/megatest.html +++ docs/megatest.html @@ -2,17 +2,16 @@ - + Megatest
-

Megatest

5/5/2011 @@ -19,54 +18,51 @@

Matt Welland

-

Abstract -

Megatest is a minimalistic tool to help automate and manage the running of a suite of regression tests or other processes and to roll up the results for display on a web page or dashboard. +

+Megatest is a minimalistic tool to help automate and manage the running of a suite of regression tests or other processes and to roll up the results for display on a web page or dashboard.
-
-
- +
+ - +
+
Section 0.3: Reference -
- -
-Subsection 0.3.1: Environment variables -
-
-Subsection 0.3.2: Configuration files -
- - -
- -
-Subsection 0.3.3: Writing tests -
- -
-
- - - - + +
+
+Subsection 0.3.1: Configuration files +
+
+ + + + + +
+
+Subsection 0.3.2: Environment variables +
+
+Subsection 0.3.3: Configuration files +
+
+ + +
+
+Subsection 0.3.4: Writing tests +
+
+ +
+
+Subsection 0.3.5: Command line +
+
+ + +

0.1 About Megatest

@@ -283,126 +302,186 @@

0.3 Reference

-0.3.1 Environment variables +0.3.1 Configuration files +

+

+0.3.1.1 Sections +

+
+[section name] +
+
+This creates a section named “section name” +
+

+0.3.1.2 Variables +

+
+VARX has this value +
+
+The variable “VARX” will have the value “has this value” +
+

+0.3.1.3 Includes +

+
+[include filename] +
+
+The file named “filename” will be included as if part of the calling file. NOTE: This means no section can be named “include “ (with the whitespace). +
+

+0.3.1.4 Setting a variable by running a command +

+
+VARNAME [system ls /tmp] +
+
+The variable “VARNAME” will get a value created by the Unix command “ls /tmp”. All lines of output from the command will be joined with a space. +
+

+0.3.1.5 Notes +

+ +

+0.3.2 Environment variables

- - - + - + - + - + - + - + - + + + + + + + + +
Variable Purpose Default value/Comment
MT_CMDINFO Conveys test variables to the megatest test runner. Not for use by the end user
MT_TEST_RUN_DIR Directory assigned by megatest for the test to run. Tests can consider this their “home” directory
MT_TEST_NAME Name of the test, corrosponds to the directory name under tests.
MT_ITEM_INFO Iterated tests will set this to a sequence of key/values ((KEY val) ...)
MT_RUN_AREA_HOME Directory where megatest was launched from and where the tests code can be found
MT_RUNNAME Name of this run as set by the :runname parameter
+MT_MEGATEST + +Path/Filename to megatest executable. Found either from called path or but using the “exectuable” keyword in the [setup] section. + +
<field1> .... The field values as set on the megatest -runall command line (e.g. :field1 abc) Planning ahead your field names is important so as to avoid collisions with other environment variables
+

-0.3.2 Configuration files +0.3.3 Configuration files

-0.3.2.1 megatest.config +0.3.3.1 megatest.config

- - - + - + - + - + - + - + - + - + - + +
section variable @@ -414,13 +493,13 @@ required comment
[setup] max_concurrent_jobs @@ -432,13 +511,13 @@ no
executable @@ -450,13 +529,13 @@ no Use only if necessary, megatest will extract the location from where it used to launch and add append that to the PATH for test runs.
runsdir @@ -468,13 +547,13 @@ no Because your runs may be spread out over several disk partitions a central link tree is created to make finding all the runs easy.
[fields] string of letters, numbers and underscore @@ -486,13 +565,13 @@ at least one
[jobtools] launcher @@ -504,13 +583,13 @@ no
workhosts @@ -522,13 +601,13 @@ n/a
[env-override] string of letters, numbers and underscore @@ -540,13 +619,13 @@ no These are set on the test launching machine, not the test running machine. Typical usage is to control the host or run queue for launching tests. These values will not be seen by the test when it runs.
[disks] string of letters, numbers and underscore @@ -558,22 +637,22 @@ yes The disk usage balancing algorithm is to choose the disk with the least space for each test run.
+

-0.3.2.2 runconfigs.config file +0.3.3.2 runconfigs.config file

- - - + - + - + +
section variable @@ -585,13 +664,13 @@ required? comment
[default] string of letters, numbers and underscore @@ -603,13 +682,13 @@ no variables set in this section will be available for all runs, defining the same variable in another section will override the value from the default section
[field1value/field2value...] string of letters, numbers and underscore @@ -621,12 +700,15 @@ no the values in this section will be set for any run where field1 is field1value, field2 is field2value and fieldN is fieldNvalue.
+
Example: a test suite that checks that a piece of software works correctly for different customer configurations and locations each of which is done as a separate release regression run. The fields, CUSTOMER and LOCATION were chosen. The following runconfigs.config file would set some variables specific to runs for megacorp in India and femtocorp in the Cook Islands and New Zealand:
@@ -635,65 +717,74 @@
[default]
ENCRYTION true +
+
+#
[megacorp/india]
TESTPATH /nfs/testing/megacorp_runs +
+
+#
[femtocorp/cook_islands]
ENCRYTION false
TESTPATH /afs/kiatoa/testing/cook_islands +
+
+#
[femtocorp/new_zealand]
TESTPATH /afs/kiatao/testing/new_zealand +
+
+#
[megacorp/new_zealand]
TESTPATH /nfs/testing/megacorp_runs
-Running megatest like this: +Running megatest like this:
megatest :CUSTOMER megacorp :LOCATION new_zealand :runname week12_2011_run1 -runall
-Would set: +Would set:
ENCRYPTION true
TESTPATH /nfs/testing/megacorp_runs

-0.3.3 Writing tests +0.3.4 Writing tests

-0.3.3.1 testconfig file +0.3.4.1 testconfig file

- - - + - + - + - + + + +
section variable @@ -705,13 +796,13 @@ required? comments
[setup] runscript @@ -723,13 +814,13 @@ yes The script must be executable and either provide the full path or put a copy at the top of your test directory
[requirements] waiton @@ -741,13 +832,13 @@ no This test will not run until the named tests are state completed and status PASS
[items] any valid @@ -759,14 +850,358 @@ no The test will be repeated once for each item with the variable name set to the value. If there is more than one variable then the test will be run against all unique combinations of the values
+ +
+

+0.3.5 Command line +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+switch or param + +parameter + +purpose + +comments +
+-h + + + +brief help + + +
+-runall + + + +run all tests + + +
+-runtests + +test1,test2,... + +run one or more tests + + +
+-step + +stepname + +record a step + +requires :state and :status +
+-test-status + + + +record the test status + +requires :state and :status +
+-setlog + +logfilename + +set the logfile name for a test + +path is assumed to be relative to the test run directory +
+-set-toplog + +logfilename + +set the logfile name for the top test in an iterated test run + +each sub test can have its own logfile set +
+-m + +“comment” + +sets a comment for the step, test or run + + +
+:runname + + + + + + +
+:state + + + + + + +
+:status + + + + + + +
+-list-runs + + + + + + +
+-testpatt + + + + + + +
+-itempatt + + + + + + +
+-showkeys + + + + + + +
+-force + + + + + + +
+-xterm + + + + + + +
+-remove-runs + + + + + + +
+Test helpers + + + + + + +
+-runstep + + + + + + +
+-logpro + + + + + + +
+
-
-

Copyright (C) 2011 Matt Welland

+ +
Index: docs/megatest.lyx ================================================================== --- docs/megatest.lyx +++ docs/megatest.lyx @@ -1,45 +1,63 @@ -#LyX 1.6.5 created this file. For more info see http://www.lyx.org/ -\lyxformat 345 +#LyX 2.0 created this file. For more info see http://www.lyx.org/ +\lyxformat 413 \begin_document \begin_header \textclass docbook-book \use_default_options false +\maintain_unincluded_children false \language english +\language_package default \inputencoding auto +\fontencoding global \font_roman default \font_sans default \font_typewriter default \font_default_family default +\use_non_tex_fonts false \font_sc false \font_osf false \font_sf_scale 100 \font_tt_scale 100 \graphics default +\default_output_format default +\output_sync 0 +\bibtex_command default +\index_command default \paperfontsize default \spacing single \use_hyperref false \papersize default \use_geometry false \use_amsmath 0 \use_esint 0 +\use_mhchem 1 +\use_mathdots 1 \cite_engine basic \use_bibtopic false +\use_indices false \paperorientation portrait +\suppress_date false +\use_refstyle 0 +\index Index +\shortcut idx +\color #008000 +\end_index \secnumdepth 3 \tocdepth 3 \paragraph_separation indent -\defskip medskip +\paragraph_indentation default \quotes_language english \papercolumns 1 \papersides 1 \paperpagestyle default \tracking_changes false \output_changes false -\author "" -\author "" +\html_math_output 0 +\html_css_as_file 0 +\html_be_strict false \end_header \begin_body \begin_layout Title @@ -331,19 +349,142 @@ \end_layout \begin_layout Section Reference \end_layout + +\begin_layout Subsection +Configuration files +\end_layout + +\begin_layout Subsubsection +Sections +\end_layout + +\begin_layout Standard +[section name] +\end_layout + +\begin_layout Standard +This creates a section named +\begin_inset Quotes eld +\end_inset + +section name +\begin_inset Quotes erd +\end_inset + + +\end_layout + +\begin_layout Subsubsection +Variables +\end_layout + +\begin_layout Standard +VARX has this value +\end_layout + +\begin_layout Standard +The variable +\begin_inset Quotes eld +\end_inset + +VARX +\begin_inset Quotes erd +\end_inset + + will have the value +\begin_inset Quotes eld +\end_inset + +has this value +\begin_inset Quotes erd +\end_inset + + +\end_layout + +\begin_layout Subsubsection +Includes +\end_layout + +\begin_layout Standard +[include filename] +\end_layout + +\begin_layout Standard +The file named +\begin_inset Quotes eld +\end_inset + +filename +\begin_inset Quotes erd +\end_inset + + will be included as if part of the calling file. + NOTE: This means no section can be named +\begin_inset Quotes eld +\end_inset + +include +\begin_inset Quotes eld +\end_inset + + (with the whitespace). +\end_layout + +\begin_layout Subsubsection +Setting a variable by running a command +\end_layout + +\begin_layout Standard +VARNAME [system ls /tmp] +\end_layout + +\begin_layout Standard +The variable +\begin_inset Quotes eld +\end_inset + +VARNAME +\begin_inset Quotes erd +\end_inset + + will get a value created by the Unix command +\begin_inset Quotes eld +\end_inset + +ls /tmp +\begin_inset Quotes erd +\end_inset + +. + All lines of output from the command will be joined with a space. +\end_layout + +\begin_layout Subsubsection +Notes +\end_layout + +\begin_layout Itemize +Some variables are infered as lists. + Each token on the line separated by whitespace will be member of the list. +\end_layout + +\begin_layout Itemize +Comments (lines starting with #) and blank lines are ignored. +\end_layout \begin_layout Subsection Environment variables \end_layout \begin_layout Standard \begin_inset Tabular - - + + @@ -558,10 +699,48 @@ \begin_inset Text + +\begin_layout Plain Layout +MT_MEGATEST +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Path/Filename to megatest executable. + Found either from called path or but using the +\begin_inset Quotes eld +\end_inset + +exectuable +\begin_inset Quotes erd +\end_inset + + keyword in the [setup] section. +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + + + +\begin_inset Text \begin_layout Plain Layout .... \end_layout @@ -604,11 +783,11 @@ \end_layout \begin_layout Standard \begin_inset Tabular - + @@ -1054,11 +1233,11 @@ \end_layout \begin_layout Standard \begin_inset Tabular - + @@ -1232,18 +1411,26 @@ \end_layout \begin_layout Code ENCRYTION true \end_layout + +\begin_layout Code +# +\end_layout \begin_layout Code [megacorp/india] \end_layout \begin_layout Code TESTPATH /nfs/testing/megacorp_runs \end_layout + +\begin_layout Code +# +\end_layout \begin_layout Code [femtocorp/cook_islands] \end_layout @@ -1252,18 +1439,26 @@ \end_layout \begin_layout Code TESTPATH /afs/kiatoa/testing/cook_islands \end_layout + +\begin_layout Code +# +\end_layout \begin_layout Code [femtocorp/new_zealand] \end_layout \begin_layout Code TESTPATH /afs/kiatao/testing/new_zealand \end_layout + +\begin_layout Code +# +\end_layout \begin_layout Code [megacorp/new_zealand] \end_layout @@ -1301,11 +1496,11 @@ \end_layout \begin_layout Standard \begin_inset Tabular - + @@ -1495,10 +1690,874 @@ \begin_layout Plain Layout The test will be repeated once for each item with the variable name set to the value. If there is more than one variable then the test will be run against all unique combinations of the values +\end_layout + +\end_inset + + + + +\end_inset + + +\end_layout + +\begin_layout Subsection +Command line +\end_layout + +\begin_layout Standard +\begin_inset Tabular + + + + + + + + +\begin_inset Text + +\begin_layout Plain Layout +switch or param +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +parameter +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +purpose +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +comments +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +-h +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +brief help +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +-runall +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +run all tests +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +-runtests +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +test1,test2,... +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +run one or more tests +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +-step +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +stepname +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +record a step +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +requires :state and :status +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +-test-status +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +record the test status +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +requires :state and :status +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +-setlog +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +logfilename +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +set the logfile name for a test +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +path is assumed to be relative to the test run directory +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +-set-toplog +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +logfilename +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +set the logfile name for the top test in an iterated test run +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +each sub test can have its own logfile set +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +-m +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Quotes eld +\end_inset + +comment +\begin_inset Quotes erd +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +sets a comment for the step, test or run +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +:runname +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +:state +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +:status +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +-list-runs +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +-testpatt +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +-itempatt +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +-showkeys +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +-force +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +-xterm +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +-remove-runs +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout + +\shape italic +Test helpers +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +-runstep +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +-logpro +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + \end_layout \end_inset Index: launch.scm ================================================================== --- launch.scm +++ launch.scm @@ -79,13 +79,18 @@ "runname")) (key-vals (get-key-vals db run-id)) (key-str (string-intersperse key-vals "/")) (dfullp (conc disk-path "/" key-str "/" runname "/" testname item-path)) + (toptest-path (conc disk-path "/" key-str "/" runname "/" testname)) (runsdir (config-lookup *configdat* "setup" "runsdir")) (lnkpath (conc (if runsdir runsdir (conc *toppath* "/runs")) "/" key-str "/" runname item-path))) + ;; since this is an iterated test this is as good a place as any to + ;; update the toptest record with its location rundir + (if (not (equal? item-path "")) + (db:test-set-rundir! db run-id testname "" toptest-path)) (print "Setting up test run area") (print " - creating run area in " dfullp) (system (conc "mkdir -p " dfullp)) (print " - creating link from " dfullp "/" testname " to " lnkpath) (system (conc "mkdir -p " lnkpath)) @@ -93,12 +98,12 @@ (system (conc "rm -f " lnkpath "/" testname))) (system (conc "ln -sf " dfullp " " lnkpath "/" testname)) (if (directory? dfullp) (begin (system (conc "rsync -av " test-path "/ " dfullp "/")) - dfullp) - #f))) + (list dfullp toptest-path)) + (list #f #f)))) ;; 1. look though disks list for disk with most space ;; 2. create run dir on disk, path name is meaningful ;; 3. create link from run dir to megatest runs area ;; 4. remotely run the test on allocated host @@ -113,10 +118,11 @@ (hosts (config-lookup *configdat* "jobtools" "workhosts")) (remote-megatest (config-lookup *configdat* "setup" "executable")) (local-megatest (car (argv))) ;; (item-path (item-list->path itemdat)) test-path is the full path including the item-path (work-area #f) + (toptest-work-area #f) ;; for iterated tests the top test contains data relevant for all (diskpath #f) (cmdparms #f) (fullcmd #f) ;; (define a (with-output-to-string (lambda ()(write x)))) (mt-bindir-path #f)) (if hosts (set! hosts (string-split hosts))) @@ -124,11 +130,13 @@ (set! mt-bindir-path (pathname-directory remote-megatest)) (if launcher (set! launcher (string-split launcher))) ;; set up the run work area for this test (set! diskpath (get-best-disk *configdat*)) (if diskpath - (set! work-area (create-work-area db run-id test-path diskpath test-name itemdat)) + (let ((dat (create-work-area db run-id test-path diskpath test-name itemdat))) + (set! work-area (car dat)) + (set! toptest-work-area (cadr dat))) (begin (set! work-area test-path) (print "WARNING: No disk work area specified - running in the test directory"))) (set! cmdparms (base64:base64-encode (with-output-to-string (lambda () ;; (list 'hosts hosts) @@ -135,11 +143,12 @@ (write (list (list 'testpath test-path) (list 'work-area work-area) (list 'test-name test-name) (list 'runscript runscript) (list 'run-id run-id ) - (list 'itemdat itemdat) + (list 'itemdat itemdat ) + (list 'megatest remote-megatest) (list 'runname (args:get-arg ":runname")) (list 'mt-bindir-path mt-bindir-path))))))) ;; (string-intersperse keyvallst " ")))) (change-directory work-area) ;; so that log files from the launch process don't clutter the test dir (cond ((and launcher hosts) ;; must be using ssh hostname Index: megatest.scm ================================================================== --- megatest.scm +++ megatest.scm @@ -6,11 +6,11 @@ ;; This program is distributed WITHOUT ANY WARRANTY; without even the ;; implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ;; PURPOSE. (include "common.scm") -(define megatest-version 1.04) +(define megatest-version 1.06) (define help (conc " Megatest, documentation at http://www.kiatoa.com/fossils/megatest version " megatest-version " license GPL, Copyright Matt Welland 2006-2011 @@ -28,10 +28,11 @@ \"megatest.sh\" file.) -step stepname -test-status : set the state and status of a test (use :state and :status) -setlog logfname : set the path/filename to the final log relative to the test directory. may be used with -test-status + -set-toplog logfname : set the overall log for a suite of sub-tests -m comment : insert a comment for this test Run data :runname : required, name for this particular test run :state : required if updating step state; e.g. start, end, completed @@ -76,10 +77,11 @@ ":status" "-list-runs" "-testpatt" "-itempatt" "-setlog" + "-set-toplog" "-runstep" "-logpro" "-m" ) (list "-h" @@ -318,20 +320,23 @@ (runscript (assoc/default 'runscript cmdinfo)) (db-host (assoc/default 'db-host cmdinfo)) (run-id (assoc/default 'run-id cmdinfo)) (itemdat (assoc/default 'itemdat cmdinfo)) (runname (assoc/default 'runname cmdinfo)) + (megatest (assoc/default 'megatest cmdinfo)) (mt-bindir-path (assoc/default 'mt-bindir-path cmdinfo)) (fullrunscript (conc testpath "/" runscript)) (db #f)) (print "Exectuing " test-name " on " (get-host-name)) (change-directory testpath) (setenv "MT_TEST_RUN_DIR" work-area) (setenv "MT_TEST_NAME" test-name) (setenv "MT_ITEM_INFO" (conc itemdat)) (setenv "MT_RUNNAME" runname) + (setenv "MT_MEGATEST" megatest) (setenv "PATH" (conc (getenv "PATH") ":" mt-bindir-path)) + (if (not (setup-for-run)) (begin (print "Failed to setup, exiting") (exit 1))) ;; now can find our db @@ -445,10 +450,11 @@ (exit 6))) (sqlite3:finalize! db) (set! *didsomething* #t)))) (if (or (args:get-arg "-setlog") ;; since setting up is so costly lets piggyback on -test-status + (args:get-arg "-set-toplog") (args:get-arg "-test-status") (args:get-arg "-runstep")) (if (not (getenv "MT_CMDINFO")) (begin (print "ERROR: MT_CMDINFO env var not set, commands -test-status, -runstep and -setlog must be called *inside* a megatest environment!") @@ -470,10 +476,12 @@ (print "Failed to setup, exiting") (exit 1))) (set! db (open-db)) (if (args:get-arg "-setlog") (test-set-log! db run-id test-name itemdat (args:get-arg "-setlog"))) + (if (args:get-arg "-set-toplog") + (test-set-toplog! db run-id test-name (args:get-arg "-set-toplog"))) (if (args:get-arg "-test-status") (test-set-status! db run-id test-name state status itemdat (args:get-arg "-m")) (if (and state status) (if (not (args:get-arg "-setlog")) (begin Index: runs.scm ================================================================== --- runs.scm +++ runs.scm @@ -74,25 +74,56 @@ (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)) + (let ((item-paths (if (equal? item-path "") + (list item-path) + (list item-path "")))) + (for-each + (lambda (pth) + (sqlite3:execute db "INSERT OR IGNORE INTO tests (run_id,testname,event_time,item_path) VALUES (?,?,strftime('%s','now'),?);" run-id test-name pth)) + item-paths))) + +;; (define db (open-db)) +;; (test-set-status! db 2 "runfirst" "COMPLETED" "PASS" "summer") (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) + (if (and (not (equal? item-path "")) ;; need to update the top test record if PASS or FAIL and this is a subtest + (or (equal? status "PASS") + (equal? status "FAIL"))) + (begin + (sqlite3:execute + db + "UPDATE tests + SET fail_count=(SELECT count(id) FROM tests WHERE run_id=? AND testname=? AND item_path != '' AND status='FAIL'), + pass_count=(SELECT count(id) FROM tests WHERE run_id=? AND testname=? AND item_path != '' AND status='PASS') + WHERE run_id=? AND testname=? AND item_path='';" + run-id test-name run-id test-name run-id test-name) + (sqlite3:execute + db + "UPDATE tests + SET state='COMPLETED', + status=CASE WHEN fail_count > 0 THEN 'FAIL' WHEN pass_count > 0 AND fail_count=0 THEN 'PASS' ELSE 'UNKNOWN' END + WHERE run_id=? AND testname=? AND item_path='';" + run-id test-name))) (if (and (not (null? comment)) (car comment)) (sqlite3:execute db "UPDATE tests SET comment=? WHERE run_id=? AND testname=? AND item_path=?;" (car comment) run-id test-name item-path)))) (define (test-set-log! db run-id test-name itemdat logf) (let ((item-path (item-list->path itemdat))) (sqlite3:execute db "UPDATE tests SET final_logf=? WHERE run_id=? AND testname=? AND item_path=?;" logf run-id test-name item-path))) + +(define (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)) ;; ;; TODO: Converge this with db:get-test-info ;; (define (runs:get-test-info db run-id test-name item-path) ;; (let ((res #f)) ;; (vector #f #f #f #f #f #f))) ;; (sqlite3:for-each-row Index: tests/tests/runfirst/main.sh ================================================================== --- tests/tests/runfirst/main.sh +++ tests/tests/runfirst/main.sh @@ -2,8 +2,8 @@ # megatest -step wasting_time :state start :status n/a -m "This is a test step comment" # sleep 20 # megatest -step wasting_time :state end :status $? -megatest -runstep wasting_time -logpro wasting_time.logpro "sleep 20;echo all done eh?" -m "This is a test step comment" +$MT_MEGATEST -runstep wasting_time -logpro wasting_time.logpro "sleep 20;echo all done eh?" -m "This is a test step comment" -megatest -test-status :state COMPLETED :status PASS -m "This is a test level comment" +$MT_MEGATEST -test-status :state COMPLETED :status PASS -m "This is a test level comment" -set-toplog the_top_log.html Index: tests/tests/sqlitespeed/testconfig ================================================================== --- tests/tests/sqlitespeed/testconfig +++ tests/tests/sqlitespeed/testconfig @@ -3,6 +3,9 @@ [requirements] waiton runfirst [items] -MANYITEMS a b c d e f g h i j k l m +MANYITEMS [system ls] +# a b c d e f g h i j k l m +# LSJUNK [system ls] +