Skip to contentSkip to conversation

Fix for YOCTO #7442

PATCH New Elliot Smith 1 participant 5 messages Sep 22, 2015

lore
Share & tools
lore
#0 lore raw

cover Fix for YOCTO #7442

This set of changes brings back functionality to specify a task for a build and properly restart builds with non-default tasks.

This functionality has been broken in toaster since June (builds specifying a non-default task could not be run correctly).

The patchset includes fixes for backend and frontend. It also adds 2 test cases for frontend to prevent this functionality from being broken again.

The following changes since commit 7b86c771c80d0759c2ca0e57c46c4c966f89c49e:

bitbake: bitbake: bb.fetch2.git: Import errno module (2015-09-19 22:38:44 +0100)

are available in the git repository at:

git://git.yoctoproject.org/poky-contrib elliot/submit/ed/toaster/7442
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=elliot/submit/ed/toaster/7442

Ed Bartosh (4):
toaster: store task name in Target objects
toaster: don't re-create Target objects
toaster: change UI to show tasks
toaster: add 2 UI tests

 lib/bb/ui/buildinfohelper.py                       | 17 +--------------
 .../bldcontrol/management/commands/runbuilds.py    |  2 +-
 lib/toaster/orm/models.py                          |  2 +-
 lib/toaster/toastergui/templates/builds.html       | 12 ++++++++++-
 lib/toaster/toastergui/templates/mrb_section.html  | 23 ++++++++++++++++-----
 .../toastergui/templates/projectbuilds.html        | 12 ++++++++++-
 lib/toaster/toastergui/tests.py                    | 24 ++++++++++++++++++++--
 7 files changed, 65 insertions(+), 27 deletions(-)

--
1.9.3

---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.

#1 lore raw

PATCH 1/4 toaster: store task name in Target objects

From: Ed Bartosh <[email protected]>

Information about a task is not stored in Target objects. This makes it impossible to correctly operate with the builds where task is specified.

Storing taks name is an enabler for other fixes in UI and backend related to restarting builds.

---
 lib/toaster/bldcontrol/management/commands/runbuilds.py | 2 +-
 lib/toaster/orm/models.py                               | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
lib/toaster/bldcontrol/management/commands/runbuilds.py +1 -1
index 718e144..5243a50 100644
@@ -118,7 +118,7 @@ class Command(NoArgsCommand):
             br.save()
             # transpose target information
             for brtarget in br.brtarget_set.all():
-                Target.objects.create(build = br.build, target= brtarget.target)
+                Target.objects.create(build=br.build, target=brtarget.target, task=brtarget.task)
             # transpose the launch errors in ToasterExceptions
             for brerror in br.brerror_set.all():
                 LogMessage.objects.create(build = br.build, level = LogMessage.EXCEPTION, message = brerror.errmsg)
lib/toaster/orm/models.py +1 -1
index e4d2e87..883ecf4 100644
@@ -270,7 +270,7 @@ class Project(models.Model):
                                 )
             for t in self.projecttarget_set.all():
                 BRTarget.objects.create(req = br, target = t.target, task = t.task)
-                Target.objects.create(build = br.build, target = t.target)
+                Target.objects.create(build = br.build, target = t.target, task = t.task)
 
             for v in self.projectvariable_set.all():
                 BRVariable.objects.create(req = br, name = v.name, value = v.value)
Signature · 12 lines
1.9.3

---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
#2 lore raw

PATCH 2/4 toaster: don't re-create Target objects

From: Ed Bartosh <[email protected]>

Due to re-creating Target objects from bitbake events task information stored in original objects is lost.

There is no valid reason to remove existing objects. It's safer to query them instead of re-creating as original object contain more information than events coming from bitbake.

---
 lib/bb/ui/buildinfohelper.py | 17 +----------------
 1 file changed, 1 insertion(+), 16 deletions(-)
lib/bb/ui/buildinfohelper.py +1 -16
index 6e313fe..e5f1e09 100644
@@ -161,8 +161,6 @@ class ORMWrapper(object):
             build.bitbake_version=build_info['bitbake_version']
             build.save()
 
