aboutsummaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2015-07-24 16:05:20 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-09-19 11:31:59 +0100
commite993aa67054aa43854570861b4f005e780bdd3df (patch)
tree992b81e22520e5260ea3fbf65a1172938368eccd /bitbake
parent5b4e380b9b4335f4607d78d97345bbbda4c66e0e (diff)
downloadopenembedded-core-contrib-e993aa67054aa43854570861b4f005e780bdd3df.tar.gz
bitbake: toaster: hide irrelevant builds in the project builds view
This patch fixes the project builds view so it doesn't show "in progress" builds or builds for other projects. Note that this also modifies the "all builds" view to use the same queryset filtering as the project builds. This is to avoid excluding "in progress" builds more than once, which is what was happening before. The patch also has a minor change to ensure that when displaying the project builds page, only builds for that project are in the results. The queryset filtering is now split over several lines so you can see what's going on. [YOCTO #8236] [YOCTO #8187] (Bitbake rev: 771c08b9be1f7875e0216e381ab0a81ef0d26256) Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Elliot Smith <elliot.smith@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/toaster/toastergui/tests.py91
-rwxr-xr-xbitbake/lib/toaster/toastergui/views.py5
-rw-r--r--bitbake/toaster-requirements.txt1
3 files changed, 91 insertions, 6 deletions
diff --git a/bitbake/lib/toaster/toastergui/tests.py b/bitbake/lib/toaster/toastergui/tests.py
index 1a8b4787dd..4d1549b0a9 100644
--- a/bitbake/lib/toaster/toastergui/tests.py
+++ b/bitbake/lib/toaster/toastergui/tests.py
@@ -24,10 +24,11 @@
from django.test import TestCase
from django.core.urlresolvers import reverse
from django.utils import timezone
-from orm.models import Project, Release, BitbakeVersion, Build
-from orm.models import ReleaseLayerSourcePriority, LayerSource, Layer
+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
import json
+from bs4 import BeautifulSoup
PROJECT_NAME = "test project"
@@ -41,7 +42,6 @@ class ViewTests(TestCase):
bitbake_version=bbv)
self.project = Project.objects.create_project(name=PROJECT_NAME,
release=release)
-
layersrc = LayerSource.objects.create(sourcetype=LayerSource.TYPE_IMPORTED)
self.priority = ReleaseLayerSourcePriority.objects.create(release=release,
layer_source=layersrc)
@@ -292,3 +292,88 @@ class ProjectsPageTests(TestCase):
'should be a project row in the page')
self.assertTrue(self.PROJECT_NAME in response.content,
'default project "cli builds" should be in page')
+
+class ProjectBuildsDisplayTest(TestCase):
+ """ Test data at /project/X/builds is displayed correctly """
+
+ def setUp(self):
+ bbv = BitbakeVersion.objects.create(name="bbv1", giturl="/tmp/",
+ branch="master", dirpath="")
+ release = Release.objects.create(name="release1",
+ bitbake_version=bbv)
+ self.project1 = Project.objects.create_project(name=PROJECT_NAME,
+ release=release)
+ self.project2 = Project.objects.create_project(name=PROJECT_NAME,
+ release=release)
+
+ # parameters for builds to associate with the projects
+ now = timezone.now()
+
+ self.project1_build_success = {
+ "project": self.project1,
+ "started_on": now,
+ "completed_on": now,
+ "outcome": Build.SUCCEEDED
+ }
+
+ self.project1_build_in_progress = {
+ "project": self.project1,
+ "started_on": now,
+ "completed_on": now,
+ "outcome": Build.IN_PROGRESS
+ }
+
+ self.project2_build_success = {
+ "project": self.project2,
+ "started_on": now,
+ "completed_on": now,
+ "outcome": Build.SUCCEEDED
+ }
+
+ self.project2_build_in_progress = {
+ "project": self.project2,
+ "started_on": now,
+ "completed_on": now,
+ "outcome": Build.IN_PROGRESS
+ }
+
+ def _get_rows_for_project(self, project_id):
+ url = reverse("projectbuilds", args=(project_id,))
+ response = self.client.get(url, follow=True)
+ soup = BeautifulSoup(response.content)
+ return soup.select('tr[class="data"]')
+
+ def test_show_builds_for_project(self):
+ """ Builds for a project should be displayed """
+ build1a = Build.objects.create(**self.project1_build_success)
+ build1b = Build.objects.create(**self.project1_build_success)
+ build_rows = self._get_rows_for_project(self.project1.id)
+ self.assertEqual(len(build_rows), 2)
+
+ def test_show_builds_for_project_only(self):
+ """ Builds for other projects should be excluded """
+ build1a = Build.objects.create(**self.project1_build_success)
+ build1b = Build.objects.create(**self.project1_build_success)
+ build1c = Build.objects.create(**self.project1_build_success)
+
+ # shouldn't see these two
+ build2a = Build.objects.create(**self.project2_build_success)
+ build2b = Build.objects.create(**self.project2_build_in_progress)
+
+ build_rows = self._get_rows_for_project(self.project1.id)
+ self.assertEqual(len(build_rows), 3)
+
+ def test_show_builds_exclude_in_progress(self):
+ """ "in progress" builds should not be shown """
+ build1a = Build.objects.create(**self.project1_build_success)
+ build1b = Build.objects.create(**self.project1_build_success)
+
+ # shouldn't see this one
+ build1c = Build.objects.create(**self.project1_build_in_progress)
+
+ # shouldn't see these two either, as they belong to a different project
+ build2a = Build.objects.create(**self.project2_build_success)
+ 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
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index d9802f01b8..8689a1251e 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -40,7 +40,7 @@ from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.http import HttpResponseBadRequest, HttpResponseNotFound
from django.utils import timezone
from django.utils.html import escape
-from datetime import timedelta, datetime, date
+from datetime import timedelta, datetime
from django.utils import formats
from toastergui.templatetags.projecttags import json as jsonfilter
import json
@@ -442,8 +442,7 @@ def _modify_date_range_filter(filter_string):
def _add_daterange_context(queryset_all, request, daterange_list):
# calculate the exact begining of local today and yesterday
today_begin = timezone.localtime(timezone.now())
- today_begin = date(today_begin.year,today_begin.month,today_begin.day)
- yesterday_begin = today_begin-timedelta(days=1)
+ yesterday_begin = today_begin - timedelta(days=1)
# add daterange persistent
context_date = {}
context_date['last_date_from'] = request.GET.get('last_date_from',timezone.localtime(timezone.now()).strftime("%d/%m/%Y"))
diff --git a/bitbake/toaster-requirements.txt b/bitbake/toaster-requirements.txt
index 1d92d5e3a7..c4a2221553 100644
--- a/bitbake/toaster-requirements.txt
+++ b/bitbake/toaster-requirements.txt
@@ -3,3 +3,4 @@ South==0.8.4
argparse==1.2.1
wsgiref==0.1.2
filemagic==1.6
+beautifulsoup4>=4.4.0