#58 Allow scheduling of update jobs for any arch (#57)
Merged 6 years ago by adamwill. Opened 6 years ago by adamwill.

file modified
+3 -1
@@ -75,7 +75,7 @@ 

      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 @@ 

          "--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)

file modified
+10 -7
@@ -274,7 +274,7 @@ 

  

      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 @@ 

      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 @@ 

          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)

file modified
+9
@@ -492,4 +492,13 @@ 

      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:

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

I successfully tested this PR for ppc64/ppc64le arches

rebased onto 56e9b0a

6 years ago

Pull-Request has been merged by adamwill

6 years ago