-            Target.objects.filter(build = build).delete()
-
         else:
             build = Build.objects.create(
                                     project = prj,
@@ -183,19 +181,6 @@ class ORMWrapper(object):
 
         return build
 
-    def create_target_objects(self, target_info):
-        assert 'build' in target_info
-        assert 'targets' in target_info
-
-        targets = []
-        for tgt_name in target_info['targets']:
-            tgt_object = Target.objects.create( build = target_info['build'],
-                                    target = tgt_name,
-                                    is_image = False,
-                                    )
-            targets.append(tgt_object)
-        return targets
-
     def update_build_object(self, build, errors, warnings, taskfailures):
         assert isinstance(build,Build)
         assert isinstance(errors, int)
@@ -869,7 +854,7 @@ class BuildInfoHelper(object):
         target_information['targets'] = event._pkgs
         target_information['build'] = build_obj
 
-        self.internal_state['targets'] = self.orm_wrapper.create_target_objects(target_information)
+        self.internal_state['targets'] = Target.objects.filter(build=target_information['build'])
 
         # Save build configuration
         data = self.server.runCommand(["getAllKeysWithFlags", ["doc", "func"]])[0]
Signature · 12 lines
1.9.3

---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
#3 lore raw

PATCH 3/4 toaster: change UI to show tasks

In reply to Elliot Smith

From: Ed Bartosh <[email protected]>

Changed toaster UI to show tasks if they're specified for the builds and use them when restarting builds.

[YOCTO #7442]

---
 lib/toaster/toastergui/templates/builds.html       | 12 ++++++++++-
 lib/toaster/toastergui/templates/mrb_section.html  | 23 +++++++++++++++++-----
 .../toastergui/templates/projectbuilds.html        | 12 ++++++++++-
 3 files changed, 40 insertions(+), 7 deletions(-)
lib/toaster/toastergui/templates/builds.html +11 -1
index c0d0c64..2b35b01 100644
@@ -66,7 +66,17 @@
             <td class="outcome">
         <a href="{% url "builddashboard" build.id %}">{%if build.outcome == build.SUCCEEDED%}<i class="icon-ok-sign success"></i>{%elif build.outcome == build.FAILED%}<i class="icon-minus-sign error"></i>{%else%}{%endif%}</a> &nbsp;
         </td>
-            <td class="target">{% for t in build.target_set.all %} <a href="{% url "builddashboard" build.id %}"> {{t.target}} </a> <br />{% endfor %}</td>
+            <td class="target">
+                {% for t in build.target_set.all %}
+                    <a href="{% url "builddashboard" build.id %}">
+                        {% if t.task %}
+                            {{t.target}}:{{t.task}}
+                        {% else %}
+                            {{t.target}}
+                        {% endif %}
+                    </a> <br />
+                {% endfor %}
+            </td>
             <td class="machine"><a href="{% url "builddashboard" build.id %}">{{build.machine}}</a></td>
             <td class="started_on"><a href="{% url "builddashboard" build.id %}">{{build.started_on|date:"d/m/y H:i"}}</a></td>
             <td class="completed_on"><a href="{% url "builddashboard" build.id %}">{{build.completed_on|date:"d/m/y H:i"}}</a></td>
lib/toaster/toastergui/templates/mrb_section.html +18 -5
index 396fb8e..13e2d0e 100644
@@ -26,12 +26,25 @@
     {% endif %}
             {% if build.target_set.all.count > 0 %}
                 <span data-toggle="tooltip"
-                  {%if build.target_set.all.count > 1%}
-                    title="Targets: {%for target in build.target_set.all%}{{target.target}} {%endfor%}"
-                  {%endif%}
+                  {% if build.target_set.all.count > 1 %}
+                    title="Targets:
+                    {% for target in build.target_set.all %}
+                        {% if target.task %}
+                            {{target.target}}:{{target.task}}
+                        {% else %}
+                            {{target.target}}
+                        {% endif %}
+                    {% endfor %}"
+                  {% endif %}
                 >
-
-                  {{build.target_set.all.0.target}} {%if build.target_set.all.count > 1%}(+ {{build.target_set.all.count|add:"-1"}}){%endif%}
+                {% if build.target_set.all.0.task %}
+                    {{build.target_set.all.0.target}}:{{build.target_set.all.0.task}}
+                {% else %}
+                    {{build.target_set.all.0.target}}
+                {% endif %}
+                {% if build.target_set.all.count > 1 %}
+                    (+ {{build.target_set.all.count|add:"-1"}})
+                {% endif %}
                 </span>
              {% endif %}
     {%if build.outcome == build.SUCCEEDED or build.outcome == build.FAILED %}
lib/toaster/toastergui/templates/projectbuilds.html +11 -1
index 27cfcd7..fc659a0 100644
@@ -66,7 +66,17 @@
                     {% endif %}
             </td>
 
-            <td class="target">{% for t in build.target_set.all %} <a href="{% url "builddashboard" build.id %}"> {{t.target}} </a> <br />{% endfor %}</td>
+            <td class="target">
+                {% for t in build.target_set.all %}
+                    <a href="{% url "builddashboard" build.id %}">
+                        {% if t.task %}
+                            {{t.target}}:{{t.task}}
+                        {% else %}
+                            {{t.target}}
+                        {% endif %}
+                    </a> <br />
+                {% endfor %}
+            </td>
             <td class="machine"><a href="{% url "builddashboard" build.id %}">{{build.machine}}</a></td>
             <td class="started_on"><a href="{% url "builddashboard" build.id %}">{{build.started_on|date:"d/m/y H:i"}}</a></td>
             <td class="completed_on"><a href="{% url "builddashboard" build.id %}">{{build.completed_on|date:"d/m/y H:i"}}</a></td>
Signature · 12 lines
1.9.3

---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
#4 lore raw

PATCH 4/4 toaster: add 2 UI tests

In reply to Elliot Smith

From: Ed Bartosh <[email protected]>

Tested that UI shows task names for the builds in
both all-builds and projectbuilds views.

---
 lib/toaster/toastergui/tests.py | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)
lib/toaster/toastergui/tests.py +22 -2
index 4d1549b..53012b4 100644
@@ -21,12 +21,14 @@
 
 """Test cases for Toaster GUI and ReST."""
 
+import re
+
 from django.test import TestCase
 from django.core.urlresolvers import reverse
 from django.utils import timezone
 from orm.models import Project, Release, BitbakeVersion, ProjectTarget
 from orm.models import ReleaseLayerSourcePriority, LayerSource, Layer, Build
-from orm.models import Layer_Version, Recipe, Machine, ProjectLayer
+from orm.models import Layer_Version, Recipe, Machine, ProjectLayer, Target
 import json
 from bs4 import BeautifulSoup
 
@@ -376,4 +378,22 @@ class ProjectBuildsDisplayTest(TestCase):
         build2b = Build.objects.create(**self.project2_build_in_progress)
 
         build_rows = self._get_rows_for_project(self.project1.id)
-        self.assertEqual(len(build_rows), 2)
\ No newline at end of file
+        self.assertEqual(len(build_rows), 2)
+
+    def test_show_tasks_in_projectbuilds(self):
+        build = Build.objects.create(**self.project1_build_success)
+        target = Target.objects.create(build=build, target='bash',
+                                       task='clean')
+        url = reverse("projectbuilds", args=(self.project1.id,))
+        response = self.client.get(url, follow=True)
+        result = re.findall('^ +bash:clean$', response.content, re.MULTILINE)
+        self.assertEqual(len(result), 1)
+
+    def test_show_tasks_in_allbuilds(self):
+        build = Build.objects.create(**self.project1_build_success)
+        target = Target.objects.create(build=build, target='bash',
+                                       task='clean')
+        url = reverse("all-builds")
+        response = self.client.get(url, follow=True)
+        result = re.findall('bash:clean', response.content, re.MULTILINE)
+        self.assertEqual(len(result), 3)
Signature · 12 lines
1.9.3

---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.