From 56e9b0a9f3b1006478a63c77200d6686aa46765d Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Oct 20 2017 19:08:43 +0000 Subject: Allow scheduling of update jobs for any arch (#57) Rather than hardcoding x86_64. I thought of ways to have the method schedule jobs for multiple arches in one call, but in the end didn't really like any of them, this should be much simpler. I don't think there'll be a significant performance difference either as ultimately there has to be one POST request per arch/flavor combination - we can't send a POST that creates jobs for more than one arch at a time. Fixes: #57 --- diff --git a/fedora_openqa/cli.py b/fedora_openqa/cli.py index e7f4f34..8af9bae 100644 --- a/fedora_openqa/cli.py +++ b/fedora_openqa/cli.py @@ -75,7 +75,7 @@ def command_update(args): if args.flavor: flavors = [args.flavor] jobs = schedule.jobs_from_update(args.update, args.release, flavors=flavors, force=args.force, - openqa_hostname=args.openqa_hostname) + openqa_hostname=args.openqa_hostname, arch=args.arch) print("Scheduled jobs: {0}".format(', '.join((str(job) for job in jobs)))) sys.exit() @@ -171,6 +171,8 @@ def parse_args(args=None): "--openqa-hostname", help="openQA host to schedule jobs on (default: client library " "default)", metavar='HOSTNAME') parser_update.add_argument( + '--arch', '-a', help="Arch to schedule jobs for (default: x86_64)", metavar='ARCH') + parser_update.add_argument( '--force', '-f', help="For each flavor, schedule jobs even if there " "are existing, non-cancelled jobs for the update for that flavor", action='store_true') parser_update.set_defaults(func=command_update) diff --git a/fedora_openqa/schedule.py b/fedora_openqa/schedule.py index 2c8b2fc..70f8b3d 100644 --- a/fedora_openqa/schedule.py +++ b/fedora_openqa/schedule.py @@ -274,7 +274,7 @@ def jobs_from_compose(location, wanted=None, force=False, extraparams=None, open return (rel.cid, jobs) -def jobs_from_update(update, version, flavors=None, force=False, extraparams=None, openqa_hostname=None): +def jobs_from_update(update, version, flavors=None, force=False, extraparams=None, openqa_hostname=None, arch=None): """Schedule jobs for a specific Fedora update. update is the advisory ID, version is the release number, flavors defines which update tests should be run (valid values are the 'flavdict' keys). @@ -300,22 +300,25 @@ def jobs_from_update(update, version, flavors=None, force=False, extraparams=Non here. """ version = str(version) + if not arch: + # set a default in a way that works neatly with the CLI bits + arch = 'x86_64' build = 'Update-{0}'.format(update) if extraparams: build = '{0}-EXTRA'.format(build) flavdict = { 'server': { - 'HDD_1': 'disk_f{0}_server_3_x86_64.img'.format(version), + 'HDD_1': 'disk_f{0}_server_3_{1}.img'.format(version, arch), }, 'workstation': { - 'HDD_1': 'disk_f{0}_desktop_3_x86_64.img'.format(version), + 'HDD_1': 'disk_f{0}_desktop_3_{1}.img'.format(version, arch), 'DESKTOP': 'gnome', }, } baseparams = { 'DISTRI': 'fedora', 'VERSION': version, - 'ARCH': 'x86_64', + 'ARCH': arch, 'BUILD': build, 'ADVISORY': update, # this disables the openQA logic that cancels all running jobs @@ -342,11 +345,11 @@ def jobs_from_update(update, version, flavors=None, force=False, extraparams=Non fullflav = 'updates-{0}'.format(flavor) if not force: # dupe check - currjobs = client.openqa_request('GET', 'jobs', params={'build': build})['jobs'] + currjobs = client.openqa_request('GET', 'jobs', params={'build': build, 'arch': arch})['jobs'] currjobs = [cjob for cjob in currjobs if cjob['settings']['FLAVOR'] == fullflav] if currjobs: - logger.info("jobs_from_update: Existing jobs found for update %s flavor %s, and force " - "not set! No jobs scheduled.", update, flavor) + logger.info("jobs_from_update: Existing jobs found for update %s flavor %s arch %s, " + "and force not set! No jobs scheduled.", update, flavor, arch) continue flavparams = flavdict[flavor] flavparams.update(baseparams) diff --git a/tests/test_schedule.py b/tests/test_schedule.py index 1b0109d..f4c3e45 100644 --- a/tests/test_schedule.py +++ b/tests/test_schedule.py @@ -492,4 +492,13 @@ def test_jobs_from_update(fakeclient, fakecurr): ret = schedule.jobs_from_update('FEDORA-2017-b07d628952', '25', openqa_hostname='openqa.example') assert fakeclient.call_args[0][0] == 'openqa.example' + # test arch + fakeinst.openqa_request.reset_mock() + ret = schedule.jobs_from_update('FEDORA-2017-b07d628952', '25', arch='ppc64le') + # find the POST calls + posts = [call for call in fakeinst.openqa_request.call_args_list if call[0][0] == 'POST'] + # check parm dict values + assert posts[0][0][2]['ARCH'] == 'ppc64le' + assert posts[0][0][2]['HDD_1'] in ['disk_f25_server_3_ppc64le.img', 'disk_f25_desktop_3_ppc64le.img'] + # vim: set textwidth=120 ts=8 et sw=4: