← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~wgrant/launchpad/bug-1160461 into lp:launchpad

 

William Grant has proposed merging lp:~wgrant/launchpad/bug-1160461 into lp:launchpad.

Commit message:
Fix BuildView.eta to handle suspended jobs, fixing a crash on SourcePackageRecipe:+index when there's a pending binary build in a disabled archive.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1160461 in Launchpad itself: "Minetest stable recipe edit page is broken"
  https://bugs.launchpad.net/launchpad/+bug/1160461

For more details, see:
https://code.launchpad.net/~wgrant/launchpad/bug-1160461/+merge/155651

BuildView.eta doesn't handle the case where the job is suspended, causing SourcePackageRecipe:+index to crash when there's a pending binary build in a disabled PPA. Fix it to return None instead.
-- 
https://code.launchpad.net/~wgrant/launchpad/bug-1160461/+merge/155651
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/bug-1160461 into lp:launchpad.
=== modified file 'lib/lp/soyuz/browser/build.py'
--- lib/lp/soyuz/browser/build.py	2013-02-05 23:43:54 +0000
+++ lib/lp/soyuz/browser/build.py	2013-03-27 03:30:29 +0000
@@ -336,10 +336,10 @@
         queue_record = self.context.buildqueue_record
         if queue_record.job.status == JobStatus.WAITING:
             start_time = queue_record.getEstimatedJobStartTime()
-            if start_time is None:
-                return None
         else:
             start_time = queue_record.job.date_started
+        if start_time is None:
+            return None
         duration = queue_record.estimated_duration
         return start_time + duration
 

=== modified file 'lib/lp/soyuz/browser/tests/test_build_views.py'
--- lib/lp/soyuz/browser/tests/test_build_views.py	2013-01-24 05:50:23 +0000
+++ lib/lp/soyuz/browser/tests/test_build_views.py	2013-03-27 03:30:29 +0000
@@ -19,6 +19,7 @@
 from lp.registry.interfaces.person import IPersonSet
 from lp.registry.interfaces.pocket import PackagePublishingPocket
 from lp.registry.interfaces.series import SeriesStatus
+from lp.services.database.sqlbase import flush_database_caches
 from lp.services.job.interfaces.job import JobStatus
 from lp.services.webapp import canonical_url
 from lp.services.webapp.interfaces import StormRangeFactoryError
@@ -29,6 +30,7 @@
 from lp.soyuz.interfaces.packageset import IPackagesetSet
 from lp.soyuz.model.queue import PackageUploadBuild
 from lp.testing import (
+    admin_logged_in,
     person_logged_in,
     TestCaseWithFactory,
     )
@@ -426,3 +428,18 @@
                 'start': 75,
                 'memo': '["2012-01-01T01:01:01", 0]'})
         view.setupBuildList()
+
+    def test_eta(self):
+        # BuildView.eta returns a non-None value when it should, or None
+        # when there's no start time.
+        build = self.factory.makeBinaryPackageBuild()
+        build.queueBuild()
+        self.factory.makeBuilder(processor=build.processor, virtualized=True)
+        v = create_initialized_view(build, '+index')
+        self.assertIsNot(None, v.eta)
+        with admin_logged_in():
+            build.archive.disable()
+        flush_database_caches()
+        v = create_initialized_view(build, '+index')
+        self.assertIs(None, v.eta)
+