From 034fc2c2833d64d30b5c2f6803eadeef71b373e7 Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Aug 08 2018 17:01:42 +0000 Subject: [PATCH 1/3] Adjust waiver-matching logic to handle koji/brew type mismatches. These are supported elsewhere in the code. --- diff --git a/greenwave/policies.py b/greenwave/policies.py index 2bfd272..b98d3b4 100644 --- a/greenwave/policies.py +++ b/greenwave/policies.py @@ -402,11 +402,14 @@ class PassingTestCaseRule(Rule): if result['outcome'] in ['PASSED', 'INFO']: return TestResultPassed(self.test_case_name, result['id']) - # XXX limit who is allowed to waive - if any(w['subject'] == dict([(key, value[0]) - for key, value in result['data'].items()]) and - w['testcase'] == result['testcase']['name'] and - w['waived'] for w in waivers): + # TODO limit who is allowed to waive + + matching_waivers = [w for w in waivers if ( + w['subject_type'] == subject_type and + w['subject_identifier'] == result['data']['item'][0] and + w['testcase'] == result['testcase']['name'] + )] + if matching_waivers: return TestResultPassed(self.test_case_name, result['id']) return TestResultFailed(subject_type, subject_identifier, self.test_case_name, self.scenario, result['id']) diff --git a/greenwave/tests/test_policies.py b/greenwave/tests/test_policies.py index e0c93eb..b8af2ec 100644 --- a/greenwave/tests/test_policies.py +++ b/greenwave/tests/test_policies.py @@ -68,6 +68,53 @@ rules: assert isinstance(decision[0], RuleSatisfied) +def test_waive_brew_koji_mismatch(tmpdir): + """ Ensure that a koji_build waiver can match a brew-build result + + Note that 'brew-build' in the result does not match 'koji_build' in the + waiver. Even though these are different strings, this should work. + """ + + p = tmpdir.join('fedora.yaml') + p.write(""" +--- !Policy +id: some_id +product_versions: +- irrelevant +decision_context: test +subject_type: koji_build +rules: + - !PassingTestCaseRule {test_case_name: sometest} + """) + policies = load_policies(tmpdir.strpath) + policy = policies[0] + + result = { + u'data': { + u'item': [u'some_nevr'], + u'type': [u'brew-build'], + }, + u'id': 6336180, + u'outcome': u'FAILED', + u'testcase': {u'name': u'sometest'}, + } + waiver = { + u'subject_identifier': u'some_nevr', + u'subject_type': u'koji_build', + u'testcase': u'sometest', + u'waived': True, + } + + item, results, waivers = 'some_nevr', [result], [waiver] + decision = policy.check(item, results, []) + assert len(decision) == 1 + assert isinstance(decision[0], TestResultFailed) + + decision = policy.check(item, results, waivers) + assert len(decision) == 1 + assert isinstance(decision[0], RuleSatisfied) + + def test_package_specific_rule(tmpdir): p = tmpdir.join('fedora.yaml') p.write(""" @@ -92,7 +139,10 @@ rules: # That a matching, failing result can fail results = [{ 'id': 123, - 'item': 'nethack-1.2.3-1.el9000', + 'data': { + 'item': 'nethack-1.2.3-1.el9000', + 'type': 'koji_build', + }, 'testcase': {'name': 'sometest'}, 'outcome': 'FAILED', }] @@ -103,7 +153,10 @@ rules: # That a matching, passing result can pass results = [{ 'id': 123, - 'item': 'nethack-1.2.3-1.el9000', + 'data': { + 'item': 'nethack-1.2.3-1.el9000', + 'type': 'koji_build', + }, 'testcase': {'name': 'sometest'}, 'outcome': 'PASSED', }] @@ -142,7 +195,10 @@ rules: # Ensure that fnmatch globs work in the negative. results = [{ 'id': 123, - 'item': 'nethack-1.2.3-1.el9000', + 'data': { + 'item': 'nethack-1.2.3-1.el9000', + 'type': 'koji_build', + }, 'testcase': {'name': 'sometest'}, 'outcome': 'FAILED', }] @@ -153,7 +209,10 @@ rules: # Ensure that fnmatch globs work in the positive. results = [{ 'id': 123, - 'item': 'nethack-1.2.3-1.el9000', + 'data': { + 'item': 'nethack-1.2.3-1.el9000', + 'type': 'koji_build', + }, 'testcase': {'name': 'sometest'}, 'outcome': 'SUCCESS', }] From f3d499f9009df0df4e8b6a814ddcad984ede8c47 Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Aug 08 2018 17:06:01 +0000 Subject: [PATCH 2/3] 0.9.4 release notes. --- diff --git a/docs/release-notes.rst b/docs/release-notes.rst index 57983ae..ba41c2a 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -2,6 +2,14 @@ Release Notes ============= +Greenwave 0.9.4 +=============== + +Released 08 August 2018 + +* Fixed a bug in waiver processing that failed to + match koji_build waivers with brew-build results. + Greenwave 0.9.3 =============== @@ -88,7 +96,7 @@ Released 3 July 2018. ``RemoteRule``. See :ref:`remote-rule` (#220). * The documentation now includes a section targeted at package maintainers to - explain how they can define package-specific policies (#222). See + explain how they can define package-specific policies (#222). See :doc:`package-specific-policies`. * Policy attribute ``id`` is now optional in :file:`gating.yaml` (#217). @@ -96,11 +104,11 @@ Released 3 July 2018. * Policy attribute ``blacklist`` is now optional. * In case a package's :file:`gating.yaml` file is invalid or malformed, - Greenwave will now return an unsatisfied decision with an unsatisfied - requirement of type ``invalid-gating-yaml``. This can be waived in order to - allow a package to proceed through a gating point in spite of the invalid - :file:`gating.yaml` file. Previously, Greenwave would return a 500 error - response and it was not possible to waive the invalid :file:`gating.yaml` + Greenwave will now return an unsatisfied decision with an unsatisfied + requirement of type ``invalid-gating-yaml``. This can be waived in order to + allow a package to proceed through a gating point in spite of the invalid + :file:`gating.yaml` file. Previously, Greenwave would return a 500 error + response and it was not possible to waive the invalid :file:`gating.yaml` file. (#221) * Settings ``greenwave_cache`` for fedmsg was dropped in favor of ``CACHE`` From eaf07f634ab9778e8d7a1ecac67a94c3b1cf8ba7 Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Aug 08 2018 17:06:04 +0000 Subject: [PATCH 3/3] Automatic commit of release 0.9.4 --- diff --git a/greenwave.spec b/greenwave.spec index 28a9b3a..aef2204 100644 --- a/greenwave.spec +++ b/greenwave.spec @@ -1,8 +1,8 @@ -%global upstream_version 0.9.3 +%global upstream_version 0.9.4 Name: greenwave -Version: 0.9.3 +Version: 0.9.4 Release: 1%{?dist} Summary: Service for gating on automated tests License: GPLv2+ diff --git a/greenwave/__init__.py b/greenwave/__init__.py index e535637..7f15a62 100644 --- a/greenwave/__init__.py +++ b/greenwave/__init__.py @@ -8,4 +8,4 @@ It provides a :ref:`http-api` for applications to use. .. _Flask: http://flask.pocoo.org/ .. _SQLAlchemy: http://sqlalchemy.org/ """ -__version__ = '0.9.3' +__version__ = '0.9.4'