#277 Adjust waiver-matching logic to handle koji/brew type mismatches.
Merged 5 years ago by ralph. Opened 5 years ago by ralph.

file modified
+14 -6
@@ -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 @@ 

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

  * 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``

file modified
+2 -2
@@ -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+

file modified
+1 -1
@@ -8,4 +8,4 @@ 

  .. _Flask: http://flask.pocoo.org/

  .. _SQLAlchemy: http://sqlalchemy.org/

  """

- __version__ = '0.9.3'

+ __version__ = '0.9.4'

file modified
+8 -5
@@ -402,11 +402,14 @@ 

          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'])

@@ -68,6 +68,53 @@ 

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

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

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

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

      # 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',

      }]

These are supported elsewhere in the code.

2 new commits added

  • Automatic commit of release 0.9.4
  • 0.9.4 release notes.
5 years ago

:thumbsup: Looks good!

Pull-Request has been merged by ralph

5 years ago