From 0ef26df33ac8688a6ca410f51482dbc6c863ca74 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Dec 05 2015 21:07:39 +0000 Subject: add URLs for failed openQA tests, allow specifying base URL This is slightly messy, but the best I can come up with; I was gonna have the code catch when the openQA server is 'localhost' and try to determine the real base URL from openqa.ini but that's pretty rinky-dink. Ideally openQA's API would actually include a URL for the test in the results, but it doesn't, I may look into adding that. --- diff --git a/check-compose b/check-compose index 993a949..cf733ca 100755 --- a/check-compose +++ b/check-compose @@ -48,6 +48,7 @@ CONFIG.set('main', 'smtp', 'localhost') CONFIG.set('main', 'json', '') CONFIG.set('main', 'loglevel', 'info') CONFIG.set('main', 'server', '') +CONFIG.set('main', 'url', '') CONFIG.read('/etc/check-compose.conf') CONFIG.read('{0}/.config/check-compose.conf'.format(os.path.expanduser('~'))) @@ -73,6 +74,13 @@ def parse_args(): "defaults to localhost", default=CONFIG.get('main', 'server'), metavar="openqa.example.com", required=False) parser.add_argument( + '-u', '--url', help="Base URL for linking to openQA results. If not " + "set, will be the openQA client base URL. Set this when the hostname " + "the script connects to is *not* the same hostname someone reading " + "the report would use to access the server - e.g. if the script is " + "connecting to 'localhost'", default=CONFIG.get('main', 'url'), + metavar="https://openqa.example.com", required=False) + parser.add_argument( '-r', '--release', help="The Fedora release to check", type=_release, required=False, metavar="1-99 or Rawhide") parser.add_argument( @@ -140,7 +148,7 @@ def check(args): # Get the raw reports. (text, jsondict) = generate_reports( - rel, prevrel=prevrel, wait=args.wait, server=args.server) + rel, prevrel=prevrel, wait=args.wait, server=args.server, url=args.url) # Send the email. if args.email_from: @@ -193,7 +201,7 @@ def _image_desc(tup): tup = (tup[0], tup[1], tup[3]) return ' '.join(tup).capitalize() -def generate_reports(rel, prevrel=None, wait=0, server=''): +def generate_reports(rel, prevrel=None, wait=0, server='', url=''): """Generate compose report for a given fedfind Release. If prevrel is passed (as another fedfind Release), do the compose diff against it; otherwise try and diff against the fedfind-discovered @@ -261,6 +269,8 @@ def generate_reports(rel, prevrel=None, wait=0, server=''): if OpenQA_Client: client = OpenQA_Client(server=server) + if not url: + url = client.baseurl build = '_'.join((rel.release, rel.milestone, rel.compose)) try: jobs = client.wait_build_jobs(build, waittime=wait) @@ -295,6 +305,7 @@ def generate_reports(rel, prevrel=None, wait=0, server=''): if 'UEFI' in settings: testname += "@uefi" text += "\nID: {0}\tTest: {1}".format(fail['id'], testname) + text += "\nURL: {0}{1}{2}".format(url, "/tests/", fail['id']) if passes: text += "\n\nPassed openQA tests: {0} of {1}".format(str(len(passes)), str(len(jobs))) others = len(jobs) - (len(passes) + len(fails)) diff --git a/check-compose.conf.sample b/check-compose.conf.sample index 6fa5850..04e8a55 100644 --- a/check-compose.conf.sample +++ b/check-compose.conf.sample @@ -8,6 +8,12 @@ # Default: not set (openqa-client config will be used, defaults to localhost) server: openqa.example.com +# Base URL for linking to openQA results. Set this when the hostname the script +# connects to is *not* the same hostname someone reading the report would use +# to access the server - e.g. if the script is connecting to 'localhost' +# Default: Whatever the openQA client connects to +url: https://openqa.pub.example.com + # How long (in minutes) to wait for compose to appear and openQA jobs to finish # Default: 480 wait: 360