ADDED docs/Makefile Index: docs/Makefile ================================================================== --- /dev/null +++ docs/Makefile @@ -0,0 +1,5 @@ + +megatest.html : megatest.lyx + lyx -e html megatest.lyx + cp megatest.html.LyXconv/megatest.html megatest.html + ADDED docs/megatest.html Index: docs/megatest.html ================================================================== --- /dev/null +++ docs/megatest.html @@ -0,0 +1,381 @@ + + + + + + + + +Megatest + + +
+ +

+Megatest +

+

+5/5/2011 +

+

+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. +
+
+ + +
+

+0.1 About Megatest +

+

+0.1.1 Megatest design philosophy +

+
+Megatest is intended to provide the minimum needed resources to make writing a suite of tests for software, design engineering or process control (via owlfs for example) without being specialized for any specific problem space. Megatest in of itself does not know what constitutes a PASS or FAIL of a test. In most cases megatest is best used in conjunction with logpro or a similar tool to parse, analyze and decide on the test outcome. A call to megatest can then be made to record the result. +
+

+0.1.2 Megatest architecture +

+
+All data to specify the tests and configure the system is stored in plain text files. All system state is stored in an sqlite3 database. Tests are launched using the launching system available for the distributed compute platform in use. A template script is provided which can launch jobs on local and remote Linux hosts. Currently megatest uses the network filesystem to “call home” to your master sqlite3 database. +
+

+0.2 Installation +

+

+0.2.1 Compilation +

+

+0.2.1.1 Dependencies +

+
+Chicken scheme and a number of eggs are required for building megatest. See the file utils/installall.sh for an automated way to install the dependancies on Linux. +
+

+0.2.1.2 Build and install +

+
+Run “make test” to create the megatest exectutable. You may wish to copy the executable to a centrally accessible location. +
+

+0.2.2 Setup +

+

+0.2.2.1 Create megatest.config +

+
+Create the file megatest.config using the megatest.config template from the tests directory. At a minimum you need the following: +
+
+# Fields are the keys under which your test runs are organised +
+
+[fields] +
+
+field1 TEXT +
+
+field2 TEXT +
+
+ +
+
+[jobtools] +
+
+# The launcher launches jobs to the local or remote hosts, +
+
+# the job is managed on the target host by megatest, +
+
+# comment out launcher to run local only. An example launcher +
+
+# "nbfake" can be found in the utils directory. +
+
+launcher nbfake +
+
+ +
+
+# The disks section specifies where the tests will be run. As you +
+
+# run out of space in a partition you can add additional disks +
+
+# entries. +
+
+# Format is: +
+
+# name /path/to/area +
+
+[disks] +
+
+1 /tmp +
+

+0.2.2.2 Create runconfigs.config +

+
+This file is used to set environment variables that are run specific. You can simply create an empty file to start. +
+

+0.2.2.3 Create the tests directory and your first test +

+
+The structure should look like this: +
+
+../tests +
+
+├── megatest.config +
+
+├── runconfigs.config +
+
+└── tests +
+
+    └── mytest +
+
+ ├── main.sh +
+
+    └── testconfig +
+

+0.2.2.4 Create the testconfig file for your test +

+
+[setup] +
+
+runscript main.sh +
+

+0.2.2.5 Create your test running script, main.sh +

+
+#!/bin/bash +
+
+ +
+
+megatest -runstep mystep1 "sleep 20;echo Done" -m "mystep1 is done" +
+
+megatest -test-status :state COMPLETED :status PASS -m "This is a test level comment" +
+

+0.2.2.6 Run megatest and watch your run progress +

+
+megatest :field1 abc :field2 def :runname 2011week08.4a -runall +
+
+watch megatest -list-runs % +
+

+0.3 Reference +

+

+0.3.1 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 + + +
+<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 +
+
+
+ +
+ +
+

Copyright (C) 2011 Matt Welland

