Merge lp:~milo/linaro-ci-dashboard/refactor-job-schedule into lp:linaro-ci-dashboard

Proposed by Milo Casagrande
Status: Merged
Approved by: Stevan Radaković
Approved revision: 31
Merged at revision: 29
Proposed branch: lp:~milo/linaro-ci-dashboard/refactor-job-schedule
Merge into: lp:linaro-ci-dashboard
Diff against target: 229 lines (+75/-21)
10 files modified
dashboard/frontend/android_build/models/android_loop.py (+0/-5)
dashboard/frontend/integration_loop/models/integration_loop.py (+0/-2)
dashboard/frontend/integration_loop/templates/integration_loop_detail.html (+1/-1)
dashboard/frontend/integration_loop/urls.py (+8/-4)
dashboard/frontend/integration_loop/views/integration_loop_build_view.py (+25/-0)
dashboard/frontend/kernel_build/models/kernel_loop.py (+1/-7)
dashboard/frontend/kernel_build/templates/kernel_loop_detail.html (+2/-2)
dashboard/frontend/kernel_build/urls.py (+4/-0)
dashboard/frontend/kernel_build/views/kernel_loop_build_view.py (+24/-0)
dashboard/frontend/models/loop.py (+10/-0)
To merge this branch: bzr merge lp:~milo/linaro-ci-dashboard/refactor-job-schedule
Reviewer Review Type Date Requested Status
Stevan Radaković code Approve
Linaro Infrastructure Pending
Review via email: mp+121197@code.launchpad.net

Description of the change

This, as briefly discussed on a previous merge proposal, is the refactoring of the loops in order for them to really call the correct "schedule_build" method.

Previously, the overridden "schedule_build" was not call, due to the fact that the build is scheduled through a view that was created against the Loop class, and not the actual subclass. The "schedule_build" was in fact called inside the LoopBuildView class as "self.object.schedule_build()", but "self.object" was always of type "Loop", calling only its method, and not the subclass one.

The solution is to create personalized "build views" for each loop, inheriting from LoopBuildView, defining also the correct URL path and removing the "schedule_build" from inside each subclass, as long as they do not need to specialize it.

The proposed merge fixes all these.

To post a comment you must log in.
Revision history for this message
Stevan Radaković (stevanr) wrote :

