This adds an 'all' mode which runs for the current validation event 
compose if it hasn't already been done, then runs for the current 
date's Rawhide and Branched nightlies, if they exist and aren't the 
same as the current validation event. Has a --yesterday parameter to 
run on the nightlies from a day earlier instead, if your timezone / 
cron config don't hook up great with releng's. (In future we ought to 
have a daemon that listens for compose events from fedmsg or 
something). 'Today' and 'yesterday' are calculated in UTC.

Right now the non-'validation event' results are just going to sit in 
OpenQA, but I have Grand Plans to get 'em out via fedmsg and/or 
special wiki pages. For now only folks with VPN access or their own 
Coconut instance will be able to see the results, sorry!

We *may* wind up running the tests for a nominated nightly compose 
twice - once before it gets nominated, once after - but that doesn't 
seem like a huge problem. Obviously we ought to build one Glorious 
Unified Sausage Machine for nightlies which pre-flights 'em via OpenQA 
then does the nomination if that passes, but for now this is fine, I 
think.
-- 
Adam Williamson
Fedora QA Community Monkey
IRC: adamw | Twitter: AdamW_Fedora | XMPP: adamw AT happyassassin . net
http://www.happyassassin.net
From d211b7ed4a284688f37152bad2f5bd7fbfd77813 Mon Sep 17 00:00:00 2001
From: Adam Williamson <awill...@redhat.com>
Date: Tue, 17 Feb 2015 23:24:08 -0800
Subject: [PATCH] add an 'all' mode to try and run against everything we can

---
 tools/openqa_trigger/openqa_trigger.py | 135 +++++++++++++++++++++------------
 1 file changed, 86 insertions(+), 49 deletions(-)

diff --git a/tools/openqa_trigger/openqa_trigger.py b/tools/openqa_trigger/openqa_trigger.py
index 9a43b6c..4f43ed4 100755
--- a/tools/openqa_trigger/openqa_trigger.py
+++ b/tools/openqa_trigger/openqa_trigger.py
@@ -8,6 +8,7 @@ import os.path
 import sys
 import subprocess
 import argparse
+import datetime
 # We can at least find images and run OpenQA jobs without wikitcms
 try:
     import wikitcms.wiki
@@ -77,12 +78,15 @@ def run_openqa_jobs(isoname, arch, image_version):
     else:
         return []
 
-# run OpenQA on current compose if it is newer version since last run
-def run_current(args, wiki):
+def jobs_from_current(wiki):
+    """Schedule jobs against the 'current' release validation event
+    (according to wikitcms) if we have not already. Returns a tuple,
+    first value is the job list, second is the current event.
+    """
     if not wiki:
-        sys.exit("python-wikitcms is required for --current. Try "
-                 "--compose to run against today's Rawhide nightly "
-                 "without wiki result submission.")
+        print("python-wikitcms is required for current validation event "
+              "discovery.")
+        return ([], None)
     last_versions, json_parsed = read_last()
     currev = wiki.current_event
     print("Current event: {0}".format(currev.version))
@@ -101,14 +105,49 @@ def run_current(args, wiki):
     f.write(json.dumps(json_parsed))
     f.close()
 
+    return (jobs, currev)
+
+def jobs_from_fedfind(ff_release, arches=VERSIONS):
+    """Given a fedfind.Release object, find the ISOs we want and run
+    jobs on them. arches is an iterable of arches to run on, if not
+    specified, we'll use our constant.
+    """
+    # Find boot.iso images for our arches; third query is a bit of a
+    # bodge till I know what 22 TCs/RCs will actually look like,
+    # ideally we want a query that will reliably return one image per
+    # arch without us having to filter further, but we can always just
+    # take the first image for each arch if necessary
+    jobs = []
+    queries = (
+        fedfind.release.Query('imagetype', ('boot',)),
+        fedfind.release.Query('arch', arches),
+        fedfind.release.Query('payload', ('server', 'generic')))
+
+    for image in ff_release.find_images(queries):
+        print("{0} {1}".format(image.url, image.desc))
+        isoname = download_image(image)
+        version = '_'.join(
+            (ff_release.release, ff_release.milestone, ff_release.compose))
+        job_ids = run_openqa_jobs(isoname, image.arch, version)
+        jobs.extend(job_ids)
+    return jobs
+
+## SUB-COMMAND FUNCTIONS
+
+def run_current(args, wiki):
+    """run OpenQA for current release validation event, if we have
+    not already done it.
+    """
+    jobs = jobs_from_current(wiki)[0]
     # wait for jobs to finish and display results
