bodhi/controllers.py | 7 +++--- bodhi/tests/test_controllers.py | 43 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 3 deletions(-)
New commits: commit ff01dda83f5ab9a7ab1949a4d1a8988db6e32ee5 Author: Luke Macken lmacken@redhat.com Date: Tue Oct 25 16:42:27 2011 -0400
Fix a bug in our auto-obsoletion code (#617)
This bug occurs when a multibuild update contains the same number of packages as a previous update, but with a different package.
diff --git a/bodhi/controllers.py b/bodhi/controllers.py index 36155c0..c9bd3a9 100644 --- a/bodhi/controllers.py +++ b/bodhi/controllers.py @@ -945,6 +945,9 @@ class Root(controllers.RootController): (edited and oldBuild in edited.builds): obsoletable = False break + if rpm.labelCompare(util.get_nvr(oldBuild.nvr), nvr) < 0: + log.debug("%s is newer than %s" % (nvr, oldBuild.nvr)) + obsoletable = True # Ensure the same number of builds are present if len(update.builds) != len(releases[update.release]): obsoletable = False @@ -956,10 +959,8 @@ class Root(controllers.RootController): if _build.package.name not in pkgs: obsoletable = False break - if rpm.labelCompare(util.get_nvr(oldBuild.nvr), nvr) < 0: - log.debug("%s is obsoletable" % oldBuild.nvr) - obsoletable = True if obsoletable: + log.info('%s is obsoletable' % oldBuild.nvr) for update in oldBuild.updates: # Have the newer update inherit the older updates bugs for bug in update.bugs: diff --git a/bodhi/tests/test_controllers.py b/bodhi/tests/test_controllers.py index d6dcdfc..cf2b241 100644 --- a/bodhi/tests/test_controllers.py +++ b/bodhi/tests/test_controllers.py @@ -975,6 +975,49 @@ class TestControllers(testutil.DBTest): update = PackageUpdate.byTitle(','.join(params['builds'].split())) assert update.status == 'testing', update.status
+ def test_obsoleting_update_with_different_packages(self): + """ Ensure that a new update cannot obsolete an older update that + contains a different package """ + session = login() + create_release() + params = { + 'builds' : 'TurboGears-1.0.2.2-2.fc7 python-sqlalchemy-0.5.0-1.fc7 nethack-1.0-1.fc7', + 'release' : 'Fedora 7', + 'type_' : 'enhancement', + 'bugs' : '1234', + 'cves' : 'CVE-2020-0001', + 'notes' : 'foobar', + 'request' : None + } + self.save_update(params, session) + update = PackageUpdate.byTitle(','.join(params['builds'].split())) + assert update.status == 'pending' + assert len(update.builds) == 3 + assert len(update.builds[0].updates) == 1 + update.status = 'testing' + update.pushed = True + update.date_pushed = datetime.now() + + # Throw a newer build in, which should *NOT* obsolete the previous + newparams = { + 'builds' : 'TurboGears-1.0.3.2-2.fc7 python-sqlalchemy-0.6.0-1.fc7 kernel-3.0-1.fc7', + 'release' : 'Fedora 7', + 'type_' : 'enhancement', + 'bugs' : '', + 'cves' : '', + 'notes' : 'foo' + } + #testutil.capture_log(['bodhi.model', 'bodhi.controllers', 'bodhi.admin', 'bodhi.masher', 'bodhi.util']) + self.save_update(newparams, session) + #assert False, testutil.get_log() + newupdate = PackageUpdate.byTitle(','.join(newparams['builds'].split())) + assert newupdate.status == 'pending' + assert newupdate.notes == 'foo', newupdate.notes + + # Ensure the original update is still in tact + update = PackageUpdate.byTitle(','.join(params['builds'].split())) + assert update.status == 'testing', update.status + def test_list(self): """ This unittest verifies various aspects of the generic list controller