The Megatest project was started for two reasons, the first was an immediate and pressing need for a generalized tool to manage a suite -of regression tests and the second was the fact that the author had -written or maintained several such tools at different companies over -the years and it seemed a good thing to have a single open source -tool, flexible enough to meet the needs of any team doing continuous -integrating and or running a complex suite of tests for release -qualification.
-- Matt Welland, original author of the Megatest tool suite.+
-Self-checking -Repeatable strive for directed or self-checking test - as opposed to delta based tests -
--Traceable - environment variables, host OS and other possibly influential - variables are captured and kept recorded. -
--Immutable - once this test is run it cannot be easily overwritten or - accidentally modified. -
--Repeatable - this test result can be recreated in the future -
--Relocatable - the testsuite or automation area can be checked out and the tests run anywhere -
--Encapsulated - the tests run in self-contained directories and all inputs - and outputs to the process can be found in the run areas. -
--Deployable - anyone on the team, at any site, at any time can run the flow +Self-checking - make it as easy as possible to write self-checking + tests (as opposed to using deltas, i.e. tests that compare with a + previous measurement to deterine PASS/FAIL). +
++Traceable - environment variables, host OS and other possibly + influential variables are captured and kept recorded. +
++Immutable - once a test is run it cannot be easily overwritten or + modified accidentally. +
++Repeatable - test results can be recreated in the future using all + the original variables. +
++Relocatable - the testsuite or automation area can be checked out + and the tests run anywhere in the disk hierarchy. +
++Encapsulated - the tests run in self-contained directories and all + inputs and outputs to the process can be found in the run areas. +
++Deployable - a testsuite is self-contained and can be bundled with + a software project and easily used by others with little to no + setup burden.
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 +plain text config 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.
Note 1: This road-map continues to evolve and subject to change without notice.
-Add variable $MT_RUNPATH = $MT_LINKTREE/$MT_TARGET/$MT_RUNNAME -
-[db] -api legacy|new-
-One big lesson from the 1.63-1.65 generation was that the main.db, 1.db … model was really good at scaling. I’d like to combine that model with the current also-very-good model. Obviously this is a disruptive change. I think making the old model the default and the new model an option for at least one generation would be fair. -
--Rigorous megatest.config and runconfig.config caching. -
--Cache the configs in $MT_RUNPATH -
--Following invocations of –run, -rerun* will calculate the new config but only overwrite the cached file IF changed -
--If the cached file changes ALL existing tests go from COMPLETED → STALE, I’m not sure what to do about RUNNING tests -
--!VARS in runconfigs are not exported to the environment. They are accessed via rget as if the ! was not there. -
--Per test copy commands (crude example below is not correct). -
-[testcopy] -%/iind% unison SRC DEST -% cp –r SRC DEST-
-Test management via pkts (optional?) -
--Control pkt types: run, kill, rerunclean, clean, archive, status? -
--Status pkt types: ack, step, status_change -
--Add nanomsg as a transport option -. -
-Purpose: allow shrinking megatest.db data by moving runs to an alternate - Megatest area with same keys.
Method: extend db sync to take a different megatest area as a destination.
Design:
-add param -destination [area|path]. when specified runs are copied to new - area and removed from local db. -
--the data move would involve these steps -
--copy the run data to destination area megatest.db -
--mark the run records as deleted, do not remove the run data on disk -
--accessing the data would be by running dashboard in the satellite area -
--future versions of Megatest dashboard should support displaying areas in a - merged way. -
--some new controls would be supported in the config -
--[setup] ⇒ allow-runs [no|yes] ⇐= used to disallow runs -
--[setup] ⇒ auto-migrate=[areaname|path] ⇐= used to automatically - migrate data to a satellite area. -
-Branch: This work is taking place on branch v1.65-reduce-records
Purpose: shrink megatest.db data to enable lower load and higher performance.
Method: add a completed-runs.db and automatically move runs data from megatest.db to that db
Design:
-completed-runs.db is a full megatest database with complete schema -
--the data move would involve these steps -
--copy the run data to completed-runs.db -
--remove the run data, first from /tmp/…/megatest.db and /tmp/…/megatest_ref.db, followed by megatest.db -
--accessing the data would be unchanged for most operations. -
--a mode -full-db will be added which when specified would attach the completed-runs.db to megatest.db before doing the query -
--mechanisms for moving runs to/from the megatest.db would be added -
---reduce-records ⇒ move runs to completed-runs.db -
---restore-records ⇒ move runs from completed-runs.db to megatest.db -
-Branch: This work is taking place on branch v1.65-reduce-records
Purpose: Automatically migrate homehost.
Method: Check that there are no tests running, launched or remotehoststart in past ½ hour then if not on homehost migrate the db to current host
Design:
-Check that the system is quiescent, i.e. that there are no runs in flight or recently run -
--Create a lock -
--Migrate the /tmp cache db to the current host -
--Update the .homehost file -
--Remove the lock -
-Branch: This work not yet started
-Reduce load on the file system. Sqlite3 files on network filesystem can be - a burden. [DONE] -
--Reduce number of servers and frequency of start/stop. This is mostly an - issue of clutter but also a reduction in "moving parts". [DONE] -
--Coalesce activities to a single home host where possible. Give the user - feedback that they have started the dashboard on a host other than the - home host. [DONE] -
--Reduce number of processes involved in managing running tests. -
--ACID compliant db will be on /tmp and synced to megatest.db with a five - second max delay. [DONE] -
--Read/writes to db for processes on homehost will go direct to /tmp - megatest.db file. [DONE] -
--Read/wites fron non-homehost processes will go through one server. Bulk - reads (e.g. for dashboard or list-runs) will be cached on the current host - in /tmp and synced from the home megatest.db in the testsuite area. [DONE] -
--Db syncs rely on the target db file timestame minus some margin. [DONE] -
--Since bulk reads do not use the server we can switch to simple RPC for the - network transport. [DONE] -
--Test running manager process extended to manage multiple running tests. -
--Switch to inmem db with fast sync to on disk db’s [DONE] -
--Server polls tasks table for next action -
--Task table used for tracking runner process [Replaced by mtutil] -
--Task table used for jobs to run [Replaced by mtutil] -
--Task table used for queueing runner actions (remove runs, - cleanRunExecute, etc) [Replaced by mtutil] -
-shifting, note that the preceding blank line is needed.
A single, stand-alone, Megatest based testsuite or "area" is +sufficient for most validation, automation and build problems.
Megatest is designed as a distributed or decoupled system. This means +you can run the areas stand-alone with no additional +infrastructure. I.e. there are no databases, web servers or other +centralized resources needed. However as your needs grow you can +integrate multiple areas into a bigger system.
+Multi-area dashboard and xterm. A gui (the dashboard) is usually the + best option for controlling and launching runs but all operations + can also be done from the commandline. Note: The not yet released + multi-area dashboard replaces the old dashboard for browsing and + controlling runs but for managing a single area the old dashboard + works very well. +
++Area/testsuite. This is your testsuite or automation definition and + consists of the information in megatest.config, runconfigs.config + and your testconfigs along with any custom scripting that can’t be + done with the native Megatest features. +
++If your testsuite or build automation is too large to run on a + single instance you can distribute your jobs into a compute server + pool. The only current requirements are password-less ssh access and + a network filesystem. +
+Creating a testsuite or flow and your first test or task.
Creating a testsuite or flow and your first test or task.
After installing Megatest you can create a flow or testsuite and add some tests using the helpers. Here is a quickstart sequence to get you up and running your first automated testsuite.
dashboard -rows 24
Megatest is an extensive program with a lot to learn. Following are some paths through the material to smooth the learning path.
+Components of automation; run, test, iteration +
++Selectors; target, runname, and testpatt +
++Using the dashboard gui (recommended) +
++Using the "Runs" panel. +
++Using the "Run Control" panel. +
++Using a test control panel +
++The Right Mouse Button menu +
++Debug features +
++xterm +
++pstree +
++log files; mt_copy.log, mt_launch.log +
++variables; megatest.csh, megatest.sh +
++testconfig dump, *testconfig +
++State/status buttons +
++Run, Clean, KillReq +
++ReRunClean +
++Using the command line +
++Getting help; megatest -h, megatest -manual +
++Starting runs; megatest -run +
++Selection controls; -target, -runname and -testpatt +
++environment variables (table 5) +
++tests/testname/testconfig testconfig details +
++ezsteps and logpro section +
++iteration (one test applied to many inputs), items, itemstable test iteration +
++dependencies, waiton, itemmatch, itemwait test requirements +
++miscellaneous; mode toplevel, runtimelim, skip on file or on running, waiver propagation +
++megatest areas +
++megatest.config +
++runconfigs.config +
++config language features; include, shell, system, scheme, rp|realpath, getenv, get, rget, scriptinc config file helpers +
++Removing and keeping runs selectively managing runs +
++Subruns nested runs +
++Config file features config file features +
++HTML output with -generate-html +
++Triggers, post run, state/status +
++MTLOWESTLOAD +
++flexilauncher +
++env delta and testconfig +
++capturing test data, extracting values from logpro and using them for pass/fail +
++mtutil, postgres connection, packets for cross-site/cross-user control (e.g. mcrun). +
++cleanup-db, database structure of Megatest 1.6x +
++archiving +
++homehost management +
++show-runconfig +
++show-config +
++show with -debug 0,9 +
++load management +
+Can use either wildcard of "%" or a regular expression:
[/abc.*def/]
Some parameters you can put in the [setup] section of megatest.config:
# minimum space required in a run disk minspace 10000000 @@ -1775,21 +1779,21 @@ # script that takes path as parameter and returns number of bytes available: free-space-script check-space.sh
[configf:settings trim-trailing-spaces yes]
[host-types] general nbfake @@ -1803,11 +1807,10 @@ launcher bsub # if defined and not "no" flexi-launcher will bypass launcher unless # there is no host-type match. flexi-launcher yes
List of host types and the commandline to run a job on that host type.
runscript main.csh
# full combinations +[items] +A x y +B 1 2 + +# Yields: x/1 x/2 y/1 y/2 + +# tabled +[itemstable] +A x y +B 1 2 + +# Yields x/1 y/2+
[requirements]
# A normal waiton waits for the prior tests to be COMPLETED # and PASS, CHECK or WAIVED waiton test1 test2
The default (i.e. if mode is not specified) is normal. All pre-dependent tests must be COMPLETED and PASS, CHECK or WAIVED before the test will start
[requirements] @@ -2050,11 +2074,10 @@-[requirements] mode itemmatch
Override variables before starting the test. Can include files (perhaps generated by megatest -envdelta or similar).
Complex mappings can be handled with a separate [itemmap] section (instead if an itemmap line in the [requirements] section)
Each line in an itemmap section starts with a waiton test name followed by an itemmap expression
[itemmap] A foo/ bar/ B stuff/
An alternative to defining items is the itemstable section. This lets you define the itempath in a table format rather than specifying components and relying on getting all permutations of those components.
[requirements] # With a toplevel test you may wish to generate your list @@ -2228,31 +2252,31 @@ # of tests to run dynamically # waiton #{shell get-valid-tests-to-run.sh}
[requirements] runtimelim 1h 2m 3s # this will automatically kill the test if it runs for more than 1h 2m and 3s
A test with a skip section will conditional skip running.
[skip] prevrunning x # rundelay 30m 15s
# NB// If the prevrunning line exists with *any* value the test will # automatically SKIP if the same-named test is currently RUNNING. The # "x" can be any string. Comment out the prevrunning line to turn off @@ -2260,35 +2284,35 @@ [skip] prevrunning x
[skip] fileexists /path/to/a/file # skip if /path/to/a/file exists
[skip] rundelay 15m 15s
A disks section in testconfig will override the disks section in megatest.config. This can be used to allocate disks on a per-test or per item basis.
If test is FAIL and previous test in run with same MT_TARGET is WAIVED then apply the following rules from the testconfig: If a waiver check is specified in the testconfig apply the check and if it passes then set this FAIL to WAIVED
Waiver check has two parts, 1) a list of waiver, rulename, filepatterns and 2) the rulename script spec (note that "diff" and "logpro" are predefined)
To transfer the environment to the next step you can do the following:
$MT_MEGATEST -env2file .ezsteps/${stepname}
In your testconfig or megatest.config triggers can be specified
[triggers] # Call script running.sh when test goes to state=RUNNING, status=PASS RUNNING/PASS running.sh @@ -2347,20 +2372,21 @@
Scripts called will have; test-id test-rundir trigger test-name item-path state status event-time, added to the commandline.
HINT
To start an xterm (useful for debugging), use a command line like the following:
[triggers] COMPLETED/ xterm -e bash -s --
- | There is a trailing space after the -- | +There is a trailing space after the double-dash |
There are a number of environment variables available to the trigger script but since triggers can be called in various contexts not all variables are available at all times. The trigger script should check for the variable and @@ -2368,66 +2394,66 @@
Variable | +Variable | Purpose | |
---|---|---|---|
MT_TEST_RUN_DIR |
-The directory where Megatest ran this test |
-||
MT_CMDINFO |
-Encoded command data for the test |
-||
MT_DEBUG_MODE |
-Used to pass the debug mode to nested calls to Megatest |
-||
MT_RUN_AREA_HOME |
-Megatest home area |
-||
MT_TESTSUITENAME |
-The name of this testsuite or area |
-||
MT_TEST_NAME |
-The name of this test |
-||
MT_ITEM_INFO |
-The variable and values for the test item |
-||
MT_MEGATEST |
-Which Megatest binary is being used by this area |
-||
MT_TARGET |
-The target variable values, separated by / |
-||
MT_LINKTREE |
-The base of the link tree where all run tests can be found |
-||
MT_ITEMPATH |
-The values of the item path variables, separated by / |
-||
MT_RUNNAME |
-The name of the run |
+MT_TEST_RUN_DIR |
+The directory where Megatest ran this test |
+
MT_CMDINFO |
+Encoded command data for the test |
+||
MT_DEBUG_MODE |
+Used to pass the debug mode to nested calls to Megatest |
+||
MT_RUN_AREA_HOME |
+Megatest home area |
+||
MT_TESTSUITENAME |
+The name of this testsuite or area |
+||
MT_TEST_NAME |
+The name of this test |
+||
MT_ITEM_INFO |
+The variable and values for the test item |
+||
MT_MEGATEST |
+Which Megatest binary is being used by this area |
+||
MT_TARGET |
+The target variable values, separated by / |
+||
MT_LINKTREE |
+The base of the link tree where all run tests can be found |
+||
MT_ITEMPATH |
+The values of the item path variables, separated by / |
+||
MT_RUNNAME |
+The name of the run |
It is often necessary to capture and or manipulate environment variables. Megatest has some facilities built in to help.
Dump modes include bash, csh and config. You can include config data -into megatest.config or runconfigs.config.
megatest -envcap original # do some stuff here @@ -2499,12 +2527,11 @@
Then in runconfigs.config
cat testconfig -[pre-launch-env-vars] +[pre-launch-env-vars] [include modified.config]
Note 1: This road-map continues to evolve and subject to change without notice.
+Add variable $MT_RUNPATH = $MT_LINKTREE/$MT_TARGET/$MT_RUNNAME +
+[db] +api legacy|new+
+One big lesson from the 1.63-1.65 generation was that the main.db, 1.db … model was really good at scaling. I’d like to combine that model with the current also-very-good model. Obviously this is a disruptive change. I think making the old model the default and the new model an option for at least one generation would be fair. +
++Rigorous megatest.config and runconfig.config caching. +
++Cache the configs in $MT_RUNPATH +
++Following invocations of –run, -rerun* will calculate the new config but only overwrite the cached file IF changed +
++If the cached file changes ALL existing tests go from COMPLETED → STALE, I’m not sure what to do about RUNNING tests +
++!VARS in runconfigs are not exported to the environment. They are accessed via rget as if the ! was not there. +
++Per test copy commands (crude example below is not correct). +
+[testcopy] +%/iind% unison SRC DEST +% cp –r SRC DEST+
+Test management via pkts (optional?) +
++Control pkt types: run, kill, rerunclean, clean, archive, status? +
++Status pkt types: ack, step, status_change +
++Add nanomsg as a transport option +. +
+Purpose: allow shrinking megatest.db data by moving runs to an alternate + Megatest area with same keys.
Method: extend db sync to take a different megatest area as a destination.
Design:
+add param -destination [area|path]. when specified runs are copied to new + area and removed from local db. +
++the data move would involve these steps +
++copy the run data to destination area megatest.db +
++mark the run records as deleted, do not remove the run data on disk +
++accessing the data would be by running dashboard in the satellite area +
++future versions of Megatest dashboard should support displaying areas in a + merged way. +
++some new controls would be supported in the config +
++[setup] ⇒ allow-runs [no|yes] ⇐= used to disallow runs +
++[setup] ⇒ auto-migrate=[areaname|path] ⇐= used to automatically + migrate data to a satellite area. +
+Branch: This work is taking place on branch v1.65-reduce-records
Purpose: shrink megatest.db data to enable lower load and higher performance.
Method: add a completed-runs.db and automatically move runs data from megatest.db to that db
Design:
+completed-runs.db is a full megatest database with complete schema +
++the data move would involve these steps +
++copy the run data to completed-runs.db +
++remove the run data, first from /tmp/…/megatest.db and /tmp/…/megatest_ref.db, followed by megatest.db +
++accessing the data would be unchanged for most operations. +
++a mode -full-db will be added which when specified would attach the completed-runs.db to megatest.db before doing the query +
++mechanisms for moving runs to/from the megatest.db would be added +
++-reduce-records ⇒ move runs to completed-runs.db +
++-restore-records ⇒ move runs from completed-runs.db to megatest.db +
+Branch: This work is taking place on branch v1.65-reduce-records
Purpose: Automatically migrate homehost.
Method: Check that there are no tests running, launched or remotehoststart in past ½ hour then if not on homehost migrate the db to current host
Design:
+Check that the system is quiescent, i.e. that there are no runs in flight or recently run +
++Create a lock +
++Migrate the /tmp cache db to the current host +
++Update the .homehost file +
++Remove the lock +
+Branch: This work not yet started
+Reduce load on the file system. Sqlite3 files on network filesystem can be + a burden. [DONE] +
++Reduce number of servers and frequency of start/stop. This is mostly an + issue of clutter but also a reduction in "moving parts". [DONE] +
++Coalesce activities to a single home host where possible. Give the user + feedback that they have started the dashboard on a host other than the + home host. [DONE] +
++Reduce number of processes involved in managing running tests. +
++ACID compliant db will be on /tmp and synced to megatest.db with a five + second max delay. [DONE] +
++Read/writes to db for processes on homehost will go direct to /tmp + megatest.db file. [DONE] +
++Read/wites fron non-homehost processes will go through one server. Bulk + reads (e.g. for dashboard or list-runs) will be cached on the current host + in /tmp and synced from the home megatest.db in the testsuite area. [DONE] +
++Db syncs rely on the target db file timestame minus some margin. [DONE] +
++Since bulk reads do not use the server we can switch to simple RPC for the + network transport. [DONE] +
++Test running manager process extended to manage multiple running tests. +
++Switch to inmem db with fast sync to on disk db’s [DONE] +
++Server polls tasks table for next action +
++Task table used for tracking runner process [Replaced by mtutil] +
++Task table used for jobs to run [Replaced by mtutil] +
++Task table used for queueing runner actions (remove runs, + cleanRunExecute, etc) [Replaced by mtutil] +
+shifting, note that the preceding blank line is needed.