report results using wikitcms directly, not via relval
ClosedPublic

Authored by adamwill on Mar 24 2015, 2:37 AM.

Details

Summary

Also refactor the result submission a bit to share the code
between CLI and module modes. This depends on the very latest
bits in wikitcms git master, will not work at all without
them.

This should be substantially more efficient - it should make
only two wiki roundtrips per result page, and only init and
login to the wiki once. Going via relval requires a wiki init
and then two roundtrips for *each result*.

Test Plan

Test reporting results both by invoking report_job_results.py
directly, and from openqa_trigger.py.

Diff Detail

Repository
rOPENQA fedora_openqa
Branch
wikitcms
Lint
No Linters Available
Unit
No Unit Test Coverage
adamwill retitled this revision from to report results using wikitcms directly, not via relval.Mar 24 2015, 2:37 AM
adamwill updated this object.
adamwill edited the test plan for this revision. (Show Details)
adamwill added reviewers: jskladan, garretraziel.
adamwill updated this revision to Diff 865.Mar 24 2015, 3:06 AM

Drop a superfluous list->set->list conversion.

The wikitcms changes behind this are moderately large: all the changes since 1.10.3 are basically part of the background for this. The ValidationPage add_results() method handles editing multiple results into a single page, and the Wiki report_validation_results() method handles getting ValidationPage, ResultRow and Result instances from the passed tuple attributes, creating a results dict in the correct form for add_results(), and calling add_results() for each affected Page.

I also implemented some caching for Page API queries - for page text and the list of page sections - to avoid repeated remote queries as we work through the list of results.

It does make wikitcms more complex, but I don't think it's going into the realm of building custom interfaces that'd be no use to other callers; a high-level 'just report a bunch of results and handle the details for me' function is something that could certainly be useful in other ways, and the caching is a clear performance improvement.

jskladan requested changes to this revision.Mar 24 2015, 8:49 AM

Overall, this looks pretty good to me, but please consider the comment below.

tools/openqa_trigger/report_job_results.py
50

How about using collections.namedtuple() instead? One can still use it as a regular tuple, but it has the added bonus of accessibility by key, thus removing the "magical constants" as at lines 53, and 72, and making the code more readable and maintainable.

This revision now requires changes to proceed.Mar 24 2015, 8:49 AM

Hah - I actually thought of doing that initially, but figured you might think it was over-complicating things :) I use namedtuples for a couple of things in fedfind. +1, I'll do it.

So there's one issue with the namedtuple approach. The tuples that report_validation_results() returns for duplicate reports are not the original objects it was passed, for...$REASONS. They're reconstructed by wikitcms during the process. So I can do the change, and we could then avoid the magic const at line 53, but we can't avoid the ones at line 72 because they're coming from report_validation_results() output, which won't be our namedtuple.

So...here's a thought: wikitcms could define a namedtuple class for this case. You can pass report_validation_results() an instance of that class, or just a regular tuple. Whichever you pass, it returns instances of that class.

Then report_job_results could import that class from wikitcms and pass in its results using it. That way we wouldn't be doing the same work both sides and wouldn't run the risk of the names used in the namedtuple diverging between the two. wikitcms would still not be imposing any mandatory complexity on callers, as they could ignore the namedtuple stuff entirely and just pass in a regular tuple and treat what they get out as a regular tuple, if they like.

WDYT?

if you're interested in the $REASONS, it's basically because wikitcms tries to be forgiving about the input for report_validation_results(). It will accept incomplete data so long as it's satisfied it can reliably guess what was intended. So the input tuple might have only a partial testcase name and no section or testname at all, for e.g. - that can be OK, if the partial testcase name alone identifies a single 'test instance' in the given page.

But the actual result reporting needs to use ResultRow() instances, which have full and precise data. report_validation_results() passes page.add_results() the ResultRow() instance - but it's page.add_results() which figures out whether a given result is a dupe of an existing report or not. It doesn't make sense for report_validation_results() to do that work.

So page.add_results() figures out the dupes and passes the info back to report_validation_results() - but page.add_results() doesn't know what the sloppy original input tuple was, it only knows the ResultRow() instance it was passed. page.add_results() outputs dupes as (ResultRow, env, Result) tuples, and report_validation_results() parses those back into the 12-tuple format to be returned.

The only way to avoid this, I guess, would be to have report_validation_results() keep track of the ResultRow and env it passes to page.add_results() and then do some work to parse the dupes list it gets back, and figure out which dupe came from which original tuple. I dunno, that seems kind of a mess, and not even necessarily the 'right' thing. And there's still another issue with that approach - page.add_results() fixes up imprecise env if it can (so if you pass it 'X8' and the envs for the test are 'x86' and 'ARM', it figures out you meant 'x86') and returns the fixed value (not the sloppy submitted one) in the dupe dict. I could change that too, but...again, not sure it's the right thing to do.

adamwill updated this revision to Diff 866.Mar 24 2015, 9:37 PM

use wikitcms' ResTuple namedtuple to construct results

More or less as jskladan suggested, only it makes most sense to
put the namedtuple in wikitcms and let callers use it if they like.

adamwill updated this revision to Diff 867.Mar 25 2015, 3:28 AM

Tweak a bit more now ResTuples have defaults

I added bits to wikitcms to give ResTuples default values, so
users (like us) can omit values they don't need to pass. Let's
take advantage of that, and also (re-)compress things just a bit (I
think it remains readable this way, while being a bit shorter).

I'm still not 100% sure I've hit on the very best/neatest way of
doing all this stuff yet (either wikitcms or openqa side), if anyone
has a really clever idea, please do suggest it!

garretraziel accepted this revision.Mar 25 2015, 8:43 AM

Looks good to me. I have no problem with using wikitcms own namedtuple and code now looks definitely better than before. Only nitpick is function report_results - it seems redundant and from line 85 it seems that it doesn't even get called.

jskladan accepted this revision.Mar 25 2015, 9:13 AM

+1 for @garretraziel's comment, but:

Macro doge: much approved such changes

This revision is now accepted and ready to land.Mar 25 2015, 9:13 AM

report_results() is what openqa_trigger.py calls.

Splitting it up this way is actually a leftover from the crash reporting stuff - I pulled the refactoring at the bottom in from that branch and re-purposed it. On the other branch it called report_passes() then report_crashes(), and the CLI bits let you choose whether to call one or the other or both.

While we're only reporting passes, having both report_results() and report_passes() seems a bit unnecessary indeed. We could drop the stubby report_results() and rename report_passes to report_results, I guess.

I think that this differential request is already merged. Please close it.

adamwill closed this revision.Jul 10 2015, 4:07 PM