+
+ + ADDED docs/megatest.lyx Index: docs/megatest.lyx ================================================================== --- /dev/null +++ docs/megatest.lyx @@ -0,0 +1,602 @@ +#LyX 1.6.5 created this file. For more info see http://www.lyx.org/ +\lyxformat 345 +\begin_document +\begin_header +\textclass docbook +\use_default_options false +\language english +\inputencoding auto +\font_roman default +\font_sans default +\font_typewriter default +\font_default_family default +\font_sc false +\font_osf false +\font_sf_scale 100 +\font_tt_scale 100 + +\graphics default +\paperfontsize default +\use_hyperref false +\papersize default +\use_geometry false +\use_amsmath 0 +\use_esint 0 +\cite_engine basic +\use_bibtopic false +\paperorientation portrait +\secnumdepth 3 +\tocdepth 3 +\paragraph_separation indent +\defskip medskip +\quotes_language english +\papercolumns 1 +\papersides 1 +\paperpagestyle default +\tracking_changes false +\output_changes false +\author "" +\author "" +\end_header + +\begin_body + +\begin_layout Title +Megatest +\end_layout + +\begin_layout Date +5/5/2011 +\end_layout + +\begin_layout Author +Matt Welland +\end_layout + +\begin_layout 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. +\end_layout + +\begin_layout Standard +\begin_inset CommandInset toc +LatexCommand tableofcontents + +\end_inset + + +\end_layout + +\begin_layout Section +About Megatest +\end_layout + +\begin_layout Subsection +Megatest design philosophy +\end_layout + +\begin_layout Standard +Megatest is intended to provide the minimum needed resources to make writing + a suite of tests for software, design engineering or process control (via + owlfs for example) without being specialized for any specific problem space. + Megatest in of itself does not know what constitutes a PASS or FAIL of + a test. + In most cases megatest is best used in conjunction with logpro or a similar + tool to parse, analyze and decide on the test outcome. + A call to megatest can then be made to record the result. + +\end_layout + +\begin_layout Subsection +Megatest architecture +\end_layout + +\begin_layout Standard +All data to specify the tests and configure the system is stored in plain + text files. + All system state is stored in an sqlite3 database. + Tests are launched using the launching system available for the distributed + compute platform in use. + A template script is provided which can launch jobs on local and remote + Linux hosts. + Currently megatest uses the network filesystem to +\begin_inset Quotes eld +\end_inset + +call home +\begin_inset Quotes erd +\end_inset + + to your master sqlite3 database. +\end_layout + +\begin_layout Section +Installation +\end_layout + +\begin_layout Subsection +Compilation +\end_layout + +\begin_layout Subsubsection +Dependencies +\end_layout + +\begin_layout Standard +Chicken scheme and a number of eggs are required for building megatest. + See the file utils/installall.sh for an automated way to install the dependancie +s on Linux. +\end_layout + +\begin_layout Subsubsection +Build and install +\end_layout + +\begin_layout Standard +Run +\begin_inset Quotes eld +\end_inset + +make test +\begin_inset Quotes erd +\end_inset + + to create the megatest exectutable. + You may wish to copy the executable to a centrally accessible location. +\end_layout + +\begin_layout Subsection +Setup +\end_layout + +\begin_layout Subsubsection +Create megatest.config +\end_layout + +\begin_layout Standard +Create the file megatest.config using the megatest.config template from the + tests directory. + At a minimum you need the following: +\end_layout + +\begin_layout Code +# Fields are the keys under which your test runs are organised +\end_layout + +\begin_layout Code +[fields] +\end_layout + +\begin_layout Code +field1 TEXT +\end_layout + +\begin_layout Code +field2 TEXT +\end_layout + +\begin_layout Code + +\end_layout + +\begin_layout Code +[jobtools] +\end_layout + +\begin_layout Code +# The launcher launches jobs to the local or remote hosts, +\end_layout + +\begin_layout Code +# the job is managed on the target host by megatest, +\end_layout + +\begin_layout Code +# comment out launcher to run local only. + An example launcher +\end_layout + +\begin_layout Code +# "nbfake" can be found in the utils directory. + +\end_layout + +\begin_layout Code +launcher nbfake +\end_layout + +\begin_layout Code + +\end_layout + +\begin_layout Code +# The disks section specifies where the tests will be run. + As you +\end_layout + +\begin_layout Code +# run out of space in a partition you can add additional disks +\end_layout + +\begin_layout Code +# entries. +\end_layout + +\begin_layout Code +# Format is: +\end_layout + +\begin_layout Code +# name /path/to/area +\end_layout + +\begin_layout Code +[disks] +\end_layout + +\begin_layout Code +1 /tmp +\end_layout + +\begin_layout Subsubsection +Create runconfigs.config +\end_layout + +\begin_layout Standard +This file is used to set environment variables that are run specific. + You can simply create an empty file to start. +\end_layout + +\begin_layout Subsubsection +Create the tests directory and your first test +\end_layout + +\begin_layout Standard +The structure should look like this: +\end_layout + +\begin_layout Code +../tests +\end_layout + +\begin_layout Code +├── megatest.config +\end_layout + +\begin_layout Code +├── runconfigs.config +\end_layout + +\begin_layout Code +└── tests +\end_layout + +\begin_layout Code +    └── mytest +\end_layout + +\begin_layout Code + ├── main.sh +\end_layout + +\begin_layout Code +    └── testconfig +\end_layout + +\begin_layout Subsubsection +Create the testconfig file for your test +\end_layout + +\begin_layout Code +[setup] +\end_layout + +\begin_layout Code +runscript main.sh +\end_layout + +\begin_layout Subsubsection +Create your test running script, main.sh +\end_layout + +\begin_layout Code +#!/bin/bash +\end_layout + +\begin_layout Code + +\end_layout + +\begin_layout Code +megatest -runstep mystep1 "sleep 20;echo Done" -m "mystep1 is done" +\end_layout + +\begin_layout Code +megatest -test-status :state COMPLETED :status PASS -m "This is a test level + comment" +\end_layout + +\begin_layout Subsubsection +Run megatest and watch your run progress +\end_layout + +\begin_layout Code +megatest :field1 abc :field2 def :runname 2011week08.4a -runall +\end_layout + +\begin_layout Code +watch megatest -list-runs % +\end_layout + +\begin_layout Section +Reference +\end_layout + +\begin_layout Subsection +Environment variables +\end_layout + +\begin_layout Standard +\begin_inset Tabular + + + + + + + +\begin_inset Text + +\begin_layout Plain Layout +Variable +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Purpose +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Default value/Comment +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +MT_CMDINFO +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Conveys test variables to the megatest test runner. +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Not for use by the end user +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +MT_TEST_RUN_DIR +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Directory assigned by megatest for the test to run. +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Tests can consider this their +\begin_inset Quotes eld +\end_inset + +home +\begin_inset Quotes erd +\end_inset + + directory +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +MT_TEST_NAME +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Name of the test, corrosponds to the directory name under tests. +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +MT_ITEM_INFO +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Iterated tests will set this to a sequence of key/values ((KEY val) ...) +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +MT_RUN_AREA_HOME +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Directory where megatest was launched from and where the tests code can + be found +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +MT_RUNNAME +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Name of this run as set by the :runname parameter +\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 +The field values as set on the megatest -runall command line (e.g. + :field1 abc) +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Planning ahead your field names is important so as to avoid collisions with + other environment variables +\end_layout + +\end_inset + + + + +\end_inset + + +\end_layout + +\begin_layout Code + +\end_layout + +\end_body +\end_document 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.02) +(define megatest-version 1.03) (define help (conc " Megatest, documentation at http://www.kiatoa.com/fossils/megatest version " megatest-version " license GPL, Copyright Matt Welland 2006-2011 @@ -309,16 +309,20 @@ (test-name (assoc/default 'test-name cmdinfo)) (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)) (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" testpath) + (setenv "MT_TEST_NAME" test-name) + (setenv "MT_ITEM_INFO" (conc itemdat)) + (setenv "MT_RUNNAME" runname) (setenv "PATH" (conc (getenv "PATH") ":" mt-bindir-path)) (if (not (setup-for-run)) (begin (print "Failed to setup, exiting") (exit 1))) @@ -504,11 +508,11 @@ (cmd (string-intersperse (list "logpro" logprofile htmllogfile "<" logfile ">" (conc stepname "_logpro.log")) " "))) (print "INFO: running \"" cmd "\"") (change-directory startingdir) (set! exitstat (system cmd)) (change-directory testpath) - (test-set-log! db run-id test-name itemdat logfile))) + (test-set-log! db run-id test-name itemdat htmllogfile))) (test-set-status! db run-id test-name "end" exitstat itemdat (args:get-arg "-m")) (sqlite3:finalize! db) (exit exitstat) ;; open the db ;; mark the end of the test Index: tests/tests/runfirst/main.sh ================================================================== --- tests/tests/runfirst/main.sh +++ tests/tests/runfirst/main.sh @@ -4,6 +4,6 @@ # 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" -megatest -test-status :state COMPLETED :status PASS -setlog thelogfile.log -m "This is a test level comment" +megatest -test-status :state COMPLETED :status PASS -m "This is a test level comment"