From d73b12433dd13073229bec2be55838a3402293a6 Mon Sep 17 00:00:00 2001 From: Kamil Páral Date: May 25 2018 13:46:03 +0000 Subject: support running per architecture Instead of running on all supported architectures in a single run, support running on a specific chosen architecture that is passed in as taskotron_arch. The former approach is still available, if you pass 'noarch' as architecture. --- diff --git a/download_rpms.py b/download_rpms.py index 8e0d18b..9effc8b 100755 --- a/download_rpms.py +++ b/download_rpms.py @@ -11,10 +11,8 @@ log = logging.getLogger('task-abicheck.download') log.setLevel(logging.DEBUG) log.addHandler(logging.NullHandler()) - -def download_rpms(koji_build, stable_rpmsdir, update_rpmsdir, - arch=['x86_64', 'i386', 'armv7hl', 'ppc64le', 'ppc64', - 'aarch64'], arch_exclude=['noarch'], debuginfo=True): +def download_rpms(koji_build, arches, stable_rpmsdir, update_rpmsdir, + arch_exclude=['noarch'], debuginfo=True, src=False): '''Download RPMs needed for the test run, i.e. the tested build and the latest stable build.''' @@ -23,9 +21,10 @@ def download_rpms(koji_build, stable_rpmsdir, update_rpmsdir, log.info('Downloading latest stable rpms for %s into %s' % (koji_build, stable_rpmsdir)) params = {'action': 'download_latest_stable', 'koji_build': koji_build, - 'arch': arch, + 'arch': arches, 'arch_exclude': arch_exclude, 'debuginfo': debuginfo, + 'src': src, 'target_dir': stable_rpmsdir, } arg_data = {'workdir': None} @@ -35,9 +34,10 @@ def download_rpms(koji_build, stable_rpmsdir, update_rpmsdir, update_rpmsdir)) params = {'action': 'download', 'koji_build': koji_build, - 'arch': arch, + 'arch': arches, 'arch_exclude': arch_exclude, 'debuginfo': debuginfo, + 'src': src, 'target_dir': update_rpmsdir, } koji.process(params, arg_data) @@ -48,19 +48,8 @@ def download_rpms(koji_build, stable_rpmsdir, update_rpmsdir, if __name__ == '__main__': logging.basicConfig() logging.getLogger('libtaskotron').setLevel(logging.DEBUG) + log.debug('Executing script: %s', sys.argv) - log.debug('Running script: %s' % sys.argv) - args = {} - - # arch is supposed to be a comma delimited string, but optional - arches = sys.argv[4] if len(sys.argv) >= 5 else '' - arches = [arch.strip() for arch in arches.split(',')] - if arches: - log.debug('Detected arches: %s' % arches) - args['arch'] = arches - - download_rpms(koji_build=sys.argv[1], - stable_rpmsdir=sys.argv[2], - update_rpmsdir=sys.argv[3], - **args - ) + arches = sys.argv[2].split(',') + download_rpms(koji_build=sys.argv[1], arches=arches, + stable_rpmsdir=sys.argv[3], update_rpmsdir=sys.argv[4]) diff --git a/run_abipkgdiff.py b/run_abipkgdiff.py index 9b738d0..7e11bcb 100755 --- a/run_abipkgdiff.py +++ b/run_abipkgdiff.py @@ -10,6 +10,7 @@ import logging from rpmUtils.miscutils import splitFilename from libtaskotron import check +from libtaskotron import arch_utils log = logging.getLogger('task-abicheck') log.setLevel(logging.DEBUG) @@ -20,26 +21,42 @@ def enum(**enums): return type('Enum', (), enums) -def run_abipkgdiff(koji_build, stable_rpmsdir, update_rpmsdir, - artifactsdir='artifacts', testcase='dist.abicheck', - arches=('x86_64', 'i686', 'armv7hl', 'ppc64le', 'ppc64', 'aarch64')): +def run_abipkgdiff(koji_build, arches, stable_rpmsdir, update_rpmsdir, + artifactsdir='artifacts', testcase='dist.abicheck'): process_start_time = time.time() log_path = os.path.join(artifactsdir, '%s.log' % koji_build) detail = check.CheckDetail(item=koji_build, report_type=check.ReportType.KOJI_BUILD, checkname=testcase, artifact=log_path) + detail.keyvals['arch'] = list(arches) + + # we work with binary arches on the filesystem level + binary_arches = [] + for arch in arches: + if arch in arch_utils.Arches.base: + binary_arches.extend(arch_utils.Arches.binary[arch]) + else: + log.warn("Unknown architecture '%s', using anyway...", arch) + binary_arches.append(arch) - # If no arch specific packages are avilable set ABI result as PASSED if ((len(os.listdir(stable_rpmsdir)) == 0) and (len(os.listdir( update_rpmsdir)) == 0)): detail.output.append("No architecture specific packages are available\n"); detail.update_outcome("PASSED") + detail.note = 'no binary files' + elif sorted(os.listdir(stable_rpmsdir)) == sorted(os.listdir(update_rpmsdir)): + detail.output.append('No previous stable build was found for %s\n' % + koji_build) + detail.update_outcome('PASSED') + detail.note = 'no previous stable build' + # TODO: figure this out before we actually download two exactly same + # builds, that just wastes time and bandwidth else: - detail.output.append("ABI changes report summary for package update id %s" - " against latest stable package in koji\n" % koji_build) + detail.output.append('ABI changes between build %s and its latest ' + 'stable build\n' % koji_build) - padding = str('=' * 103) + padding = str('=' * 80) detail.output.append("%s\n\n" % padding) detail.output.append("This file contains possible ABI changes which have occurred" " due to this package update against latest stable build available" @@ -48,7 +65,7 @@ def run_abipkgdiff(koji_build, stable_rpmsdir, update_rpmsdir, " you can add a proper .abignore file to this package. To know more" " about how to write one, please look at the wiki page" " https://fedoraproject.org/wiki/Taskotron/Tasks/dist.abicheck#filtering .\n\n") - for arch in arches: + for arch in binary_arches: test_arch(arch, stable_rpmsdir, update_rpmsdir, detail) # Save logs @@ -128,7 +145,7 @@ def test_arch(arch, stable_rpmsdir, update_rpmsdir, detail): if not ((len(update_rpms_detail) == 0) and (len(stable_rpms_detail) == 0)): detail.output.append("On %s architecture\n" % arch) - padding = str('-' * 25) + padding = str('*' * 25) detail.output.append("%s\n\n" % padding) # We are looking for packages which might contain public header files in @@ -188,34 +205,31 @@ def test_arch(arch, stable_rpmsdir, update_rpmsdir, detail): # Check for abipkgdiff exit status # No ABI change or error when exit status is ABIDIFF_OK whose value is 0 if proc.returncode == abipkgdiff_status.ABIDIFF_OK: - detail.output.append("* No ABI change between %s " - "and %s. ABI comparison took %s." - "\n\n" % (stable_rpm['rpm'], - update_rpm['rpm'], - formatted_time(abipkgdiff_time_taken))) + detail.output.append("* No ABI change between:\n%s\n" + "%s\nABI comparison took %s.\n\n" % + (stable_rpm['rpm'], update_rpm['rpm'], + formatted_time(abipkgdiff_time_taken))) else: # If ABIDIFF_USAGE_ERROR is set to true then ABIDIFF_ERROR # also set to true. So, check for ABIDIFF_ERROR only if # ABIDIFF_USAGE_ERROR not set to true if proc.returncode & abipkgdiff_status.ABIDIFF_USAGE_ERROR: - detail.output.append("* Insufficient arguments to command" - " abipkgdiff: %s\n" % (' '.join(command))) + detail.output.append("* Insufficient arguments to " + "command abipkgdiff: %s\n" % (' '.join(command))) result = 'FAILED' elif proc.returncode & abipkgdiff_status.ABIDIFF_ERROR: detail.output.append("* Following error encountered" - " while running command %s :" - "\n%s\n" % (' '.join(command), - stderr)) + " while running command %s :\n%s\n" % + (' '.join(command), stderr)) result = 'FAILED' # Compared ABI are different and may be incompatible if proc.returncode & abipkgdiff_status.ABIDIFF_ABI_INCOMPATIBLE_CHANGE: - detail.output.append("* Incompatible ABI changes between" - " %s and %s. ABI comparison took" - " %s. Please review them.\n\n" - % (stable_rpm['rpm'], - update_rpm['rpm'], - formatted_time(abipkgdiff_time_taken))) + detail.output.append("* Incompatible ABI changes " + 'between:\n%s\n%s\nABI comparison took %s. ' + 'Please review them.\n\n' % (stable_rpm['rpm'], + update_rpm['rpm'], + formatted_time(abipkgdiff_time_taken))) detail.output.append(stdout) result = 'FAILED' # If exit status of abipkgdiff has ABIDIFF_ABI_INCOMPATIBLE_CHANGE (8) @@ -224,12 +238,10 @@ def test_arch(arch, stable_rpmsdir, update_rpmsdir, detail): # But check for ABIDIFF_ABI_CHANGE value if # ABIDIFF_ABI_INCOMPATIBLE_CHANGE is not set to true. elif proc.returncode & abipkgdiff_status.ABIDIFF_ABI_CHANGE: - detail.output.append("* ABI changes found between" - " %s and %s. ABI comparison took" - " %s. Please review them.\n\n" - % (stable_rpm['rpm'], - update_rpm['rpm'], - formatted_time(abipkgdiff_time_taken))) + detail.output.append("* ABI changes found between:\n" + "%s\n%s\nABI comparison took %s. Please review " + "them.\n\n" % (stable_rpm['rpm'], update_rpm['rpm'], + formatted_time(abipkgdiff_time_taken))) detail.output.append(stdout) if result != 'FAILED': result = 'NEEDS_INSPECTION' @@ -314,12 +326,15 @@ def get_right_header_package_for_rpm(header_pkgs, pkg): if __name__ == '__main__': logging.basicConfig() logging.getLogger('libtaskotron').setLevel(logging.DEBUG) + log.debug('Executing script: %s', sys.argv) log.info('Running abipkgdiff...') + arches = sys.argv[2].split(',') rc = run_abipkgdiff(koji_build=sys.argv[1], - stable_rpmsdir=sys.argv[2], - update_rpmsdir=sys.argv[3], - artifactsdir=sys.argv[4], - testcase=sys.argv[5]) + arches=arches, + stable_rpmsdir=sys.argv[3], + update_rpmsdir=sys.argv[4], + artifactsdir=sys.argv[5], + testcase=sys.argv[6]) log.info('Abipkgdiff execution complete. Exiting with exit code %d' % rc) sys.exit(rc) diff --git a/tests.yml b/tests.yml index 3fe104a..2a7d67b 100644 --- a/tests.yml +++ b/tests.yml @@ -9,6 +9,7 @@ taskotron_keepalive_minutes: 20 # below are fallback vars for local testing artifacts: ./artifacts + taskotron_arch: noarch taskotron_supported_arches: - x86_64 tasks: @@ -50,25 +51,30 @@ debug: var: workdir.path - - name: Compute architectures to download + - name: Compute architectures to test set_fact: - download_arches: "{{ taskotron_supported_arches | join(',') }}" + # if 'noarch' is specified, test everything supported + test_arches: "{{ (taskotron_arch == 'noarch') + | ternary(taskotron_supported_arches, [taskotron_arch]) }}" - - name: Print architectures to download + - name: Print architectures to test debug: - var: download_arches + var: test_arches - block: - name: Download RPMs from Koji shell: > - ./download_rpms.py {{ taskotron_item }} {{ workdir.path }}/stable - {{ workdir.path }}/update {{ download_arches }} + ./download_rpms.py {{ taskotron_item }} + {{ test_arches | join(',') }} + {{ workdir.path }}/stable {{ workdir.path }}/update &> {{ artifacts }}/test.log - name: Run abicheck shell: > - ./run_abipkgdiff.py {{ taskotron_item }} {{ workdir.path }}/stable - {{ workdir.path }}/update {{ artifacts }} {{ testcase }} + ./run_abipkgdiff.py {{ taskotron_item }} + {{ test_arches | join(',') }} + {{ workdir.path }}/stable {{ workdir.path }}/update + {{ artifacts }} {{ testcase }} &>> {{ artifacts }}/test.log always: - name: Print results location