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
=== modified file 'dashboard/frontend/android_build/models/android_loop.py'
--- dashboard/frontend/android_build/models/android_loop.py 2012-08-24 13:00:02 +0000
+++ dashboard/frontend/android_build/models/android_loop.py 2012-08-24 14:25:22 +0000
@@ -55,8 +55,6 @@
55 DEFAULT_GCC = '4.4.0'55 DEFAULT_GCC = '4.4.0'
56 DEFAULT_IMAGE_SIZE = '2G'56 DEFAULT_IMAGE_SIZE = '2G'
5757
58 EXCLUDE_LIST = ['id', 'name', 'server', 'loop_ptr']
59
60 # BUILD_TYPE58 # BUILD_TYPE
61 build_type = models.CharField(max_length=100,59 build_type = models.CharField(max_length=100,
62 choices=ANDROID_BUILD_TYPES,60 choices=ANDROID_BUILD_TYPES,
@@ -127,8 +125,5 @@
127 pass125 pass
128126
129 def schedule_build(self):127 def schedule_build(self):
130 # Every time before the build is scheduled, update the
131 # loop config on the remote server.
132 parameters = {'parameter': [{'delay': '0'}]}128 parameters = {'parameter': [{'delay': '0'}]}
133 self.server.create_or_update_loop(self)
134 return super(self.__class__, self).schedule_build(parameters)129 return super(self.__class__, self).schedule_build(parameters)
135130
=== modified file 'dashboard/frontend/integration_loop/models/integration_loop.py'
--- dashboard/frontend/integration_loop/models/integration_loop.py 2012-08-24 13:00:02 +0000
+++ dashboard/frontend/integration_loop/models/integration_loop.py 2012-08-24 14:25:22 +0000
@@ -29,8 +29,6 @@
29 precommand = models.CharField(max_length=200)29 precommand = models.CharField(max_length=200)
30 command = models.CharField(max_length=200)30 command = models.CharField(max_length=200)
3131
32 EXCLUDE_LIST = ['id', 'name', 'server', 'loop_ptr']
33
34 def save(self, *args, **kwargs):32 def save(self, *args, **kwargs):
35 self.server = JenkinsServer.objects.get(id=1)33 self.server = JenkinsServer.objects.get(id=1)
36 super(self.__class__, self).save(*args, **kwargs)34 super(self.__class__, self).save(*args, **kwargs)
3735
=== modified file 'dashboard/frontend/integration_loop/templates/integration_loop_detail.html'
--- dashboard/frontend/integration_loop/templates/integration_loop_detail.html 2012-08-23 08:45:39 +0000
+++ dashboard/frontend/integration_loop/templates/integration_loop_detail.html 2012-08-24 14:25:22 +0000
@@ -41,7 +41,7 @@
41{% block scripts %}41{% block scripts %}
42<script type="text/javascript">42<script type="text/javascript">
43$("#schedule_button").click(function() {43$("#schedule_button").click(function() {
44 $.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);45 data = $.parseJSON(data);
46 $("<div/>", {46 $("<div/>", {
47 "class": "test",47 "class": "test",
4848
=== modified file 'dashboard/frontend/integration_loop/urls.py'
--- dashboard/frontend/integration_loop/urls.py 2012-08-16 15:12:10 +0000
+++ dashboard/frontend/integration_loop/urls.py 2012-08-24 14:25:22 +0000
@@ -15,13 +15,15 @@
15# You should have received a copy of the GNU Affero General Public License15# You should have received a copy of the GNU Affero General Public License
16# along with linaro-ci-dashboard. If not, see <http://www.gnu.org/licenses/>.16# along with linaro-ci-dashboard. If not, see <http://www.gnu.org/licenses/>.
1717
18from django.conf.urls.defaults import patterns, include, url18from django.conf.urls.defaults import patterns, url
19from frontend.integration_loop.views.integration_loop_create_view\19from frontend.integration_loop.views.integration_loop_create_view \
20 import IntegrationLoopCreateView20 import IntegrationLoopCreateView
21from frontend.integration_loop.views.integration_loop_update_view\21from frontend.integration_loop.views.integration_loop_update_view \
22 import IntegrationLoopUpdateView22 import IntegrationLoopUpdateView
23from frontend.integration_loop.views.integration_loop_detail_view\23from frontend.integration_loop.views.integration_loop_detail_view \
24 import IntegrationLoopDetailView24 import IntegrationLoopDetailView
25from frontend.integration_loop.views.integration_loop_build_view \
26 import IntegrationLoopBuildView
2527
2628
27urlpatterns = patterns('',29urlpatterns = patterns('',
@@ -31,4 +33,6 @@
31 IntegrationLoopDetailView.as_view(), name='IntegrationLoopDetail'),33 IntegrationLoopDetailView.as_view(), name='IntegrationLoopDetail'),
32 url(r'^integration_loop/update/(?P<slug>[\w|\W]+)/$',34 url(r'^integration_loop/update/(?P<slug>[\w|\W]+)/$',
33 IntegrationLoopUpdateView.as_view(), name='IntegrationLoopUpdate'),35 IntegrationLoopUpdateView.as_view(), name='IntegrationLoopUpdate'),
36 url(r'^integration_loop/build/(?P<slug>[\w|\W]+)/$',
37 IntegrationLoopBuildView.as_view(), name='IntegrationLoopBuild'),
34)38)
3539
=== added file 'dashboard/frontend/integration_loop/views/integration_loop_build_view.py'
--- dashboard/frontend/integration_loop/views/integration_loop_build_view.py 1970-01-01 00:00:00 +0000
+++ dashboard/frontend/integration_loop/views/integration_loop_build_view.py 2012-08-24 14:25:22 +0000
@@ -0,0 +1,25 @@
1#!/usr/bin/env python
2# Copyright (C) 2012 Linaro
3#
4# This file is part of linaro-ci-dashboard.
5#
6# linaro-ci-dashboard is free software: you can redistribute it and/or modify
7# it under the terms of the GNU Affero General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# linaro-ci-dashboard is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU Affero General Public License for more details.
15#
16# You should have received a copy of the GNU Affero General Public License
17# along with linaro-ci-dashboard. If not, see <http://www.gnu.org/licenses/>.
18
19from frontend.integration_loop.models.integration_loop import IntegrationLoop
20from frontend.views.loop_build_view import LoopBuildView
21
22
23class IntegrationLoopBuildView(LoopBuildView):
24
25 model = IntegrationLoop
026
=== modified file 'dashboard/frontend/kernel_build/models/kernel_loop.py'
--- dashboard/frontend/kernel_build/models/kernel_loop.py 2012-08-24 13:00:02 +0000
+++ dashboard/frontend/kernel_build/models/kernel_loop.py 2012-08-24 14:25:22 +0000
@@ -114,7 +114,7 @@
114114
115 def save(self, *args, **kwargs):115 def save(self, *args, **kwargs):
116 self.server = JenkinsServer.objects.get(id=1)116 self.server = JenkinsServer.objects.get(id=1)
117 super(KernelLoop, self).save(*args, **kwargs)117 super(self.__class__, self).save(*args, **kwargs)
118 # We do not want a failure in remote server to affect the118 # We do not want a failure in remote server to affect the
119 # CI Loop flow.119 # CI Loop flow.
120 try:120 try:
@@ -122,9 +122,3 @@
122 except:122 except:
123 # TODO: Log error.123 # TODO: Log error.
124 pass124 pass
125
126 def schedule_build(self):
127 # Every time before the build is scheduled, update the
128 # loop config on the remote server.
129 self.server.create_or_update_loop(self)
130 super(KernelLoop, self).schedule_build()
131125
=== modified file 'dashboard/frontend/kernel_build/templates/kernel_loop_detail.html'
--- dashboard/frontend/kernel_build/templates/kernel_loop_detail.html 2012-08-20 20:12:55 +0000
+++ dashboard/frontend/kernel_build/templates/kernel_loop_detail.html 2012-08-24 14:25:22 +0000
@@ -39,14 +39,14 @@
39{% block scripts %}39{% block scripts %}
40<script type="text/javascript">40<script type="text/javascript">
41$("#schedule_button").click(function() {41$("#schedule_button").click(function() {
42 $.get("{% if request.is_secure %}https{% else %}http{% endif %}://{{ request.get_host }}/loop/build/{{ kernel_loop_detail.name }}/", function(data) {42 $.get("{% if request.is_secure %}https{% else %}http{% endif %}://{{ request.get_host }}/kernel/build/{{ kernel_loop_detail.name }}/", function(data) {
43 data = $.parseJSON(data);43 data = $.parseJSON(data);
44 $("<div/>", {44 $("<div/>", {
45 "class": "test",45 "class": "test",
46 text: "Build: " + data[0].fields.build_number + " || " +46 text: "Build: " + data[0].fields.build_number + " || " +
47 data[0].fields.status + " || " +47 data[0].fields.status + " || " +
48 data[0].fields.duration + " || " +48 data[0].fields.duration + " || " +
49 data[0].fields.remote_number,49 data[0].fields.remote_number
50 })50 })
51 .prependTo($("#builds"));51 .prependTo($("#builds"));
52 });52 });
5353
=== modified file 'dashboard/frontend/kernel_build/urls.py'
--- dashboard/frontend/kernel_build/urls.py 2012-08-20 20:12:55 +0000
+++ dashboard/frontend/kernel_build/urls.py 2012-08-24 14:25:22 +0000
@@ -22,6 +22,8 @@
22 import KernelLoopUpdateView22 import KernelLoopUpdateView
23from frontend.kernel_build.views.kernel_loop_detail_view \23from frontend.kernel_build.views.kernel_loop_detail_view \
24 import KernelLoopDetailView24 import KernelLoopDetailView
25from frontend.kernel_build.views.kernel_loop_build_view \
26 import KernelLoopBuildView
2527
2628
27urlpatterns = patterns('',29urlpatterns = patterns('',
@@ -31,4 +33,6 @@
31 KernelLoopDetailView.as_view(), name='KernelLoopDetail'),33 KernelLoopDetailView.as_view(), name='KernelLoopDetail'),
32 url(r'^kernel/update/(?P<slug>[\w|\W]+)/$',34 url(r'^kernel/update/(?P<slug>[\w|\W]+)/$',
33 KernelLoopUpdateView.as_view(), name='KernelLoopUpdate'),35 KernelLoopUpdateView.as_view(), name='KernelLoopUpdate'),
36 url(r'^kernel/build/(?P<slug>[\w|\W]+)/$',
37 KernelLoopBuildView.as_view(), name='KernelLoopBuild'),
34)38)
3539
=== added file 'dashboard/frontend/kernel_build/views/kernel_loop_build_view.py'
--- dashboard/frontend/kernel_build/views/kernel_loop_build_view.py 1970-01-01 00:00:00 +0000
+++ dashboard/frontend/kernel_build/views/kernel_loop_build_view.py 2012-08-24 14:25:22 +0000
@@ -0,0 +1,24 @@
1# Copyright (C) 2012 Linaro
2#
3# This file is part of linaro-ci-dashboard.
4#
5# linaro-ci-dashboard is free software: you can redistribute it and/or modify
6# it under the terms of the GNU Affero General Public License as published by
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9#
10# linaro-ci-dashboard is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU Affero General Public License for more details.
14#
15# You should have received a copy of the GNU Affero General Public License
16# along with linaro-ci-dashboard. If not, see <http://www.gnu.org/licenses/>.
17
18from frontend.kernel_build.models.kernel_loop import KernelLoop
19from frontend.views.loop_build_view import LoopBuildView
20
21
22class KernelLoopBuildView(LoopBuildView):
23
24 model = KernelLoop
025
=== modified file 'dashboard/frontend/models/loop.py'
--- dashboard/frontend/models/loop.py 2012-08-24 12:02:17 +0000
+++ dashboard/frontend/models/loop.py 2012-08-24 14:25:22 +0000
@@ -33,6 +33,11 @@
33 is_official = models.BooleanField(default=False,33 is_official = models.BooleanField(default=False,
34 verbose_name='Build is official')34 verbose_name='Build is official')
3535
36 # List of fields to be excluded by default from the base64 encoded config.
37 # If a subclass needs different fields, it is necessary to override this
38 # variable.
39 EXCLUDE_LIST = ['id', 'name', 'server', 'loop_ptr']
40
36 def __init__(self, *args, **kwargs):41 def __init__(self, *args, **kwargs):
37 self.log = Logger.getClassLogger(self)42 self.log = Logger.getClassLogger(self)
38 super(Loop, self).__init__(*args, **kwargs)43 super(Loop, self).__init__(*args, **kwargs)
@@ -43,6 +48,11 @@
43 Also try to send a build job signal to the server, but if it fails,48 Also try to send a build job signal to the server, but if it fails,
44 ignore it.49 ignore it.
45 '''50 '''
51
52 # Every time before the build is scheduled, update the
53 # loop config on the remote server.
54 self.server.create_or_update_loop(self)
55
46 from frontend.models.loop_build import LoopBuild56 from frontend.models.loop_build import LoopBuild
47 build = LoopBuild()57 build = LoopBuild()
48 build.loop = self58 build.loop = self

Subscribers

People subscribed via source and target branches