Merge lp:~jelmer/launchpad/uploadprocessor-invalid-status-test into lp:launchpad

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Graham Binns
Approved revision: no longer in the source branch.
Merged at revision: 12083
Proposed branch: lp:~jelmer/launchpad/uploadprocessor-invalid-status-test
Merge into: lp:launchpad
Diff against target: 64 lines (+40/-3)
2 files modified
lib/lp/archiveuploader/tests/test_uploadprocessor.py (+38/-0)
lib/lp/archiveuploader/uploadprocessor.py (+2/-3)
To merge this branch: bzr merge lp:~jelmer/launchpad/uploadprocessor-invalid-status-test
Reviewer Review Type Date Requested Status
Graham Binns (community) code Approve
Review via email: mp+43622@code.launchpad.net

Commit message

[r=gmb][ui=none][bug=690074] Warn about builds with unexpected status in the archive uploader rather than moving them out of the way.

Description of the change

We've had some issues with the archive uploader moving builds out of its queue too soon. Those issues should be resolved now. This branch makes the archive uploader a bit more cautious and makes it warn (so an OOPS will be logged) about uploads with an unknown build status rather than simply moving their directory out of the way, from which it is much harder to recover.

To post a comment you must log in.
Revision history for this message
Graham Binns (gmb) wrote :

Hi Jelmer,

A couple of styling issues but they're both nitpicks. r=me with these changes.

30 + upload_dir = self.queueUpload("bar_1.0-1_binary",
31 + queue_entry=leaf_name)

Minor styling quibble. Arguments should start on the line after the opening paren.

39 + self.assertTrue(os.path.exists(
40 + os.path.join(self.incoming_folder, leaf_name)))

Same here (you can indent by two levels if necessary).

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/archiveuploader/tests/test_uploadprocessor.py'
2--- lib/lp/archiveuploader/tests/test_uploadprocessor.py 2010-11-26 16:27:12 +0000
3+++ lib/lp/archiveuploader/tests/test_uploadprocessor.py 2010-12-15 22:34:56 +0000
4@@ -2033,6 +2033,44 @@
5 self.assertIsNot(None, build.duration)
6 self.assertIsNot(None, build.upload_log)
7
8+ def testBuildWithInvalidStatus(self):
9+ # Builds with an invalid (non-UPLOADING) status should trigger
10+ # a warning but be left alone.
11+ upload_dir = self.queueUpload("bar_1.0-1")
12+ self.processUpload(self.uploadprocessor, upload_dir)
13+ source_pub = self.publishPackage('bar', '1.0-1')
14+ [build] = source_pub.createMissingBuilds()
15+
16+ # Move the source from the accepted queue.
17+ [queue_item] = self.breezy.getQueueItems(
18+ status=PackageUploadStatus.ACCEPTED,
19+ version="1.0-1", name="bar")
20+ queue_item.setDone()
21+
22+ build.buildqueue_record.markAsBuilding(self.factory.makeBuilder())
23+ build.status = BuildStatus.BUILDING
24+
25+ shutil.rmtree(upload_dir)
26+
27+ # Commit so the build cookie has the right ids.
28+ self.layer.txn.commit()
29+ leaf_name = build.getUploadDirLeaf(build.getBuildCookie())
30+ upload_dir = self.queueUpload(
31+ "bar_1.0-1_binary", queue_entry=leaf_name)
32+ self.options.context = 'buildd'
33+ self.options.builds = True
34+ last_stub_mail_count = len(stub.test_emails)
35+ self.uploadprocessor.processBuildUpload(
36+ self.incoming_folder, leaf_name)
37+ self.layer.txn.commit()
38+ # The build status is not changed
39+ self.assertTrue(
40+ os.path.exists(os.path.join(self.incoming_folder, leaf_name)))
41+ self.assertEquals(BuildStatus.BUILDING, build.status)
42+ self.assertLogContains(
43+ "Expected build status to be 'UPLOADING', was BUILDING. "
44+ "Ignoring.")
45+
46
47 class ParseBuildUploadLeafNameTests(TestCase):
48 """Tests for parse_build_upload_leaf_name."""
49
50=== modified file 'lib/lp/archiveuploader/uploadprocessor.py'
51--- lib/lp/archiveuploader/uploadprocessor.py 2010-11-24 15:29:49 +0000
52+++ lib/lp/archiveuploader/uploadprocessor.py 2010-12-15 22:34:56 +0000
53@@ -224,9 +224,8 @@
54 build = buildfarm_job.getSpecificJob()
55 if build.status != BuildStatus.UPLOADING:
56 self.log.warn(
57- "Expected build status to be 'UPLOADING', was %s. "
58- "Moving to failed.", build.status.name)
59- self.moveProcessedUpload(upload_path, "failed", logger)
60+ "Expected build status to be 'UPLOADING', was %s. Ignoring." %
61+ build.status.name)
62 return
63 self.log.debug("Build %s found" % build.id)
64 try: