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

Proposed by Kevin McDermott on 2012-12-13
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 2012-12-13 Needs Fixing on 2012-12-13
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.

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 on 2012-12-13

Fix for this issue.

154. By Kevin McDermott on 2012-12-13

Failing test for this.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/offspring/master/tests/test_utils.py'
2--- lib/offspring/master/tests/test_utils.py 2012-06-12 14:32:48 +0000
3+++ lib/offspring/master/tests/test_utils.py 2012-12-13 13:56:46 +0000
4@@ -104,6 +104,24 @@
5 self.assertEqual(self.project, build_request.project)
6 self.assertEqual(u"Nightly build", build_request.reason)
7
8+ def test_build_active_projects_with_daily_build_order(self):
9+ """
10+ In order not to build the same projects twice, if a Project has a
11+ BuildOrder, then it shouldn't be built during the daily active build
12+ cron run.
13+ """
14+ self.assertEqual(0, self.db_store.find(BuildRequest).count())
15+ current_hour = datetime.now(tz.tzlocal()).hour
16+ build_order = DailyBuildOrder(self.project.name, current_hour)
17+ self.db_store.add(build_order)
18+ build_order_project = DailyBuildOrderProject()
19+ build_order_project.dailybuildorder_id = build_order.id
20+ build_order_project.project_id = self.project.name
21+ self.db_store.add(build_order_project)
22+
23+ build_active_projects(self.db_store)
24+ self.assertEqual(0, self.db_store.find(BuildRequest).count())
25+
26
27 class TestProcessPendingBuildOrders(BaseOffspringMasterTestCase):
28
29
30=== modified file 'lib/offspring/master/utils.py'
31--- lib/offspring/master/utils.py 2011-11-17 12:21:03 +0000
32+++ lib/offspring/master/utils.py 2012-12-13 13:56:46 +0000
33@@ -4,9 +4,10 @@
34 from datetime import datetime
35
36 from storm import tz
37-from storm.locals import create_database, Store
38+from storm.locals import create_database, Store, Not
39
40-from offspring.master.models import BuildRequest, DailyBuildOrder, Project
41+from offspring.master.models import (
42+ BuildRequest, DailyBuildOrder, DailyBuildOrderProject, Project)
43 from offspring.config import get_configuration
44
45
46@@ -16,8 +17,11 @@
47 config = get_configuration()
48 database = create_database(config.get("master", "db"))
49 db_store = Store(database)
50- activeProjects = db_store.find(Project, Project.is_active == True)
51- for project in activeProjects:
52+ daily_build_orders = db_store.find(DailyBuildOrderProject)
53+ daily_build_projects = daily_build_orders.values(DailyBuildOrderProject.project_id)
54+ active_projects = db_store.find(Project, Project.is_active == True,
55+ Not(Project.name.is_in(daily_build_projects)))
56+ for project in active_projects:
57 request = BuildRequest(project, project.priority, u"Nightly build")
58 db_store.add(request)
59 db_store.commit()

Subscribers

People subscribed via source and target branches