#442 Add a configuration to add an optional suffix to the release of the rebuilt NVR
Merged 4 years ago by mprahl. Opened 4 years ago by mprahl.
mprahl/freshmaker optional-release-suffix  into  master

file modified
+6
@@ -31,3 +31,9 @@ 

          },

      }

  

+ 

+ Other

+ =====

+ 

+ * ``rebuilt_nvr_release_suffix`` - a suffix to add to the ``rebuilt_nvr``

+   release in addition to the timestamp. This defaults to an empty string.

file modified
+5
@@ -359,6 +359,11 @@ 

                      'the keys "groups" and "users" which have values that are lists. Any roles not '

                      'provided as keys, will contain defaut empty values.'

          },

+         'rebuilt_nvr_release_suffix': {

+             'type': str,

+             'default': '',

+             'desc': 'A suffix to add to the rebuilt_nvr release in addition to the timestamp.',

+         },

      }

  

      def __init__(self, conf_section_obj):

file modified
+2 -2
@@ -106,10 +106,10 @@ 

      """

      rebuilt_nvr = None

      if artifact_type == ArtifactType.IMAGE.value:

-         # Set release from XX.YY to XX.$timestamp

+         # Set release from XX.YY to XX.$timestamp$release_suffix

          parsed_nvr = koji.parse_NVR(nvr)

          r_version = parsed_nvr["release"].split(".")[0]

-         release = str(r_version) + "." + str(int(time.time()))

+         release = f"{r_version}.{int(time.time())}{conf.rebuilt_nvr_release_suffix}"

          rebuilt_nvr = "%s-%s-%s" % (parsed_nvr["name"], parsed_nvr["version"],

                                      release)

  

file modified
+17 -1
@@ -20,10 +20,26 @@ 

  #

  # Written by Jan Kaluza <jkaluza@redhat.com>

  

- from freshmaker.utils import sorted_by_nvr

+ from unittest.mock import patch

+ 

+ import pytest

+ 

+ from freshmaker import conf

+ from freshmaker.models import ArtifactType

+ from freshmaker.utils import get_rebuilt_nvr, sorted_by_nvr

  from tests import helpers

  

  

+ @pytest.mark.parametrize("rebuilt_nvr_release_suffix", ("", ".dev"))

+ @patch("freshmaker.utils.time.time", return_value=1572631468.1807485)

+ def test_get_rebuilt_nvr(mock_time, rebuilt_nvr_release_suffix):

+     nvr = "python-v3.6-201910221723"

+     expected = f"{nvr}.1572631468{rebuilt_nvr_release_suffix}"

+     with patch.object(conf, "rebuilt_nvr_release_suffix", new=rebuilt_nvr_release_suffix):

+         rebuilt_nvr = get_rebuilt_nvr(ArtifactType.IMAGE.value, nvr)

+     assert rebuilt_nvr == expected

+ 

+ 

  class TestSortedByNVR(helpers.FreshmakerTestCase):

  

      def test_simple_list(self):

This adds the rebuilt_nvr_release_suffix configuration which is useful to make the NVR unique in an environment where multiple Freshmaker instances are reacting to the same events and using the same build system.

This relates to FACTORY-5346.

rebased onto 36ec325

4 years ago

Pull-Request has been merged by mprahl

4 years ago