Merge lp:~rockstar/launchpad/upgrade-branch-rc into lp:launchpad/db-devel

Proposed by Paul Hummer
Status: Merged
Merged at revision: not available
Proposed branch: lp:~rockstar/launchpad/upgrade-branch-rc
Merge into: lp:launchpad/db-devel
Diff against target: 102 lines (+26/-1)
5 files modified
database/schema/security.cfg (+1/-1)
lib/lp/code/model/branch.py (+5/-0)
lib/lp/code/model/branchjob.py (+2/-0)
lib/lp/code/model/tests/test_branch.py (+15/-0)
lib/lp/code/model/tests/test_branchjob.py (+3/-0)
To merge this branch: bzr merge lp:~rockstar/launchpad/upgrade-branch-rc
Reviewer Review Type Date Requested Status
Gary Poster (community) rc Approve
Tim Penhey (community) Approve
Review via email: mp+18049@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Paul Hummer (rockstar) wrote :

Hi-

  This branch fixes two release-critical issues with the branch upgrade job
stuff. The first issue is that IBranch.upgrade_pending didn't check to see if
the upgrade had failed or was finished. In those cases, it should return
false. The other issue is that the BranchUpgradeJob wasn't triggering a mirror
after it got upgraded, so the branch still thought it needed upgrading.

  The patch is the tests for those fixes and then the fixes.

Cheers,
Paul

Revision history for this message
Tim Penhey (thumper) wrote :

Looks OK to me.

review: Approve
Revision history for this message
Gary Poster (gary) :
review: Approve (rc)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'database/schema/security.cfg'
--- database/schema/security.cfg 2010-01-22 22:25:30 +0000
+++ database/schema/security.cfg 2010-01-26 02:27:13 +0000
@@ -1716,7 +1716,7 @@
1716[upgrade-branches]1716[upgrade-branches]
1717type=user1717type=user
1718groups=script1718groups=script
1719public.branch = SELECT1719public.branch = SELECT, UPDATE
1720public.branchjob = SELECT1720public.branchjob = SELECT
1721public.job = SELECT, UPDATE1721public.job = SELECT, UPDATE
17221722
17231723
=== modified file 'lib/lp/code/model/branch.py'
--- lib/lp/code/model/branch.py 2010-01-22 06:03:19 +0000
+++ lib/lp/code/model/branch.py 2010-01-26 02:27:13 +0000
@@ -74,6 +74,8 @@
74 IFindOfficialBranchLinks)74 IFindOfficialBranchLinks)
75from lp.registry.interfaces.person import (75from lp.registry.interfaces.person import (
76 validate_person_not_private_membership, validate_public_person)76 validate_person_not_private_membership, validate_public_person)
77from lp.services.job.interfaces.job import JobStatus
78from lp.services.job.model.job import Job
77from lp.services.mail.notificationrecipientset import (79from lp.services.mail.notificationrecipientset import (
78 NotificationRecipientSet)80 NotificationRecipientSet)
7981
@@ -1012,6 +1014,9 @@
1012 jobs = store.find(1014 jobs = store.find(
1013 BranchJob,1015 BranchJob,
1014 BranchJob.branch == self,1016 BranchJob.branch == self,
1017 Job.id == BranchJob.jobID,
1018 Job._status != JobStatus.COMPLETED,
1019 Job._status != JobStatus.FAILED,
1015 BranchJob.job_type == BranchJobType.UPGRADE_BRANCH)1020 BranchJob.job_type == BranchJobType.UPGRADE_BRANCH)
1016 return jobs.count() > 01021 return jobs.count() > 0
10171022
10181023
=== modified file 'lib/lp/code/model/branchjob.py'
--- lib/lp/code/model/branchjob.py 2010-01-26 01:20:54 +0000
+++ lib/lp/code/model/branchjob.py 2010-01-26 02:27:13 +0000
@@ -343,6 +343,8 @@
343 upgrade_transport.delete_tree('backup.bzr')343 upgrade_transport.delete_tree('backup.bzr')
344 source_branch_transport.rename('.bzr', 'backup.bzr')344 source_branch_transport.rename('.bzr', 'backup.bzr')
345 upgrade_transport.copy_tree_to_transport(source_branch_transport)345 upgrade_transport.copy_tree_to_transport(source_branch_transport)
346
347 self.branch.requestMirror()
346 finally:348 finally:
347 shutil.rmtree(upgrade_branch_path)349 shutil.rmtree(upgrade_branch_path)
348350
349351
=== modified file 'lib/lp/code/model/tests/test_branch.py'
--- lib/lp/code/model/tests/test_branch.py 2010-01-22 06:03:19 +0000
+++ lib/lp/code/model/tests/test_branch.py 2010-01-26 02:27:13 +0000
@@ -65,6 +65,7 @@
65from lp.registry.model.product import ProductSet65from lp.registry.model.product import ProductSet
66from lp.registry.model.sourcepackage import SourcePackage66from lp.registry.model.sourcepackage import SourcePackage
67from lp.registry.interfaces.pocket import PackagePublishingPocket67from lp.registry.interfaces.pocket import PackagePublishingPocket
68from lp.services.job.interfaces.job import JobStatus
68from lp.testing import (69from lp.testing import (
69 run_with_login, TestCase, TestCaseWithFactory, time_counter)70 run_with_login, TestCase, TestCaseWithFactory, time_counter)
70from lp.testing.factory import LaunchpadObjectFactory71from lp.testing.factory import LaunchpadObjectFactory
@@ -443,6 +444,20 @@
443444
444 self.assertFalse(branch.upgrade_pending)445 self.assertFalse(branch.upgrade_pending)
445446
447 def test_upgradePending_old_job_exists(self):
448 # If the branch had an upgrade pending, but then the job was completed,
449 # then upgrade_pending should return False.
450 branch = self.factory.makeAnyBranch(
451 branch_format=BranchFormat.BZR_BRANCH_6)
452 owner = removeSecurityProxy(branch).owner
453 login_person(owner)
454 self.addCleanup(logout)
455 branch_job = removeSecurityProxy(branch.requestUpgrade())
456 branch_job.job.start()
457 branch_job.job.complete()
458
459 self.assertFalse(branch.upgrade_pending)
460
446461
447class TestBzrIdentity(TestCaseWithFactory):462class TestBzrIdentity(TestCaseWithFactory):
448 """Test IBranch.bzr_identity."""463 """Test IBranch.bzr_identity."""
449464
=== modified file 'lib/lp/code/model/tests/test_branchjob.py'
--- lib/lp/code/model/tests/test_branchjob.py 2010-01-22 06:03:19 +0000
+++ lib/lp/code/model/tests/test_branchjob.py 2010-01-26 02:27:13 +0000
@@ -8,6 +8,7 @@
8import datetime8import datetime
9import os9import os
10import shutil10import shutil
11from storm.locals import Store
11import tempfile12import tempfile
12from unittest import TestLoader13from unittest import TestLoader
1314
@@ -263,6 +264,8 @@
263 new_branch.repository._format.get_format_string(),264 new_branch.repository._format.get_format_string(),
264 'Bazaar repository format 2a (needs bzr 1.16 or later)\n')265 'Bazaar repository format 2a (needs bzr 1.16 or later)\n')
265266
267 self.assertTrue(db_branch.pending_writes)
268
266 def test_needs_no_upgrading(self):269 def test_needs_no_upgrading(self):
267 # Branch upgrade job creation should raise an AssertionError if the270 # Branch upgrade job creation should raise an AssertionError if the
268 # branch does not need to be upgraded.271 # branch does not need to be upgraded.

Subscribers

People subscribed via source and target branches

to status/vote changes: