<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="generator" content="http://www.nongnu.org/elyxer/"/>
<meta name="create-date" content="2011-05-08"/>
<link rel="stylesheet" href="http://www.nongnu.org/elyxer/lyx.css" type="text/css" media="screen"/>
<title>Megatest</title>
</head>
<body>
<div id="globalWrapper">
<h1 class="title">
Megatest
</h1>
<h2 class="Date">
5/5/2011
</h2>
<h2 class="author">
Matt Welland
</h2>
<div class="abstract">
<p class="abstract-message">
Abstract
</p>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.
</div>
<div class="Unindented">
<div class="fulltoc">
<div class="tocheader">
Table of Contents
</div><div class="tocindent">
<div class="tocindent">
<div class="toc">
<a class="Link" href="#toc-Section-0.1">Section 0.1: About Megatest</a>
</div><div class="tocindent">
<div class="toc">
<a class="Link" href="#toc-Subsection-0.1.1">Subsection 0.1.1: Megatest design philosophy</a>
</div>
<div class="toc">
<a class="Link" href="#toc-Subsection-0.1.2">Subsection 0.1.2: Megatest architecture</a>
</div></div>
<div class="toc">
<a class="Link" href="#toc-Section-0.2">Section 0.2: Installation</a>
</div><div class="tocindent">
<div class="toc">
<a class="Link" href="#toc-Subsection-0.2.1">Subsection 0.2.1: Compilation</a>
</div><div class="tocindent">
<div class="toc">
<a class="Link" href="#toc-Subsubsection-0.2.1.1">Subsubsection 0.2.1.1: Dependencies</a>
</div>
<div class="toc">
<a class="Link" href="#toc-Subsubsection-0.2.1.2">Subsubsection 0.2.1.2: Build and install</a>
</div></div>
<div class="toc">
<a class="Link" href="#toc-Subsection-0.2.2">Subsection 0.2.2: Setup</a>
</div><div class="tocindent">
<div class="toc">
<a class="Link" href="#toc-Subsubsection-0.2.2.1">Subsubsection 0.2.2.1: Create megatest.config</a>
</div>
<div class="toc">
<a class="Link" href="#toc-Subsubsection-0.2.2.2">Subsubsection 0.2.2.2: Create runconfigs.config</a>
</div>
<div class="toc">
<a class="Link" href="#toc-Subsubsection-0.2.2.3">Subsubsection 0.2.2.3: Create the tests directory and your first test</a>
</div>
<div class="toc">
<a class="Link" href="#toc-Subsubsection-0.2.2.4">Subsubsection 0.2.2.4: Create the testconfig file for your test</a>
</div>
<div class="toc">
<a class="Link" href="#toc-Subsubsection-0.2.2.5">Subsubsection 0.2.2.5: Create your test running script, main.sh</a>
</div>
<div class="toc">
<a class="Link" href="#toc-Subsubsection-0.2.2.6">Subsubsection 0.2.2.6: Run megatest and watch your run progress</a>
</div></div>
</div>
<div class="toc">
<a class="Link" href="#toc-Section-0.3">Section 0.3: Reference</a>
</div><div class="tocindent">
<div class="toc">
<a class="Link" href="#toc-Subsection-0.3.1">Subsection 0.3.1: Environment variables</a>
</div>
<div class="toc">
<a class="Link" href="#toc-Subsection-0.3.2">Subsection 0.3.2: Configuration files</a>
</div><div class="tocindent">
<div class="toc">
<a class="Link" href="#toc-Subsubsection-0.3.2.1">Subsubsection 0.3.2.1: megatest.config</a>
</div>
<div class="toc">
<a class="Link" href="#toc-Subsubsection-0.3.2.2">Subsubsection 0.3.2.2: runconfigs.config file</a>
</div></div>
<div class="toc">
<a class="Link" href="#toc-Subsection-0.3.3">Subsection 0.3.3: Writing tests</a>
</div><div class="tocindent">
<div class="toc">
<a class="Link" href="#toc-Subsubsection-0.3.3.1">Subsubsection 0.3.3.1: testconfig file</a>
</div></div>
</div>
</div>
</div>
</div>
</div>
<h2 class="Section">
<a class="toc" name="toc-Section-0.1">0.1</a> About Megatest
</h2>
<h3 class="Subsection">
<a class="toc" name="toc-Subsection-0.1.1">0.1.1</a> Megatest design philosophy
</h3>
<div class="Unindented">
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.
</div>
<h3 class="Subsection">
<a class="toc" name="toc-Subsection-0.1.2">0.1.2</a> Megatest architecture
</h3>
<div class="Unindented">
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.
</div>
<h2 class="Section">
<a class="toc" name="toc-Section-0.2">0.2</a> Installation
</h2>
<h3 class="Subsection">
<a class="toc" name="toc-Subsection-0.2.1">0.2.1</a> Compilation
</h3>
<h4 class="Subsubsection">
<a class="toc" name="toc-Subsubsection-0.2.1.1">0.2.1.1</a> Dependencies
</h4>
<div class="Unindented">
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 dependencies on Linux.
</div>
<h4 class="Subsubsection">
<a class="toc" name="toc-Subsubsection-0.2.1.2">0.2.1.2</a> Build and install
</h4>
<div class="Unindented">
Run “make test” to create the megatest executable. You may wish to copy the executable to a centrally accessible location.
</div>
<h3 class="Subsection">
<a class="toc" name="toc-Subsection-0.2.2">0.2.2</a> Setup
</h3>
<h4 class="Subsubsection">
<a class="toc" name="toc-Subsubsection-0.2.2.1">0.2.2.1</a> Create megatest.config
</h4>
<div class="Unindented">
Create the file megatest.config using the megatest.config template from the tests directory. At a minimum you need the following:
</div>
<div class="Code">
# Fields are the keys under which your test runs are organized
</div>
<div class="Code">
[fields]
</div>
<div class="Code">
field1 TEXT
</div>
<div class="Code">
field2 TEXT
</div>
<div class="Code">
</div>
<div class="Code">
[jobtools]
</div>
<div class="Code">
# The launcher launches jobs to the local or remote hosts,
</div>
<div class="Code">
# the job is managed on the target host by megatest,
</div>
<div class="Code">
# comment out launcher to run local only. An example launcher
</div>
<div class="Code">
# "nbfake" can be found in the utils directory.
</div>
<div class="Code">
launcher nbfake
</div>
<div class="Code">
</div>
<div class="Code">
# The disks section specifies where the tests will be run. As you
</div>
<div class="Code">
# run out of space in a partition you can add additional disks
</div>
<div class="Code">
# entries.
</div>
<div class="Code">
# Format is:
</div>
<div class="Code">
# name /path/to/area
</div>
<div class="Code">
[disks]
</div>
<div class="Code">
1 /tmp
</div>
<h4 class="Subsubsection">
<a class="toc" name="toc-Subsubsection-0.2.2.2">0.2.2.2</a> Create runconfigs.config
</h4>
<div class="Unindented">
This file is used to set environment variables that are run specific. You can simply create an empty file to start.
</div>
<h4 class="Subsubsection">
<a class="toc" name="toc-Subsubsection-0.2.2.3">0.2.2.3</a> Create the tests directory and your first test
</h4>
<div class="Unindented">
The structure should look like this:
</div>
<div class="Code">
../tests
</div>
<div class="Code">
├── megatest.config
</div>
<div class="Code">
├── runconfigs.config
</div>
<div class="Code">
└── tests
</div>
<div class="Code">
└── mytest
</div>
<div class="Code">
├── main.sh
</div>
<div class="Code">
└── testconfig
</div>
<h4 class="Subsubsection">
<a class="toc" name="toc-Subsubsection-0.2.2.4">0.2.2.4</a> Create the testconfig file for your test
</h4>
<div class="Code">
[setup]
</div>
<div class="Code">
runscript main.sh
</div>
<h4 class="Subsubsection">
<a class="toc" name="toc-Subsubsection-0.2.2.5">0.2.2.5</a> Create your test running script, main.sh
</h4>
<div class="Code">
#!/bin/bash
</div>
<div class="Code">
</div>
<div class="Code">
megatest -runstep mystep1 "sleep 20;echo Done" -m "mystep1 is done"
</div>
<div class="Code">
megatest -test-status :state COMPLETED :status PASS -m "This is a test level comment"
</div>
<h4 class="Subsubsection">
<a class="toc" name="toc-Subsubsection-0.2.2.6">0.2.2.6</a> Run megatest and watch your run progress
</h4>
<div class="Code">
megatest :field1 abc :field2 def :runname 2011week08.4a -runall
</div>
<div class="Code">
watch megatest -list-runs %
</div>
<h2 class="Section">
<a class="toc" name="toc-Section-0.3">0.3</a> Reference
</h2>
<h3 class="Subsection">
<a class="toc" name="toc-Subsection-0.3.1">0.3.1</a> Environment variables
</h3>
<div class="Unindented">
<table>
<tr>
<td align="left" valign="top">
Variable
</td>
<td align="left" valign="top">
Purpose
</td>
<td align="left" valign="top">
Default value/Comment
</td>
</tr>
<tr>
<td align="left" valign="top">
MT_CMDINFO
</td>
<td align="left" valign="top">
Conveys test variables to the megatest test runner.
</td>
<td align="left" valign="top">
Not for use by the end user
</td>
</tr>
<tr>
<td align="left" valign="top">
MT_TEST_RUN_DIR
</td>
<td align="left" valign="top">
Directory assigned by megatest for the test to run.
</td>
<td align="left" valign="top">
Tests can consider this their “home” directory
</td>
</tr>
<tr>
<td align="left" valign="top">
MT_TEST_NAME
</td>
<td align="left" valign="top">
Name of the test, corrosponds to the directory name under tests.
</td>
<td align="left" valign="top">
</td>
</tr>
<tr>
<td align="left" valign="top">
MT_ITEM_INFO
</td>
<td align="left" valign="top">
Iterated tests will set this to a sequence of key/values ((KEY val) ...)
</td>
<td align="left" valign="top">
</td>
</tr>
<tr>
<td align="left" valign="top">
MT_RUN_AREA_HOME
</td>
<td align="left" valign="top">
Directory where megatest was launched from and where the tests code can be found
</td>
<td align="left" valign="top">
</td>
</tr>
<tr>
<td align="left" valign="top">
MT_RUNNAME
</td>
<td align="left" valign="top">
Name of this run as set by the :runname parameter
</td>
<td align="left" valign="top">
</td>
</tr>
<tr>
<td align="left" valign="top">
<field1> ....
</td>
<td align="left" valign="top">
The field values as set on the megatest -runall command line (e.g. :field1 abc)
</td>
<td align="left" valign="top">
Planning ahead your field names is important so as to avoid collisions with other environment variables
</td>
</tr>
</table>
</div>
<h3 class="Subsection">
<a class="toc" name="toc-Subsection-0.3.2">0.3.2</a> Configuration files
</h3>
<h4 class="Subsubsection">
<a class="toc" name="toc-Subsubsection-0.3.2.1">0.3.2.1</a> megatest.config
</h4>
<div class="Unindented">
<table>
<tr>
<td align="left" valign="top">
section
</td>
<td align="left" valign="top">
variable
</td>
<td align="left" valign="top">
value
</td>
<td align="left" valign="top">
required
</td>
<td align="left" valign="top">
comment
</td>
</tr>
<tr>
<td align="left" valign="top">
[setup]
</td>
<td align="left" valign="top">
max_concurrent_jobs
</td>
<td align="left" valign="top">
if variable is not defined no limit on jobs
</td>
<td align="left" valign="top">
no
</td>
<td align="left" valign="top">
</td>
</tr>
<tr>
<td align="left" valign="top">
</td>
<td align="left" valign="top">
executable
</td>
<td align="left" valign="top">
full path to megatest binary
</td>
<td align="left" valign="top">
no
</td>
<td align="left" valign="top">
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.
</td>
</tr>
<tr>
<td align="left" valign="top">
</td>
<td align="left" valign="top">
runsdir
</td>
<td align="left" valign="top">
full path to where the link tree to all runs will be created
</td>
<td align="left" valign="top">
no
</td>
<td align="left" valign="top">
Because your runs may be spread out over several disk partitions a central link tree is created to make finding all the runs easy.
</td>
</tr>
<tr>
<td align="left" valign="top">
[fields]
</td>
<td align="left" valign="top">
string of letters, numbers and underscore
</td>
<td align="left" valign="top">
string of letters, numbers and underscore
</td>
<td align="left" valign="top">
at least one
</td>
<td align="left" valign="top">
</td>
</tr>
<tr>
<td align="left" valign="top">
[jobtools]
</td>
<td align="left" valign="top">
launcher
</td>
<td align="left" valign="top">
command line used to launch jobs - the job command (megatest -execute) will be appended to this
</td>
<td align="left" valign="top">
no
</td>
<td align="left" valign="top">
</td>
</tr>
<tr>
<td align="left" valign="top">
</td>
<td align="left" valign="top">
workhosts
</td>
<td align="left" valign="top">
list of hostnames to run jobs on NOT SUPPORTED RIGHT NOW
</td>
<td align="left" valign="top">
n/a
</td>
<td align="left" valign="top">
</td>
</tr>
<tr>
<td align="left" valign="top">
[env-override]
</td>
<td align="left" valign="top">
string of letters, numbers and underscore
</td>
<td align="left" valign="top">
any string
</td>
<td align="left" valign="top">
no
</td>
<td align="left" valign="top">
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.
</td>
</tr>
<tr>
<td align="left" valign="top">
[disks]
</td>
<td align="left" valign="top">
string of letters, numbers and underscore
</td>
<td align="left" valign="top">
a valid path writable by the test launching process and by the test process
</td>
<td align="left" valign="top">
yes
</td>
<td align="left" valign="top">
The disk usage balancing algorithm is to choose the disk with the least space for each test run.
</td>
</tr>
</table>
</div>
<h4 class="Subsubsection">
<a class="toc" name="toc-Subsubsection-0.3.2.2">0.3.2.2</a> runconfigs.config file
</h4>
<div class="Unindented">
<table>
<tr>
<td align="left" valign="top">
section
</td>
<td align="left" valign="top">
variable
</td>
<td align="left" valign="top">
value
</td>
<td align="left" valign="top">
required?
</td>
<td align="left" valign="top">
comment
</td>
</tr>
<tr>
<td align="left" valign="top">
[default]
</td>
<td align="left" valign="top">
string of letters, numbers and underscore
</td>
<td align="left" valign="top">
any
</td>
<td align="left" valign="top">
no
</td>
<td align="left" valign="top">
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
</td>
</tr>
<tr>
<td align="left" valign="top">
[field1value/field2value...]
</td>
<td align="left" valign="top">
string of letters, numbers and underscore
</td>
<td align="left" valign="top">
any
</td>
<td align="left" valign="top">
no
</td>
<td align="left" valign="top">
the values in this section will be set for any run where field1 is field1value, field2 is field2value and fieldN is fieldNvalue.
</td>
</tr>
</table>
</div>
<div class="Indented">
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:
</div>
<div class="Code">
# runconfigs.config
</div>
<div class="Code">
[default]
</div>
<div class="Code">
ENCRYTION true
</div>
<div class="Code">
[megacorp/india]
</div>
<div class="Code">
TESTPATH /nfs/testing/megacorp_runs
</div>
<div class="Code">
[femtocorp/cook_islands]
</div>
<div class="Code">
ENCRYTION false
</div>
<div class="Code">
TESTPATH /afs/kiatoa/testing/cook_islands
</div>
<div class="Code">
[femtocorp/new_zealand]
</div>
<div class="Code">
TESTPATH /afs/kiatao/testing/new_zealand
</div>
<div class="Code">
[megacorp/new_zealand]
</div>
<div class="Code">
TESTPATH /nfs/testing/megacorp_runs
</div>
<div class="Paragraph-">
<a class="toc" name="toc-Paragraph*-1"></a>Running megatest like this:
</div>
<div class="Code">
megatest :CUSTOMER megacorp :LOCATION new_zealand :runname week12_2011_run1 -runall
</div>
<div class="Paragraph-">
<a class="toc" name="toc-Paragraph*-2"></a>Would set:
</div>
<div class="Code">
ENCRYPTION true
</div>
<div class="Code">
TESTPATH /nfs/testing/megacorp_runs
</div>
<h3 class="Subsection">
<a class="toc" name="toc-Subsection-0.3.3">0.3.3</a> Writing tests
</h3>
<h4 class="Subsubsection">
<a class="toc" name="toc-Subsubsection-0.3.3.1">0.3.3.1</a> testconfig file
</h4>
<div class="Unindented">
<table>
<tr>
<td align="left" valign="top">
section
</td>
<td align="left" valign="top">
variable
</td>
<td align="left" valign="top">
value
</td>
<td align="left" valign="top">
required?
</td>
<td align="left" valign="top">
comments
</td>
</tr>
<tr>
<td align="left" valign="top">
[setup]
</td>
<td align="left" valign="top">
runscript
</td>
<td align="left" valign="top">
name of script to execute for this test
</td>
<td align="left" valign="top">
yes
</td>
<td align="left" valign="top">
The script must be executable and either provide the full path or put a copy at the top of your test directory
</td>
</tr>
<tr>
<td align="left" valign="top">
[requirements]
</td>
<td align="left" valign="top">
waiton
</td>
<td align="left" valign="top">
list of valid test names
</td>
<td align="left" valign="top">
no
</td>
<td align="left" valign="top">
This test will not run until the named tests are state completed and status PASS
</td>
</tr>
<tr>
<td align="left" valign="top">
[items]
</td>
<td align="left" valign="top">
any valid
</td>
<td align="left" valign="top">
list of values
</td>
<td align="left" valign="top">
no
</td>
<td align="left" valign="top">
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
</td>
</tr>
</table>
</div>
<hr/>
<p>Copyright (C) 2011 Matt Welland</p>
</div>
</body>
</html>