Tnx for taking care of this Milo.
Good code.
Approve +1

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'dashboard/frontend/android_build/models/android_loop.py'
2--- dashboard/frontend/android_build/models/android_loop.py 2012-08-24 13:00:02 +0000
3+++ dashboard/frontend/android_build/models/android_loop.py 2012-08-24 14:25:22 +0000
4@@ -55,8 +55,6 @@
5 DEFAULT_GCC = '4.4.0'
6 DEFAULT_IMAGE_SIZE = '2G'
7
8- EXCLUDE_LIST = ['id', 'name', 'server', 'loop_ptr']
9-
10 # BUILD_TYPE
11 build_type = models.CharField(max_length=100,
12 choices=ANDROID_BUILD_TYPES,
13@@ -127,8 +125,5 @@
14 pass
15
16 def schedule_build(self):
17- # Every time before the build is scheduled, update the
18- # loop config on the remote server.
19 parameters = {'parameter': [{'delay': '0'}]}
20- self.server.create_or_update_loop(self)
21 return super(self.__class__, self).schedule_build(parameters)
22
23=== modified file 'dashboard/frontend/integration_loop/models/integration_loop.py'
24--- dashboard/frontend/integration_loop/models/integration_loop.py 2012-08-24 13:00:02 +0000
25+++ dashboard/frontend/integration_loop/models/integration_loop.py 2012-08-24 14:25:22 +0000
26@@ -29,8 +29,6 @@
27 precommand = models.CharField(max_length=200)
28 command = models.CharField(max_length=200)
29
30- EXCLUDE_LIST = ['id', 'name', 'server', 'loop_ptr']
31-
32 def save(self, *args, **kwargs):
33 self.server = JenkinsServer.objects.get(id=1)
34 super(self.__class__, self).save(*args, **kwargs)
35
36=== modified file 'dashboard/frontend/integration_loop/templates/integration_loop_detail.html'
37--- dashboard/frontend/integration_loop/templates/integration_loop_detail.html 2012-08-23 08:45:39 +0000
38+++ dashboard/frontend/integration_loop/templates/integration_loop_detail.html 2012-08-24 14:25:22 +0000
39@@ -41,7 +41,7 @@
40 {% block scripts %}
41 <script type="text/javascript">
42 $("#schedule_button").click(function() {
43- $.get("{% if request.is_secure %}https{% else %}http{% endif %}://{{ request.get_host }}/loop/build/{{ integration_loop_detail.name }}/", function(data) {
44+ $.get("{% if request.is_secure %}https{% else %}http{% endif %}://{{ request.get_host }}/integration_loop/build/{{ integration_loop_detail.name }}/", function(data) {
45 data = $.parseJSON(data);
46 $("<div/>", {
47 "class": "test",
48
49=== modified file 'dashboard/frontend/integration_loop/urls.py'
50--- dashboard/frontend/integration_loop/urls.py 2012-08-16 15:12:10 +0000
51+++ dashboard/frontend/integration_loop/urls.py 2012-08-24 14:25:22 +0000
52@@ -15,13 +15,15 @@
53 # You should have received a copy of the GNU Affero General Public License
54 # along with linaro-ci-dashboard. If not, see <http://www.gnu.org/licenses/>.
55
56-from django.conf.urls.defaults import patterns, include, url
57-from frontend.integration_loop.views.integration_loop_create_view\
58+from django.conf.urls.defaults import patterns, url
59+from frontend.integration_loop.views.integration_loop_create_view \
60 import IntegrationLoopCreateView
61-from frontend.integration_loop.views.integration_loop_update_view\
62+from frontend.integration_loop.views.integration_loop_update_view \
63 import IntegrationLoopUpdateView
64-from frontend.integration_loop.views.integration_loop_detail_view\
65+from frontend.integration_loop.views.integration_loop_detail_view \
66 import IntegrationLoopDetailView
67+from frontend.integration_loop.views.integration_loop_build_view \
68+ import IntegrationLoopBuildView
69
70
71 urlpatterns = patterns('',
72@@ -31,4 +33,6 @@
73 IntegrationLoopDetailView.as_view(), name='IntegrationLoopDetail'),
74 url(r'^integration_loop/update/(?P<slug>[\w|\W]+)/$',
75 IntegrationLoopUpdateView.as_view(), name='IntegrationLoopUpdate'),
76+ url(r'^integration_loop/build/(?P<slug>[\w|\W]+)/$',
77+ IntegrationLoopBuildView.as_view(), name='IntegrationLoopBuild'),
78 )
79
80=== added file 'dashboard/frontend/integration_loop/views/integration_loop_build_view.py'
81--- dashboard/frontend/integration_loop/views/integration_loop_build_view.py 1970-01-01 00:00:00 +0000
82+++ dashboard/frontend/integration_loop/views/integration_loop_build_view.py 2012-08-24 14:25:22 +0000
83@@ -0,0 +1,25 @@
84+#!/usr/bin/env python
85+# Copyright (C) 2012 Linaro
86+#
87+# This file is part of linaro-ci-dashboard.
88+#
89+# linaro-ci-dashboard is free software: you can redistribute it and/or modify
90+# it under the terms of the GNU Affero General Public License as published by
91+# the Free Software Foundation, either version 3 of the License, or
92+# (at your option) any later version.
93+#
94+# linaro-ci-dashboard is distributed in the hope that it will be useful,
95+# but WITHOUT ANY WARRANTY; without even the implied warranty of
96+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
97+# GNU Affero General Public License for more details.
98+#
99+# You should have received a copy of the GNU Affero General Public License
100+# along with linaro-ci-dashboard. If not, see <http://www.gnu.org/licenses/>.
101+
102+from frontend.integration_loop.models.integration_loop import IntegrationLoop
103+from frontend.views.loop_build_view import LoopBuildView
104+
105+
106+class IntegrationLoopBuildView(LoopBuildView):
107+
108+ model = IntegrationLoop
109
110=== modified file 'dashboard/frontend/kernel_build/models/kernel_loop.py'
111--- dashboard/frontend/kernel_build/models/kernel_loop.py 2012-08-24 13:00:02 +0000
112+++ dashboard/frontend/kernel_build/models/kernel_loop.py 2012-08-24 14:25:22 +0000
113@@ -114,7 +114,7 @@
114
115 def save(self, *args, **kwargs):
116 self.server = JenkinsServer.objects.get(id=1)
117- super(KernelLoop, self).save(*args, **kwargs)
118+ super(self.__class__, self).save(*args, **kwargs)
119 # We do not want a failure in remote server to affect the
120 # CI Loop flow.
121 try:
122@@ -122,9 +122,3 @@
123 except:
124 # TODO: Log error.
125 pass
126-
127- def schedule_build(self):
128- # Every time before the build is scheduled, update the
129- # loop config on the remote server.
130- self.server.create_or_update_loop(self)
131- super(KernelLoop, self).schedule_build()
132
133=== modified file 'dashboard/frontend/kernel_build/templates/kernel_loop_detail.html'
134--- dashboard/frontend/kernel_build/templates/kernel_loop_detail.html 2012-08-20 20:12:55 +0000
135+++ dashboard/frontend/kernel_build/templates/kernel_loop_detail.html 2012-08-24 14:25:22 +0000
136@@ -39,14 +39,14 @@
137 {% block scripts %}
138 <script type="text/javascript">
139 $("#schedule_button").click(function() {
140- $.get("{% if request.is_secure %}https{% else %}http{% endif %}://{{ request.get_host }}/loop/build/{{ kernel_loop_detail.name }}/", function(data) {
141+ $.get("{% if request.is_secure %}https{% else %}http{% endif %}://{{ request.get_host }}/kernel/build/{{ kernel_loop_detail.name }}/", function(data) {
142 data = $.parseJSON(data);
143 $("<div/>", {
144 "class": "test",
145 text: "Build: " + data[0].fields.build_number + " || " +
146 data[0].fields.status + " || " +
147 data[0].fields.duration + " || " +
148- data[0].fields.remote_number,
149+ data[0].fields.remote_number
150 })
151 .prependTo($("#builds"));
152 });
153
154=== modified file 'dashboard/frontend/kernel_build/urls.py'
155--- dashboard/frontend/kernel_build/urls.py 2012-08-20 20:12:55 +0000
156+++ dashboard/frontend/kernel_build/urls.py 2012-08-24 14:25:22 +0000
157@@ -22,6 +22,8 @@
158 import KernelLoopUpdateView
159 from frontend.kernel_build.views.kernel_loop_detail_view \
160 import KernelLoopDetailView
161+from frontend.kernel_build.views.kernel_loop_build_view \
162+ import KernelLoopBuildView
163
164
165 urlpatterns = patterns('',
166@@ -31,4 +33,6 @@
167 KernelLoopDetailView.as_view(), name='KernelLoopDetail'),
168 url(r'^kernel/update/(?P<slug>[\w|\W]+)/$',
169 KernelLoopUpdateView.as_view(), name='KernelLoopUpdate'),
170+ url(r'^kernel/build/(?P<slug>[\w|\W]+)/$',
171+ KernelLoopBuildView.as_view(), name='KernelLoopBuild'),
172 )
173
174=== added file 'dashboard/frontend/kernel_build/views/kernel_loop_build_view.py'
175--- dashboard/frontend/kernel_build/views/kernel_loop_build_view.py 1970-01-01 00:00:00 +0000
176+++ dashboard/frontend/kernel_build/views/kernel_loop_build_view.py 2012-08-24 14:25:22 +0000
177@@ -0,0 +1,24 @@
178+# Copyright (C) 2012 Linaro
179+#
180+# This file is part of linaro-ci-dashboard.
181+#
182+# linaro-ci-dashboard is free software: you can redistribute it and/or modify
183+# it under the terms of the GNU Affero General Public License as published by
184+# the Free Software Foundation, either version 3 of the License, or
185+# (at your option) any later version.
186+#
187+# linaro-ci-dashboard is distributed in the hope that it will be useful,
188+# but WITHOUT ANY WARRANTY; without even the implied warranty of
189+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
190+# GNU Affero General Public License for more details.
191+#
192+# You should have received a copy of the GNU Affero General Public License
193+# along with linaro-ci-dashboard. If not, see <http://www.gnu.org/licenses/>.
194+
195+from frontend.kernel_build.models.kernel_loop import KernelLoop
196+from frontend.views.loop_build_view import LoopBuildView
197+
198+
199+class KernelLoopBuildView(LoopBuildView):
200+
201+ model = KernelLoop
202
203=== modified file 'dashboard/frontend/models/loop.py'
204--- dashboard/frontend/models/loop.py 2012-08-24 12:02:17 +0000
205+++ dashboard/frontend/models/loop.py 2012-08-24 14:25:22 +0000
206@@ -33,6 +33,11 @@
207 is_official = models.BooleanField(default=False,
208 verbose_name='Build is official')
209
210+ # List of fields to be excluded by default from the base64 encoded config.
211+ # If a subclass needs different fields, it is necessary to override this
212+ # variable.
213+ EXCLUDE_LIST = ['id', 'name', 'server', 'loop_ptr']
214+
215 def __init__(self, *args, **kwargs):
216 self.log = Logger.getClassLogger(self)
217 super(Loop, self).__init__(*args, **kwargs)
218@@ -43,6 +48,11 @@
219 Also try to send a build job signal to the server, but if it fails,
220 ignore it.
221 '''
222+
223+ # Every time before the build is scheduled, update the
224+ # loop config on the remote server.
225+ self.server.create_or_update_loop(self)
226+
227 from frontend.models.loop_build import LoopBuild
228 build = LoopBuild()
229 build.loop = self

Subscribers

People subscribed via source and target branches