Auto-tools/Projects/Autolog
Goal
The Autolog project seeks to implement a TBPL-like system for viewing test results produced by the a-team's various tools, at least those of which aren't hooked up to TBPL. Such projects potentially include mobile automation, Crossweave, profile manager, etc.
Proposed Implementation
The system will be comprised of both a front-end web UI, and a backend database. The database which will be used is ElasticSearch, the same instance of which we're using for OrangeFactor, since our experience with that seems to indicate that it is fast, reliable, and easy to use.
Communication with the db will be provided by two channels: a REST API, which we can probably build by extending Orange Factor's woo_server.py, and a python library that automation tools can use to post results to the database.
The tbpl source should make a good starting place. A few files will have to be replaced more-or-less in their entirety, including Data.js, PushlogJSONParser.js, SummaryLoader.js, and TinderboxJSONUser.js.
Necessary global changes include the following:
- replacing the notion of 'trees' with 'products' or something similar
- products will be combined together into one log, rather than split between different logs, since we presumably won't be running a lot of simultaneous tests against one product
- test suites are product dependent
- test names and other test metadata will be extracted from the test-run JSON rather than being hardcoded in the client JS
The idea of using CommonJS (specifically, the modules system) was discussed, but given that we will use tbpl as a starting point, it doesn't make sense to redo the basic architecture, which works well. It would also make it difficult to port any new features over to tbpl.
asuth of MoMo created an alternative view to tbpl called ArbPL (code). Might be interesting for possible UI ideas and as a source of more code that interfaces with tinderbox.
Data Structure
There are two types of data structures we are concerned with. One is the structure of data that a test suite will have to provide in order to insert test results into ElasticSearch. The second is the structure of data inside ElasticSearch itself.
For the former:
{ // testgroup definition 'harness': 'tinderbox', 'testgroup': 'mochitest-other', 'machine': 'talos-r3-fed64-044', 'testsuite_count': 1, // supplied by python lib 'starttime': 1297879654, 'date': '2011-02-16', // supplied by python lib 'logurl': '...', // optional 'os': 'fedora12', 'platform': 'linux', // 'testrun' is an implementation-specific identifier which // is unique among a set of related testgroups; it is used to // differentiate multiple sets of testgroups which may be run // against the same changeset 'testrun': '...', // Base product definition: the primary product under test. For // Crossweave, this is the fx-sync code; for Android it is // the mobile-browser code. In a TBPL-like display, this // product's rev would be displayed in the "commit" column. 'productname': 'sync', 'tree': 'fx-sync', 'branch': '1.7', // optional? 'revision': '553f7b1974a3', 'buildtype': 'xpi', 'buildid': '20110210030206', // optional 'version': '1.7.pre', // optional 'buildurl': '...', // optional // Secondary product definitions: additional products involved // in the test. For Crossweave or Android, this might be // 'mozilla-central', etc. There can be as many secondary // products as needed. 'tree2': 'mozilla-central', 'branch2': 'default', // optional? 'revision2': '553f7b1974a3', // optional for secondary products 'buildtype2': 'opt', 'buildid2': '20110210030206', // optional 'version2': '4.0b13pre', // optional 'buildurl2': '...', // optional // Testsuite definition. This is an array (to support cases like // mochitest-other); only one member is shown in the example below. 'testsuites': [ // for cases other than mochitest-other, this is probably the // same as 'testgroup' above 'suitename': 'mochitest-ally1', 'cmdline': '...', // optional 'testfailure_count': 1, // provided by python lib 'elapsedtime': 665, // in seconds 'passed': 85152, 'failed': 1, 'todo': 124, // These are failures that occur during specific test cases. 'testfailures': [ // 'test' is null in cases where the error cannot be assigned to a specific test case, // e.g., crashes that occur after all tests have finished 'test': 'xpcshell/tests/toolkit/components/places/tests/autocomplete/test_download_embed_bookmarks.js', // per test logs, optional 'logurl': '...', // Like testsuite errors, each member of 'failures' can contain // additional metadata depending on failure type. 'failures': [ 'status': 'TEST-UNEXPECTED-FAIL', 'text': 'Acceleration enabled on Windows XP or newer - didn't expect 0, but got it' ] ], ] }
For the structure in ElasticSearch, the data will be separated into three document types (by the python library if that's used; the test suite will have to do this if it's posting to ES directly via HTTP), similar to the way that tinderbox logs are spread across three document types at present:
- a testgroup document (corresponding to tinderbox build documents, example here)
- one or more testsuite documents (corresponding to tinderbox testrun documents, example here)
- one or more testfailure documents (corresponding to tinderbox testfailure documents, example here)
Q: Why do we separate the data into three document types, why not just use one big document?
A: Because searches in ElasticSearch are must faster and easier with basic data types; searching inside complex nested JSON is slower and the syntax is much more complex.
Q: Can't the python library automatically provide 'os' and 'platform'?
A: It would be nice, wouldn't it? Unfortunately, there are lots of things which can confuse the issue; e.g., if you're using mozilla-build on Windows, it will see your 64-bit version of Windows as win32, regardless of what you're testing. Similarly, we sometimes test 32-bit Mac stuff on macosx64. It seems safest to have the test tools provide this data instead of trying to guess.
Q: Why do we have both testgroup and testsuite?
A: It's entirely to support mochitest-other. :( In most cases, each testgroup will have 1 testsuite.
Q: Where are the test runs in this structure?
A: We've been using the term 'testrun' to mean different things in different places. In this structure, I imagine 'testrun' to mean the same thing as it does in OrangeFactor: that is, a collection of testgroups that are run against the same primary changeset.
Q: Is this really the best way to include data about multiple products, or code from multiple repos?
A: I'm not sure. I suggested this structure because it's easy to use when searching ES. Other structures are possible. For instance, we could create a 'product' document type, and store all the products there, and then just include indexes to this document in the 'testgroup' document. The downside to this is that getting certain data out of ES would require multiple queries.
Open Issues
Identifying 'testruns'
The above structure would work fine for displaying a TBPL-like result view. It might be problematic if we intend to feed into OrangeFactor, however.
The problem is in identifying unique test runs. For OrangeFactor, we rely on the fact the buildbot uses the same buildid with all related 'testgroups'. If buildbot reruns the same testgroups (because it's bored), it generates a new buildid, even though the revision is still the same. Thus we can identify unique test runs.
For non-buildbot cases (and I'm specifically thinking of Crossweave), we don't have an analogous buildid. In the Crossweave case, each 'testgroup' fired off against a given revision is independent and doesn't share any metadata (like a buildid) with other testgroups run at the same time.
If we want to maintain consistency with OrangeFactor, we may have to require a 'buildid' value, which would be the same across all testgroups which are initiated by the same event. This would require some refactoring of Crossweave and possibly other tools.
Using 'buildid' isn't a perfect solution, though, as some buildbot jobs (like once-a-day win64 runs) use a distinct buildid that doesn't match other buildbot jobs run on the same changeset. We're currently excluding these in OrangeFactor so it isn't skewing data, but it illustrates the drawbacks of relying on buildid.
The other option is to change the way OrangeFactor identifies testruns. Instead of relying on buildid, we could implement some algorithm like this:
- identify all the changesets that have testgroups; the number of changesets is our preliminary testrun_count
- for each changeset, identify the list of testgroups (L) and the unique set of testgroups (S), based on 'testgroup' and 'platform'
- if len(S) > len(L), create a list of 'extra testgroups' (E) by removing members of (S) from (L)
- sort (E) and look for the maximum number of duplicate entries (e.g., if (E) contains three 'mochitest-other'/'win32' and two 'mochitest-1/5'/'linux64', return 3), and add this number of the preliminary testrun_count
There's always going to be some guesswork involved, since the idea of a 'testrun' we're using in OrangeFactor is entirely an intellectual concept and not something supported intrinsically by our test frameworks.
update: Per the WOO meeting on 2011-03-02, we decided to add a 'testrun' field to the data structure above, which the implementation would be responsible for filling with a value that is unique for specific collections of testgroups.
Log Storage
Some tools will need to store logs somewhere that can be served by autolog on request; we can't store these in ES, so where should they go? Options include stage, brasstacks, or some alternate solution provided by metrics. In order to engage other teams, we'll likely need guesstimates about total storage needed per month and some idea about the retention policy.
TBPL Data Structure
The basic unit of data in TBPL is the push. A push according to TBPL looks like this:
"b853c6efa929": { "id": 19218, "pusher": "dougt@mozilla.com", "date": "2011-03-17T20:50:37.000Z", "toprev": "b853c6efa929", "defaultTip": "b853c6efa929", "patches": [ { "rev": "b853c6efa929", "author": "Doug Turner", "desc": "Bug 642291 - crash [@ nsBufferedInputStream::Write] demos.mozilla.org motovational poster. ipc serialization does not work here, removing it. r=bent a=blocking-fennec", "tags": { "length": 0, "prevObject": { "length": 0 } } } ] },
Additionally, each push can have a 'results' key, which contains all the results associated with that push. If the 'results' key exists, it looks like this:
'results': { 'linux': { 'opt': { 'Reftest': [ an array of machineResults ], 'Mochitest': [ an array of machineResults ], etc, }, 'debug': {} }, 'linux64': {}, etc }
Each 'machineResult' looks like this:
"1300280775.1300281487.29409.gz": { "tree": "Firefox", "machine": { "name": "Rev3 WINNT 5.1 mozilla-central opt test mochitests-2/5", "os": "windowsxp", "type": "Mochitest", "debug": false, "latestFinishedRun": (a reference to the last finished run for this machine), "runs": 0, "runtime": 0, "averageCycleTime": 0 }, "slave": "talos-r3-xp-039", "runID": "1300280775.1300281487.29409.gz", "state": "success", "startTime": "2011-03-16T13:06:15.000Z", "endTime": "2011-03-16T13:19:01.000Z", "briefLogURL": "http://tinderbox.mozilla.org/showlog.cgi?log=Firefox/1300280775.1300281487.29409.gz", "fullLogURL": "http://tinderbox.mozilla.org/showlog.cgi?log=Firefox/1300280775.1300281487.29409.gz&fulltext=1", "summaryURL": "php/getSummary.php?tree=Firefox&id=1300280775.1300281487.29409.gz", "revs": { "mozilla-central": "ee18eff42c2e" }, "notes": [], "errorParser": "unittest", "_scrape": [ " s: talos-r3-xp-039", "<a href=http://hg.mozilla.org/mozilla-central/rev/ee18eff42c2e title=\"Built from revision e18eff42c2e\">rev:ee18eff42c2e</a>", " mochitest-plain-2
11855/0/292" ] 'push': (reference to the push this belongs to), 'getTestResults': a function, 'getScrapeResults': a function, 'getUnitTestResults': a function, 'getTalosResults': a function, },
All of this gets fed into UserInterface.js in the handleUpdatedPush function().
UI
There are three main aspects of TBPL that we want to present in Autolog:
- a list of on-going test runs
- a colour-coded list of (abbreviated) names of on-going test suites for each test run
- popups with detailed test data
The first two are dynamically updated, with newly started runs being inserted at the top, and test suites changing colours as they change states.
Additional, useful information:
- list of currently failing tests
- filters
- dropdowns for metadata (abbreviations, tree info, etc.)
Since TBPL's UI is pretty clean and crisp, we should try to reuse TBPL's HTML and CSS. JavaScript might be more problematic, depending on how closely tied it is to the underlying layers.
Client/Server
TBPL puts all the work into the client. The client-side JavaScript is responsible for querying tinderbox directly.
Autolog will have a relatively thin server side with a caching layer to limit the number of queries going to the ES database. Since the UI will only display a subset of the total data for each test run, the smaller set can be cached and refreshed periodically. Requested for test-run details will still go directly to the ES database.
Setting up a Development Environment
Pre-requisites:
- pyes (http://pypi.python.org/packages/source/p/pyes/pyes-0.14.1.tar.gz, or easy_install pyes)
- mozautoeslib (http://hg.mozilla.org/automation/mozautoeslib/)
- autolog (http://hg.mozilla.org/automation/autolog/)
Steps:
- Setup a local instance of ElasticSearch for development purposes, and populate it with test data, see README-testdata.txt. By default, this will operate on http://localhost:9200/
- Start the autolog server in the autolog repo, using
python autolog_server.py .
- Host the autolog repo using a webserver; I use Apache but presumably nginx or anything else would work equally well.
- Navigate to index.html in the autolog repo; depending on how you've configured your webserver this might look something like http://localhost/autolog/
Tasks
Task | Owner | Notes |
Investigate TBPL code and determine how much to re-use | mcote | We will use it as a starting point, stripping out what's unnecessary and modifying existing code as necessary to deal with autolog's (simpler) data source. |
Client code (HTML/CSS/JS) | mcote, jmaher? | |
Propose common data structure for test results in db | Jgriffin | |
Clean up woo_server.py and modularize in order to make future additions easier | ? | |
Create python library for test tools to use to post results to db | jgriffin | |
Investigate implementing threading in woo_server |