From 65513afd1ac41e846224b3921d111d198d374b4c Mon Sep 17 00:00:00 2001 From: Jan Kaluza Date: Thu, 5 Apr 2018 10:42:56 +0200 Subject: [PATCH] Share the same in the dist tag between all MSE builds. --- module_build_service/utils/general.py | 9 ++++++++- tests/test_utils/test_utils.py | 11 ++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/module_build_service/utils/general.py b/module_build_service/utils/general.py index ce96ff1a..5e06c514 100644 --- a/module_build_service/utils/general.py +++ b/module_build_service/utils/general.py @@ -178,9 +178,16 @@ def get_rpm_release(module_build): dist_str = '.'.join([module_build.name, module_build.stream, str(module_build.version), str(module_build.context)]).encode('utf-8') dist_hash = hashlib.sha1(dist_str).hexdigest()[:8] + + # We need to share the same auto-incrementing index in dist tag between all MSE builds. + # We can achieve that by using the lowest build ID of all the MSE siblings including + # this module build. + mse_build_ids = module_build.siblings + [module_build.id or 0] + mse_build_ids.sort() + index = mse_build_ids[0] return "{prefix}{index}+{dist_hash}".format( prefix=conf.default_dist_tag_prefix, - index=module_build.id or 0, + index=index, dist_hash=dist_hash, ) diff --git a/tests/test_utils/test_utils.py b/tests/test_utils/test_utils.py index ad33537e..fcf136ef 100644 --- a/tests/test_utils/test_utils.py +++ b/tests/test_utils/test_utils.py @@ -29,7 +29,7 @@ import module_build_service.scm from module_build_service import models, conf from module_build_service.errors import ProgrammingError, ValidationError, UnprocessableEntity from tests import ( - reuse_component_init_data, db, reuse_shared_userspace_init_data, clean_database) + reuse_component_init_data, db, reuse_shared_userspace_init_data, clean_database, init_data) import mock import koji import pytest @@ -239,6 +239,15 @@ class TestUtils: def teardown_method(self, test_method): clean_database() + def test_get_rpm_release_mse(self): + init_data(contexts=True) + build_one = models.ModuleBuild.query.get(2) + build_two = models.ModuleBuild.query.get(3) + release_one = module_build_service.utils.get_rpm_release(build_one) + release_two = module_build_service.utils.get_rpm_release(build_two) + assert release_one == "module+2+b8645bbb" + assert release_two == "module+2+17e35784" + @pytest.mark.parametrize('scmurl', [ ('git://pkgs.stg.fedoraproject.org/modules/testmodule.git' '?#620ec77321b2ea7b0d67d82992dda3e1d67055b4'),