Merge lp:~al-maisan/launchpad/bq-platform-columns-505725 into lp:launchpad/db-devel

Proposed by Muharem Hrnjadovic
Status: Merged
Approved by: Jonathan Lange
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~al-maisan/launchpad/bq-platform-columns-505725
Merge into: lp:launchpad/db-devel
Diff against target: 198 lines (+96/-10)
8 files modified
database/sampledata/current-dev.sql (+2/-2)
database/sampledata/current.sql (+2/-2)
database/schema/comments.sql (+2/-0)
database/schema/patch-2207-24-0.sql (+20/-0)
lib/lp/soyuz/interfaces/buildqueue.py (+18/-5)
lib/lp/soyuz/model/build.py (+2/-1)
lib/lp/soyuz/model/buildqueue.py (+3/-0)
lib/lp/soyuz/tests/test_buildqueue.py (+47/-0)
To merge this branch: bzr merge lp:~al-maisan/launchpad/bq-platform-columns-505725
Reviewer Review Type Date Requested Status
Paul Hummer (community) code Approve
Jonathan Lange (community) Approve
Stuart Bishop (community) db Approve
Review via email: mp+17125@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Muharem Hrnjadovic (al-maisan) wrote :

Hello there!

In order to be able to formulate reasonably straightforward queries that find
candidate jobs for idle builders we'd like to add NULLable 'processor' and
'virtualized' columns to BuildQueue.

In case of binary builds these will replicate the respective Build.processor
and Build.is_virtualized values. For processor-independent jobs they will
remain NULL.

Please note also that these columns will only be initialed once, when the
BuildQueue record is inserted.

Pre-implementation chat with jml. Bug #505725.

Revision history for this message
Stuart Bishop (stub) wrote :

Looks fine. patch-2207-24-0.sql

review: Approve (db)
Revision history for this message
Jonathan Lange (jml) wrote :

Fine by me.

review: Approve
Revision history for this message
Paul Hummer (rockstar) wrote :

