#307 Allow filtering images based on image_version and image_release.
Merged 11 months ago by jkaluza. Opened 11 months ago by jkaluza.
jkaluza/freshmaker image-filters  into  master

@@ -609,11 +609,15 @@ 

          :return: True when image should be filtered out.

          """

  

+         parsed_nvr = koji.parse_NVR(image["brew"]["build"])

          image_name = koji.parse_NVR(image["brew"]["build"])['name']

  

-         if not self.event.is_allowed(self, image_name=image_name):

+         if not self.event.is_allowed(

+                 self, image_name=parsed_nvr["name"],

+                 image_version=parsed_nvr["version"],

+                 image_release=parsed_nvr["release"]):

              self.log_info("Skipping rebuild of image %s, not allowed by "

-                           "configuration", image_name)

+                           "configuration", image["brew"]["build"])

              return True

          return False

  

@@ -27,6 +27,7 @@ 

  from mock import patch, PropertyMock, Mock, call

  

  from freshmaker import conf, db, events

+ from freshmaker.config import all_

  from freshmaker.errata import ErrataAdvisory

  from freshmaker.events import ErrataAdvisoryRPMsSignedEvent

  from freshmaker.events import ErrataAdvisoryStateChangedEvent

@@ -240,6 +241,54 @@ 

          ret = handler._filter_out_not_allowed_builds(image)

          self.assertEqual(ret, True)

  

+     @patch(

+         "freshmaker.config.Config.handler_build_whitelist",

+         new_callable=PropertyMock,

+         return_value={

+             "ErrataAdvisoryRPMsSignedHandler": {

+                 "image": {

+                     "image_name": ["foo", "bar"]

+                 }

+             }

+         })

+     @patch(

+         "freshmaker.config.Config.handler_build_blacklist",

+         new_callable=PropertyMock,

+         return_value={

+             "ErrataAdvisoryRPMsSignedHandler": {

+                 "image": all_(

+                     {

+                         "image_name": "foo",

+                         "image_version": "7.3",

+                     }

+                 )

+             }

+         })

+     def test_filter_out_not_allowed_builds_image_version(

+             self, handler_build_blacklist, handler_build_whitelist):

+         handler = ErrataAdvisoryRPMsSignedHandler()

+         handler.event = ErrataAdvisoryRPMsSignedEvent(

+             "123",

+             ErrataAdvisory(123, "RHSA-2017", "REL_PREP", [],

+                            security_impact="None",

+                            product_short_name="product"))

+ 

+         image = {"brew": {"build": "foo-1-2.3"}}

+         ret = handler._filter_out_not_allowed_builds(image)

+         self.assertEqual(ret, False)

+ 

+         image = {"brew": {"build": "foo-1-7.3"}}

+         ret = handler._filter_out_not_allowed_builds(image)

+         self.assertEqual(ret, False)

+ 

+         image = {"brew": {"build": "foo-7.3-2.3"}}

+         ret = handler._filter_out_not_allowed_builds(image)

+         self.assertEqual(ret, True)

+ 

+         image = {"brew": {"build": "unknown-1-2.3"}}

+         ret = handler._filter_out_not_allowed_builds(image)

+         self.assertEqual(ret, True)

+ 

  

  class TestBatches(helpers.ModelsTestCase):

      """Test handling of batches"""

We need to be able to stop building particular version of image in blacklist, but still build the others.

Commit 22ec361 fixes this pull-request

Pull-Request has been merged by jkaluza

11 months ago

Pull-Request has been merged by jkaluza

11 months ago