BCCD:Regression Testing

From Earlham CS Department
Jump to: navigation, search

Regression Testing

Executing the Tests

To execute the regression tests included with bccdrt on a running copy of the BCCD, simply checkout the bccdrt module from CVS on bccd.cs.uni.edu and start runtests.py:

export CVSROOT=username@bccd.cs.uni.edu:/var/lib/cvs/var/lib/cvs # you aren't seeing double and this isn't a typo!
cvs co bccdrt
cd bccdrt
./runtests.py # run list-packages and install python first if need be

System Overview

This section exposes the architecture behind bccdrt, which refers generally to the collection of Python and PHP scripts than handle the execution and data extraction (bccdrt.py), recording (post-results.php), and analysis (show-results.php) of BCCD regression tests (the scripts were written and tested on PPC, but can be used on any architecture the BCCD supports).

htdocs

This directory houses the PHP scripts that record and analyze test data.

rt.d

This directory houses individual test scripts and the bccdrt library, which provides several routines to the individual tests (see bccdrt.py below).

runtests.py

This script calls some generic bccd cluster initialization routines (bccd-allowall, bccd-snarfhosts, and bccd-checkem machines) and then executes each of the tests in the rt.d directory. No per-test modification of runtests.py is necessary.

bccdrt.py

This library provides several routines to individal tests, including system(...), runcmd(...), and postresult(...). It resides in the rt.d directory, but contains no actual test code itself.

  • system(...) takes a single argument in the form of a shell command, executes that command, and allows the output to print to the console.
  • runcmd(...) does the same thing, but returns the output (both stdout and stderr) as a string.
  • postresult(...) takes two arguments: the test name and an associative array of your test data (column) names and values. postresult(...) adds the generic test data, like machine name, BCCD release, etc., encodes the data in XML, and posts it to post-results.php via HTTP.

To define a new test, write a new script in Python that executes whatever programs on the BCCD the test involves and then extracts the relevant data from them (e.g., with regular expressions). There is an sample test in rt.d named gromacs.py. The only call your test function must make is to postresult(...).

Example: Creating the associative array and calling postresult(...)

import bccdrt

result={}

result["molecule"] = os.path.basename(moleculedir)
result["np"] = np
result["walltime"] = Real
result["psNODEhr"] = psNODEhr

postresult("gromacs",result)

post-results.php

This script is generally responsible for recording data as posted by bccdrt.py. This involves the following:

  • receiving the XML-encoded data from bccdrt.py
  • determining the SQL table format from the given data names and values
  • creating the SQL table if necessary
  • inserting the given data into the table

What does this mean for you? post-results.php is entirely automatic; that is, it requires no per-test modification to operate.

show-results.php

This script handles the analysis and display of the regression test data that resides in the SQL tables created by post-results.php. Per regression test, it operates with the folllowing parameters: (a) a table name; (b) an array of check columns, i.e., columns that contain the actual test data that we're concerned with; and (c) an array of control columns, i.e., columns whose values determine the grouping of data within each test table, e.g., if one's control columns are 'processor' and 'node_count', then show-results.php will discover every possible combination (between columns) of distinct column cell values and use that set of combinations to group test data prior to analysis and display. Each grouping combination includes exactly one value from every control column. This is easier understood when seen than when described (due in a large part to my inability to describe the system at hand), so visit the actual script and see what it does for yourself!

So, to make show-results.php aware of your newly-defined regression test, simply create an associative array containing your table name (tbname), array of check columns (check_cols), and array of control columns (control_cols) and append it to the $tests array. The table name is the test name prefixed by rt_, and the column names are exactly the same as those passed to postresult(...) in the original Python.

Example: Defining a test in show-results.php

$tests = array( array(  "tbname" => "rt_gromacs",
                        "check_cols" => array("walltime","psNODEhr"),
                        "control_cols" => array("machine","molecule","np") )
               );

show-results.php then iterates through $tests in the body of the HTML document, calling showResults(...) with the parameters defined in each element.

Recap: Creating a New Test

That's a lot of talk for a relatively simple process. Here's the basic outline once more of what creating a new regression test involves:

  • 1. write the actual test in Python and call postresult(...) to send the test data to the result server
  • 2. drop your test in the rt.d directory
  • 3. define your test's table name, check columns, and control columns in show-results.php
  • 4. commit your changes to CVS, update the CVS module on the result server, and execute the tests.

FAQ

How does show-results.php analyze test data?

The analysis script calculates the standard deviation of each grouping of each check column and from that determines, on a per-cell basis, outliers in the data set, i.e., possible test failures (1*S). Cells that pass the test are given the CSS class rt_pass, and cells that fail rt_fail. Currently, the stylesheet marks passes green and potential failures red.

TODO

  • Implement early failure detection and reporting (e.g., "this command doesn't even run")

Conclusion

That brings a close to our discussion of BCCD regression testing. Please direct any questions, comments, or suggestions to the system's author, Tobias McNulty.