Merge lp:~bigkevmcd/offspring/dont-duplicate-automated-builds into lp:offspring

Proposed by Kevin McDermott
Status: Work in progress
Proposed branch: lp:~bigkevmcd/offspring/dont-duplicate-automated-builds
Merge into: lp:offspring
Diff against target: 59 lines (+26/-4)
2 files modified
lib/offspring/master/tests/test_utils.py (+18/-0)
lib/offspring/master/utils.py (+8/-4)
To merge this branch: bzr merge lp:~bigkevmcd/offspring/dont-duplicate-automated-builds
Reviewer Review Type Date Requested Status
Cody A.W. Somerville design/architecture Needs Fixing
Review via email: mp+139706@code.launchpad.net

Description of the change

This is a fix for the nightly builds, that prevents duplicate builds when the project is already in a DailyBuildOrder.

If the project is active, and is a DailyBuildOrder project, then it will not be picked up by the build_active_projects functionality.

To post a comment you must log in.
Revision history for this message
Cody A.W. Somerville (cody-somerville) wrote :

The is_active attribute is more or less been re-purposed to be "Build Nightly" per front-end UI (ie. We show projects on main page if active OR project has daily build order PLUS the edit page in front-end has a label 'Build Nightly?').

The nightly build functionality was not intended to be conflated with daily build orders. The original purpose of this feature was to have projects build a second time so that both NA and APAC region employees would have a fresh build to work with at the start of the work day. Projects that did not want the NA build would toggle the is_active flag (this is why we modified the active project listing to also show projects with a DBO).

So yes, I agree there is a problem for sure. However, I feel like this implementation only extends how deep this rabbit hole goes. I would recommend an alternative implementation such as finishing the refactoring of is_active OR getting rid of that attribute all together and using JUST daily build orders. In the very least, IMHO, this patchset needs to address the UX issue.

review: Needs Fixing (design/architecture)

Unmerged revisions

155. By Kevin McDermott

Fix for this issue.

154. By Kevin McDermott

Failing test for this.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/offspring/master/tests/test_utils.py'
--- lib/offspring/master/tests/test_utils.py 2012-06-12 14:32:48 +0000
+++ lib/offspring/master/tests/test_utils.py 2012-12-13 13:56:46 +0000
@@ -104,6 +104,24 @@
104 self.assertEqual(self.project, build_request.project)104 self.assertEqual(self.project, build_request.project)
105 self.assertEqual(u"Nightly build", build_request.reason)105 self.assertEqual(u"Nightly build", build_request.reason)
106106
107 def test_build_active_projects_with_daily_build_order(self):
108 """
109 In order not to build the same projects twice, if a Project has a
110 BuildOrder, then it shouldn't be built during the daily active build
111 cron run.
112 """
113 self.assertEqual(0, self.db_store.find(BuildRequest).count())
114 current_hour = datetime.now(tz.tzlocal()).hour
115 build_order = DailyBuildOrder(self.project.name, current_hour)
116 self.db_store.add(build_order)
117 build_order_project = DailyBuildOrderProject()
118 build_order_project.dailybuildorder_id = build_order.id
119 build_order_project.project_id = self.project.name
120 self.db_store.add(build_order_project)
121
122 build_active_projects(self.db_store)
123 self.assertEqual(0, self.db_store.find(BuildRequest).count())
124
107125
108class TestProcessPendingBuildOrders(BaseOffspringMasterTestCase):126class TestProcessPendingBuildOrders(BaseOffspringMasterTestCase):
109127
110128
=== modified file 'lib/offspring/master/utils.py'
--- lib/offspring/master/utils.py 2011-11-17 12:21:03 +0000
+++ lib/offspring/master/utils.py 2012-12-13 13:56:46 +0000
@@ -4,9 +4,10 @@
4from datetime import datetime4from datetime import datetime
55
6from storm import tz6from storm import tz
7from storm.locals import create_database, Store7from storm.locals import create_database, Store, Not
88
9from offspring.master.models import BuildRequest, DailyBuildOrder, Project9from offspring.master.models import (
10 BuildRequest, DailyBuildOrder, DailyBuildOrderProject, Project)
10from offspring.config import get_configuration11from offspring.config import get_configuration
1112
1213
@@ -16,8 +17,11 @@
16 config = get_configuration()17 config = get_configuration()
17 database = create_database(config.get("master", "db"))18 database = create_database(config.get("master", "db"))
18 db_store = Store(database)19 db_store = Store(database)
19 activeProjects = db_store.find(Project, Project.is_active == True)20 daily_build_orders = db_store.find(DailyBuildOrderProject)
20 for project in activeProjects:21 daily_build_projects = daily_build_orders.values(DailyBuildOrderProject.project_id)
22 active_projects = db_store.find(Project, Project.is_active == True,
23 Not(Project.name.is_in(daily_build_projects)))
24 for project in active_projects:
21 request = BuildRequest(project, project.priority, u"Nightly build")25 request = BuildRequest(project, project.priority, u"Nightly build")
22 db_store.add(request)26 db_store.add(request)
23 db_store.commit()27 db_store.commit()

Subscribers

People subscribed via source and target branches