-    print jobs
-    report_results(jobs)
+    if jobs:
+        print jobs
+        report_results(jobs)
     sys.exit()
 
 def run_compose(args, wiki=None):
     """run OpenQA on a specified compose, optionally reporting results
-    if a matching wikitcms ValidationEvent can be found.
+    if a matching wikitcms ValidationEvent is found by relval/wikitcms
     """
     # get the fedfind release object
     try:
@@ -118,26 +157,6 @@ def run_compose(args, wiki=None):
     except ValueError as err:
         sys.exit(err[0])
 
-    if args.submit_results:
-        try:
-            # sanity check, there's...some voodoo in here. but this isn't
-            # really strictly necessary, and we don't use the event object
-            # for anything.
-            event = wiki.get_validation_event(
-                release=ff_release.release, milestone=ff_release.milestone,
-                compose=ff_release.compose)
-            evff = event.ff_release
-            if evff.version != ff_release.version:
-                print("Release validation event's fedfind object does not "
-                      "match the one from fedfind's get_release(). Something's"
-                      " wrong somewhere. Result submission disabled.")
-                args.submit_results = False
-        except ValueError:
-            print("Warning: could not find validation test event for this "
-                  "compose. Continuing with OpenQA jobs, but results will "
-                  " not be submitted to the wiki.")
-            args.submit_results = False
-
     print("Running on compose: {0}".format(ff_release.version))
     if args.arch:
         jobs = jobs_from_fedfind(ff_release, [args.arch])
@@ -148,30 +167,40 @@ def run_compose(args, wiki=None):
         report_results(jobs)
     sys.exit()
 
-def jobs_from_fedfind(ff_release, arches=VERSIONS):
-    """Given a fedfind.Release object, find the ISOs we want and run
-    jobs on them. arches is an iterable of arches to run on, if not
-    specified, we'll use our constant.
+def run_all(args, wiki=None):
+    """Do everything we can: test both Rawhide and Branched nightlies
+    if they exist, and test current compose if it's different from
+    either and it's new.
     """
-    # Find boot.iso images for our arches; third query is a bit of a
-    # bodge till I know what 22 TCs/RCs will actually look like,
-    # ideally we want a query that will reliably return one image per
-    # arch without us having to filter further, but we can always just
-    # take the first image for each arch if necessary
     jobs = []
-    queries = (
-        fedfind.release.Query('imagetype', ('boot',)),
-        fedfind.release.Query('arch', arches),
-        fedfind.release.Query('payload', ('server', 'generic')))
+    skip = None
+    (currjobs, currev) = jobs_from_current(wiki)
+    print("Jobs from current validation event: {0}".format(currjobs))
+    jobs.extend(currjobs)
 
-    for image in ff_release.find_images(queries):
-        print("{0} {1}".format(image.url, image.desc))
-        isoname = download_image(image)
-        version = '_'.join(
-            (ff_release.release, ff_release.milestone, ff_release.compose))
-        job_ids = run_openqa_jobs(isoname, image.arch, version)
-        jobs.extend(job_ids)
-    return jobs
+    utcdate = datetime.datetime.utcnow()
+    day = datetime.timedelta(days=1)
+    utcdate = utcdate - day
+    if currev and currev.compose == utcdate.strftime('%Y%m%d'):
+        skip = currev.milestone
+
+    if not skip.lower() == 'rawhide':
+        rawhide_ffrel = fedfind.release.get_release(
+            release='Rawhide', compose=utcdate)
+        rawjobs = jobs_from_fedfind(rawhide_ffrel)
+        print("Jobs from {0}: {1}".format(rawhide_ffrel.version, rawjobs))
+        jobs.extend(rawjobs)
+
+    if not skip.lower() == 'branched':
+        branched_ffrel = fedfind.release.get_release(
+            release=currev.release, compose=utcdate)
+        branchjobs = jobs_from_fedfind(branched_ffrel)
+        print("Jobs from {0}: {1}".format(branched_ffrel.version, branchjobs))
+        jobs.extend(branchjobs)
+
+    if jobs:
+        report_results(jobs)
+    sys.exit()
 
 if __name__ == "__main__":
     test_help = "Operate on the staging wiki (for testing)"
@@ -213,6 +242,14 @@ if __name__ == "__main__":
         '-t', '--test', help=test_help, required=False, action='store_true')
     parser_compose.set_defaults(func=run_compose)
 
+    parser_all = subparsers.add_parser(
+        'all', description="Run for the current validation event (if needed) "
+        "and today's Rawhide and Branched nightly's (if found).")
+    parser_all.add_argument(
+        '-t', '--test', help=test_help, required=False, action='store_true')
+    parser_current.set_defaults(func=run_current)
+    parser_all.set_defaults(func=run_all)
+
     args = parser.parse_args()
 
     wiki = None
-- 
2.3.0

_______________________________________________
qa-devel mailing list
qa-devel@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/qa-devel

Reply via email to