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.
Table of Contents

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 dependencies on Linux.

0.2.1.2 Build and install

Run “make test” to create the megatest executable. 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 organized
[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
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.2.1 megatest.config

section variable value required comment
[setup] max_concurrent_jobs if variable is not defined no limit on jobs no
executable full path to megatest binary 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 full path to where the link tree to all runs will be created 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 string of letters, numbers and underscore at least one
[jobtools] launcher command line used to launch jobs - the job command (megatest -execute) will be appended to this no
workhosts list of hostnames to run jobs on NOT SUPPORTED RIGHT NOW n/a
[env-override] string of letters, numbers and underscore any string 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 a valid path writable by the test launching process and by the test process 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

section variable value required? comment
[default] string of letters, numbers and underscore any 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 any 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:
# runconfigs.config
[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:
megatest :CUSTOMER megacorp :LOCATION new_zealand :runname week12_2011_run1 -runall
Would set:
ENCRYPTION true
TESTPATH /nfs/testing/megacorp_runs

0.3.3 Writing tests

0.3.3.1 testconfig file

section variable value required? comments
[setup] runscript name of script to execute for this test 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 list of valid test names no This test will not run until the named tests are state completed and status PASS
[items] any valid list of values 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.4 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