Please add whitespace around the test's "layer =..." line. Other than that, it looks good.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'database/sampledata/current-dev.sql'
--- database/sampledata/current-dev.sql 2009-12-14 13:49:03 +0000
+++ database/sampledata/current-dev.sql 2010-01-12 02:26:13 +0000
@@ -1715,8 +1715,8 @@
17151715
1716ALTER TABLE buildqueue DISABLE TRIGGER ALL;1716ALTER TABLE buildqueue DISABLE TRIGGER ALL;
17171717
1718INSERT INTO buildqueue (id, builder, logtail, lastscore, manual, job, job_type, estimated_duration) VALUES (1, 1, 'Dummy sampledata entry, not processing', 1, false, 1, 1, '00:00:00');1718INSERT INTO buildqueue (id, builder, logtail, lastscore, manual, job, job_type, estimated_duration, processor, virtualized) VALUES (1, 1, 'Dummy sampledata entry, not processing', 1, false, 1, 1, '00:00:00', 1, FALSE);
1719INSERT INTO buildqueue (id, builder, logtail, lastscore, manual, job, job_type, estimated_duration) VALUES (2, NULL, NULL, 10, false, 2, 1, '00:01:00');1719INSERT INTO buildqueue (id, builder, logtail, lastscore, manual, job, job_type, estimated_duration, processor, virtualized) VALUES (2, NULL, NULL, 10, false, 2, 1, '00:01:00', 1, FALSE);
17201720
17211721
1722ALTER TABLE buildqueue ENABLE TRIGGER ALL;1722ALTER TABLE buildqueue ENABLE TRIGGER ALL;
17231723
=== modified file 'database/sampledata/current.sql'
--- database/sampledata/current.sql 2009-12-14 13:49:03 +0000
+++ database/sampledata/current.sql 2010-01-12 02:26:13 +0000
@@ -1697,8 +1697,8 @@
16971697
1698ALTER TABLE buildqueue DISABLE TRIGGER ALL;1698ALTER TABLE buildqueue DISABLE TRIGGER ALL;
16991699
1700INSERT INTO buildqueue (id, builder, logtail, lastscore, manual, job, job_type, estimated_duration) VALUES (1, 1, 'Dummy sampledata entry, not processing', 1, false, 1, 1, '00:00:00');1700INSERT INTO buildqueue (id, builder, logtail, lastscore, manual, job, job_type, estimated_duration, processor, virtualized) VALUES (1, 1, 'Dummy sampledata entry, not processing', 1, false, 1, 1, '00:00:00', 1, FALSE);
1701INSERT INTO buildqueue (id, builder, logtail, lastscore, manual, job, job_type, estimated_duration) VALUES (2, NULL, NULL, 10, false, 2, 1, '00:01:00');1701INSERT INTO buildqueue (id, builder, logtail, lastscore, manual, job, job_type, estimated_duration, processor, virtualized) VALUES (2, NULL, NULL, 10, false, 2, 1, '00:01:00', 1, FALSE);
17021702
17031703
1704ALTER TABLE buildqueue ENABLE TRIGGER ALL;1704ALTER TABLE buildqueue ENABLE TRIGGER ALL;
17051705
=== modified file 'database/schema/comments.sql'
--- database/schema/comments.sql 2009-12-01 13:45:58 +0000
+++ database/schema/comments.sql 2010-01-12 02:26:13 +0000
@@ -1537,6 +1537,8 @@
1537COMMENT ON COLUMN BuildQueue.job IS 'Foreign key to the `Job` table row with the generic job data.';1537COMMENT ON COLUMN BuildQueue.job IS 'Foreign key to the `Job` table row with the generic job data.';
1538COMMENT ON COLUMN BuildQueue.job_type IS 'Type of job (enumeration value), enables us to find/query the correct table with the data specific to this type of job.';1538COMMENT ON COLUMN BuildQueue.job_type IS 'Type of job (enumeration value), enables us to find/query the correct table with the data specific to this type of job.';
1539COMMENT ON COLUMN BuildQueue.estimated_duration IS 'Estimated job duration, based on previous running times of comparable jobs.';1539COMMENT ON COLUMN BuildQueue.estimated_duration IS 'Estimated job duration, based on previous running times of comparable jobs.';
1540COMMENT ON COLUMN BuildQueue.processor IS 'The processor required by the associated build farm job.';
1541COMMENT ON COLUMN BuildQueue.virtualized IS 'The virtualization setting required by the associated build farm job.';
15401542
1541-- Mirrors1543-- Mirrors
15421544
15431545
=== added file 'database/schema/patch-2207-24-0.sql'
--- database/schema/patch-2207-24-0.sql 1970-01-01 00:00:00 +0000
+++ database/schema/patch-2207-24-0.sql 2010-01-12 02:26:13 +0000
@@ -0,0 +1,20 @@
1-- Copyright 2009 Canonical Ltd. This software is licensed under the
2-- GNU Affero General Public License version 3 (see the file LICENSE).
3
4SET client_min_messages=ERROR;
5
6-- Another schema patch required for the Soyuz buildd generalisation, see
7-- https://dev.launchpad.net/Soyuz/Specs/BuilddGeneralisation for details.
8-- Bug #505725.
9
10-- Changes needed to the `BuildQueue` table.
11
12-- The 'processor' and the 'virtualized' columns will enable us to formulate
13-- more straightforward queries for finding candidate jobs when builders
14-- become idle.
15ALTER TABLE ONLY buildqueue ADD COLUMN processor integer;
16ALTER TABLE ONLY buildqueue ADD COLUMN virtualized boolean;
17
18CREATE INDEX buildqueue__processor__virtualized__idx ON buildqueue USING btree (processor, virtualized) WHERE (processor IS NOT NULL);
19
20INSERT INTO LaunchpadDatabaseRevision VALUES (2207, 24, 0);
021
=== modified file 'lib/lp/soyuz/interfaces/buildqueue.py'
--- lib/lp/soyuz/interfaces/buildqueue.py 2010-01-07 04:07:09 +0000
+++ lib/lp/soyuz/interfaces/buildqueue.py 2010-01-12 02:26:13 +0000
@@ -13,7 +13,7 @@
13 ]13 ]
1414
15from zope.interface import Interface, Attribute15from zope.interface import Interface, Attribute
16from zope.schema import Choice, Datetime, Field, Timedelta16from zope.schema import Bool, Choice, Datetime, Field, Int, Text, Timedelta
1717
18from lazr.restful.fields import Reference18from lazr.restful.fields import Reference
1919
@@ -21,6 +21,8 @@
21from lp.buildmaster.interfaces.buildfarmjob import (21from lp.buildmaster.interfaces.buildfarmjob import (
22 IBuildFarmJob, BuildFarmJobType)22 IBuildFarmJob, BuildFarmJobType)
23from lp.services.job.interfaces.job import IJob23from lp.services.job.interfaces.job import IJob
24from lp.soyuz.interfaces.builder import IBuilder
25from lp.soyuz.interfaces.processor import IProcessor
2426
2527
26class IBuildQueue(Interface):28class IBuildQueue(Interface):
@@ -38,10 +40,21 @@
38 """40 """
3941
40 id = Attribute("Job identifier")42 id = Attribute("Job identifier")
41 builder = Attribute("The IBuilder instance processing this job")43 builder = Reference(
42 logtail = Attribute("The current tail of the log of the build")44 IBuilder, title=_("Builder"), required=True, readonly=True,
43 lastscore = Attribute("Last score to be computed for this job")45 description=_("The IBuilder instance processing this job"))
44 manual = Attribute("Whether or not the job was manually scored")46 logtail = Text(
47 description=_("The current tail of the log of the job"))
48 lastscore = Int(description=_("This job's score."))
49 manual = Bool(
50 description=_("Whether or not the job was manually scored."))
51 processor = Reference(
52 IProcessor, title=_("Processor"), required=False, readonly=True,
53 description=_("The processor required by this build farm job."))
54 virtualized = Bool(
55 required=False,
56 description=_(
57 "The virtualization setting required by this build farm job."))
4558
46 job = Reference(59 job = Reference(
47 IJob, title=_("Job"), required=True, readonly=True,60 IJob, title=_("Job"), required=True, readonly=True,
4861
=== modified file 'lib/lp/soyuz/model/build.py'
--- lib/lp/soyuz/model/build.py 2009-12-10 16:51:18 +0000
+++ lib/lp/soyuz/model/build.py 2010-01-12 02:26:13 +0000
@@ -682,7 +682,8 @@
682 queue_entry = BuildQueue(682 queue_entry = BuildQueue(
683 estimated_duration=duration_estimate,683 estimated_duration=duration_estimate,
684 job_type=BuildFarmJobType.PACKAGEBUILD,684 job_type=BuildFarmJobType.PACKAGEBUILD,
685 job=job.id)685 job=job.id, processor=self.processor,
686 virtualized=self.is_virtualized)
686 store.add(queue_entry)687 store.add(queue_entry)
687 return queue_entry688 return queue_entry
688689
689690
=== modified file 'lib/lp/soyuz/model/buildqueue.py'
--- lib/lp/soyuz/model/buildqueue.py 2010-01-08 08:55:10 +0000
+++ lib/lp/soyuz/model/buildqueue.py 2010-01-12 02:26:13 +0000
@@ -52,6 +52,9 @@
52 lastscore = IntCol(dbName='lastscore', default=0)52 lastscore = IntCol(dbName='lastscore', default=0)
53 manual = BoolCol(dbName='manual', default=False)53 manual = BoolCol(dbName='manual', default=False)
54 estimated_duration = IntervalCol()54 estimated_duration = IntervalCol()
55 processor = ForeignKey(
56 dbName='processor', foreignKey='Processor', notNull=True)
57 virtualized = BoolCol(dbName='virtualized')
5558
56 @property59 @property
57 def required_build_behavior(self):60 def required_build_behavior(self):
5861
=== modified file 'lib/lp/soyuz/tests/test_buildqueue.py'
--- lib/lp/soyuz/tests/test_buildqueue.py 2010-01-07 20:12:52 +0000
+++ lib/lp/soyuz/tests/test_buildqueue.py 2010-01-12 02:26:13 +0000
@@ -740,3 +740,50 @@
740 self.assertEqual(740 self.assertEqual(
741 bq.specific_job_classes[BuildFarmJobType.BRANCHBUILD],741 bq.specific_job_classes[BuildFarmJobType.BRANCHBUILD],
742 FakeBranchBuild)742 FakeBranchBuild)
743
744
745class TestPlatformData(TestCaseWithFactory):
746 """Tests covering the processor/virtualized properties."""
747
748 layer = LaunchpadZopelessLayer
749
750 def setUp(self):
751 """Set up a native x86 build for the test archive."""
752 super(TestPlatformData, self).setUp()
753
754 self.publisher = SoyuzTestPublisher()
755 self.publisher.prepareBreezyAutotest()
756
757 # First mark all builds in the sample data as already built.
758 store = getUtility(IStoreSelector).get(MAIN_STORE, DEFAULT_FLAVOR)
759 sample_data = store.find(Build)
760 for build in sample_data:
761 build.buildstate = BuildStatus.FULLYBUILT
762 store.flush()
763
764 # We test builds that target a primary archive.
765 self.non_ppa = self.factory.makeArchive(
766 name="primary", purpose=ArchivePurpose.PRIMARY)
767 self.non_ppa.require_virtualized = False
768
769 self.builds = []
770 self.builds.extend(
771 self.publisher.getPubSource(
772 sourcename="gedit", status=PackagePublishingStatus.PUBLISHED,
773 archive=self.non_ppa).createMissingBuilds())
774
775 def test_JobPlatformSettings(self):
776 """The `BuildQueue` instance shares the processor/virtualized
777 properties with the associated `Build`."""
778 build, bq = find_job(self, 'gedit')
779
780 # Make sure the 'processor' properties are the same.
781 self.assertEqual(
782 bq.processor, build.processor,
783 "The 'processor' property deviates.")
784
785 # Make sure the 'virtualized' properties are the same.
786 self.assertEqual(
787 bq.virtualized, build.is_virtualized,
788 "The 'virtualized' property deviates.")
789

Subscribers

People subscribed via source and target branches

to status/vote changes: