bodhi/controllers.py | 60 ++++++++++++---------
bodhi/metadata.py | 2
bodhi/model.py | 1
bodhi/tests/test_controllers.py | 110 +++++++++++++++++++++-------------------
4 files changed, 95 insertions(+), 78 deletions(-)
New commits:
commit 42a5e5b00ce96ef843773d75ab5e4a7f73e2b2a7
Author: Luke Macken <lmacken(a)redhat.com>
Date: Wed May 19 10:02:54 2010 -0400
Get the test suite running again after the recent admin_groups changes
diff --git a/bodhi/tests/test_controllers.py b/bodhi/tests/test_controllers.py
index 38748bb..06cfc61 100644
--- a/bodhi/tests/test_controllers.py
+++ b/bodhi/tests/test_controllers.py
@@ -1102,6 +1102,9 @@ class TestControllers(testutil.DBTest):
def test_admin_push(self):
session = login(username='admin', group='releng')
+ me = User.by_user_name('admin')
+ testers = Group(group_name='proventesters',
display_name='proventesters')
+ me.addGroup(testers)
create_release()
testutil.create_request('/updates/admin/push', headers=session)
assert '0 pending requests' in cherrypy.response.body[0]
@@ -1113,6 +1116,7 @@ class TestControllers(testutil.DBTest):
'notes' : 'Initial release of new package!',
'request' : 'stable'
}
+
self.save_update(params, session)
assert PackageUpdate.select().count() == 1
assert PackageUpdate.select()[0].request == 'stable'
@@ -1445,7 +1449,7 @@ class TestControllers(testutil.DBTest):
assert update.request == 'testing'
def test_push_critpath_to_frozen_release_and_request_stable_as_releng(self):
- session = login(group='releng')
+ session = login(group='proventesters')
create_release(locked=True)
params = {
'builds' : 'kernel-2.6.31-1.fc7',
@@ -1505,7 +1509,7 @@ class TestControllers(testutil.DBTest):
Ensure releng/qa can push critpath updates to stable for pending releases
after 1 releng/qa karma, and 1 other karma
"""
- releng = login(group='releng')
+ releng = login(group='proventesters')
create_release(locked=True)
params = {
'builds' : 'kernel-2.6.31-1.fc7',
@@ -1651,7 +1655,7 @@ class TestControllers(testutil.DBTest):
"""
Ensure admins can submit critpath updates for pending releases to stable.
"""
- session = login(group='qa')
+ session = login(group='proventesters')
create_release(locked=True)
params = {
'builds' : 'kernel-2.6.31-1.fc7',
commit 1c04192e417bbef916801efb0f5d6b6e714329b3
Author: Luke Macken <lmacken(a)redhat.com>
Date: Wed May 19 09:43:25 2010 -0400
Auto-obsoletion improvements. Ensure the same packages are present in the
obsoletable update
diff --git a/bodhi/controllers.py b/bodhi/controllers.py
index a9a9f55..8877b9f 100644
--- a/bodhi/controllers.py
+++ b/bodhi/controllers.py
@@ -771,11 +771,7 @@ class Root(controllers.RootController):
# all updates are safe to obsolete, or else just skip it.
for oldBuild in package.builds:
obsoletable = False
- print "Potentially obsoleting %s with %s" % (oldBuild.nvr,
build)
- print oldBuild
- print oldBuild.updates
for update in oldBuild.updates:
- print update
if update.status not in ('pending', 'testing') or \
update.request or \
update.release not in buildinfo[build]['releases'] or \
@@ -783,10 +779,17 @@ class Root(controllers.RootController):
(edited and oldBuild in edited.builds):
obsoletable = False
break
+ # Ensure the same number of builds are present
+ if len(update.builds) != len(releases[update.release]):
+ obsoletable = False
+ break
# Ensure that all of the packages in the old update are
- # present in the new one. If not, don't obsolete it but
- # make sure the developer knows that the update exists
- #for build in builds:
+ # present in the new one.
+ pkgs = [get_nvr(b)[0] for b in releases[update.release]]
+ for build in update.builds:
+ 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
commit b996fd012d4374dae57258001c08c4dfb9f71173
Author: Luke Macken <lmacken(a)redhat.com>
Date: Wed May 19 09:33:33 2010 -0400
Remove a duplicate log message
diff --git a/bodhi/model.py b/bodhi/model.py
index 6fdbbd3..3577352 100644
--- a/bodhi/model.py
+++ b/bodhi/model.py
@@ -786,7 +786,6 @@ class PackageUpdate(SQLObject):
task = koji.moveBuild(curtag, newtag, build.nvr, force=True)
tasks.append(task)
if tasks:
- log.debug('Waiting for %s tasks to complete...' % tasks)
if buildsys.wait_for_tasks(tasks, sleep=1):
log.error('One or more tasks failed!')
else:
commit d678dbb9293714b6b945b01c66df0f181aa2f91f
Author: Luke Macken <lmacken(a)redhat.com>
Date: Wed May 19 09:23:24 2010 -0400
Re-enable our auto-obsoletion code, and expand the test suite a bit
diff --git a/bodhi/controllers.py b/bodhi/controllers.py
index e9cb30a..a9a9f55 100644
--- a/bodhi/controllers.py
+++ b/bodhi/controllers.py
@@ -769,32 +769,37 @@ class Root(controllers.RootController):
# Obsolete any older pending/testing updates.
# If a build is associated with multiple updates, make sure that
# all updates are safe to obsolete, or else just skip it.
- #for oldBuild in package.builds:
- # obsoletable = False
- # for update in oldBuild.updates:
- # if update.status not in ('pending', 'testing') or \
- # update.request or \
- # update.release not in buildinfo[build]['releases'] or \
- # update in pkgBuild.updates or \
- # (edited and oldBuild in edited.builds):
- # obsoletable = False
- # break
-# TODO:
-# ensure that all of the packages in the old update are present in the new one
-# compare length of builds, and match them.
- # if rpm.labelCompare(util.get_nvr(oldBuild.nvr), nvr) < 0:
- # log.debug("%s is obsoletable" % oldBuild.nvr)
- # obsoletable = True
- # if obsoletable:
- # for update in oldBuild.updates:
- # # Have the newer update inherit the older updates bugs
- # for bug in update.bugs:
- # bugs.append(unicode(bug.bz_id))
- # # Also inherit the older updates notes as well
- # notes += '\n' + update.notes
- # update.obsolete(newer=build)
- # note.append('This update has obsoleted %s, and has '
- # 'inherited its bugs and notes.' % oldBuild.nvr)
+ for oldBuild in package.builds:
+ obsoletable = False
+ print "Potentially obsoleting %s with %s" % (oldBuild.nvr,
build)
+ print oldBuild
+ print oldBuild.updates
+ for update in oldBuild.updates:
+ print update
+ if update.status not in ('pending', 'testing') or \
+ update.request or \
+ update.release not in buildinfo[build]['releases'] or \
+ update in pkgBuild.updates or \
+ (edited and oldBuild in edited.builds):
+ obsoletable = False
+ break
+ # Ensure that all of the packages in the old update are
+ # present in the new one. If not, don't obsolete it but
+ # make sure the developer knows that the update exists
+ #for build in builds:
+ if rpm.labelCompare(util.get_nvr(oldBuild.nvr), nvr) < 0:
+ log.debug("%s is obsoletable" % oldBuild.nvr)
+ obsoletable = True
+ if obsoletable:
+ for update in oldBuild.updates:
+ # Have the newer update inherit the older updates bugs
+ for bug in update.bugs:
+ bugs.append(unicode(bug.bz_id))
+ # Also inherit the older updates notes as well
+ notes += '\n' + update.notes
+ update.obsolete(newer=build)
+ note.append('This update has obsoleted %s, and has '
+ 'inherited its bugs and notes.' % oldBuild.nvr)
# Create or modify the necessary PackageUpdate objects
for release, builds in releases.items():
diff --git a/bodhi/tests/test_controllers.py b/bodhi/tests/test_controllers.py
index c39a38e..38748bb 100644
--- a/bodhi/tests/test_controllers.py
+++ b/bodhi/tests/test_controllers.py
@@ -770,78 +770,84 @@ class TestControllers(testutil.DBTest):
self.save_update(params, session)
assert "This resource resides temporarily" in
cherrypy.response.body[0], cherrypy.response.body[0]
- #def test_obsoleting(self):
- # session = login()
- # create_release()
- # params = {
- # 'builds' : 'TurboGears-1.0.2.2-2.fc7',
- # 'release' : 'Fedora 7',
- # 'type_' : 'enhancement',
- # 'bugs' : '1234',
- # 'cves' : 'CVE-2020-0001',
- # 'notes' : 'foobar',
- # 'request' : None
- # }
- # self.save_update(params, session)
- # print cherrypy.response.body[0]
- # assert "This resource resides temporarily at <a
href='http://localhost/updates/TurboGears-1.0.2.2-2.fc7'>http://localhost/updates/TurboGears-1.0.2.2-2.fc7</a>"
in cherrypy.response.body[0]
- # update = PackageUpdate.byTitle(params['builds'])
- # assert update.status == 'pending'
-
- # # Throw a newer build in, which should obsolete the previous
- # newparams = {
- # 'builds' : 'TurboGears-1.0.2.2-3.fc7',
- # 'release' : 'Fedora 7',
- # 'type_' : 'enhancement',
- # 'bugs' : '4321',
- # 'cves' : 'CVE-2020-0001',
- # 'notes' : 'bizbaz'
- # }
- # self.save_update(newparams, session)
- # newupdate = PackageUpdate.byTitle(newparams['builds'])
- # assert newupdate.status == 'pending'
- # update = PackageUpdate.byTitle(params['builds'])
- # assert update.status == 'obsolete'
-
- # # The newer build should also inherit the obsolete updates bugs
- # bugz = [bug.bz_id for bug in newupdate.bugs]
- # assert 1234 in bugz and 4321 in bugz
-
- # # The newer update should also inherit the obsolete updates notes
- # assert newupdate.notes == "%s\n%s" % (newparams['notes'],
params['notes'])
-
- def test_obsoleting_request(self):
+ def test_obsoleting(self):
session = login()
create_release()
params = {
'builds' : 'TurboGears-1.0.2.2-2.fc7',
'release' : 'Fedora 7',
- 'type_' : 'enhancement',
+ 'type_' : 'enhancement',
'bugs' : '1234',
'cves' : 'CVE-2020-0001',
- 'notes' : 'foobar'
+ 'notes' : 'foobar',
+ 'request' : None
}
self.save_update(params, session)
+ print cherrypy.response.body[0]
assert "This resource resides temporarily at <a
href='http://localhost/updates/TurboGears-1.0.2.2-2.fc7'>http://localhost/updates/TurboGears-1.0.2.2-2.fc7</a>"
in cherrypy.response.body[0]
update = PackageUpdate.byTitle(params['builds'])
assert update.status == 'pending'
- assert update.request == 'testing'
- # Throw a newer build in, which should *NOT* obsolete the previous,
- # since it has an active request
+ # Throw a newer build in, which should obsolete the previous
newparams = {
'builds' : 'TurboGears-1.0.2.2-3.fc7',
'release' : 'Fedora 7',
'type_' : 'enhancement',
'bugs' : '4321',
'cves' : 'CVE-2020-0001',
- 'notes' : 'foobar'
+ 'notes' : 'bizbaz'
}
self.save_update(newparams, session)
newupdate = PackageUpdate.byTitle(newparams['builds'])
assert newupdate.status == 'pending'
update = PackageUpdate.byTitle(params['builds'])
+ assert update.status == 'obsolete'
+
+ # The newer build should also inherit the obsolete updates bugs
+ bugz = [bug.bz_id for bug in newupdate.bugs]
+ assert 1234 in bugz and 4321 in bugz
+
+ # The newer update should also inherit the obsolete updates notes
+ assert newupdate.notes == "%s\n%s" % (newparams['notes'],
params['notes'])
+
+ def test_obsoleting_multibuild_update(self):
+ """ Ensure that a new update cannot obsolete an older update that
+ contains this new build along with others """
+ session = login()
+ create_release()
+ params = {
+ 'builds' : 'TurboGears-1.0.2.2-2.fc7
python-sqlalchemy-0.5-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) == 2
+ 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' : 'python-sqlalchemy-0.5.1-1.fc7',
+ 'release' : 'Fedora 7',
+ 'type_' : 'enhancement',
+ 'bugs' : '',
+ 'cves' : '',
+ 'notes' : ''
+ }
+ self.save_update(newparams, session)
+ newupdate = PackageUpdate.byTitle(newparams['builds'])
+ assert newupdate.status == 'pending'
+ assert newupdate.notes == ''
+ update =
PackageUpdate.byTitle(','.join(params['builds'].split()))
+ assert update.status == 'testing', update.status
def test_list(self):
"""
commit 700dcff3be5aa2104449e5d61226d913a7a63b99
Author: Luke Macken <lmacken(a)redhat.com>
Date: Tue Mar 16 06:23:23 2010 -0400
Set the epoch to 0 instead of None if it doesn't exist
diff --git a/bodhi/metadata.py b/bodhi/metadata.py
index 0401344..b996e71 100644
--- a/bodhi/metadata.py
+++ b/bodhi/metadata.py
@@ -256,7 +256,7 @@ class ExtendedMetadata:
'name' : rpm['name'],
'version' : rpm['version'],
'release' : rpm['release'],
- 'epoch' : rpm['epoch'],
+ 'epoch' : rpm['epoch'] or '0',
'arch' : rpm['arch'],
'src' : urlpath
})