Merge ~cjwatson/launchpad:stormify-binarypackagebuild into launchpad:master
- Git
- lp:~cjwatson/launchpad
- stormify-binarypackagebuild
- Merge into master
Proposed by
Colin Watson
Status: | Merged |
---|---|
Approved by: | Colin Watson |
Approved revision: | 97cfdd3cb4cdf71ed726708f1cffbe026079ef9f |
Merge reported by: | Otto Co-Pilot |
Merged at revision: | not available |
Proposed branch: | ~cjwatson/launchpad:stormify-binarypackagebuild |
Merge into: | launchpad:master |
Diff against target: |
449 lines (+164/-98) 7 files modified
lib/lp/archiveuploader/tests/test_buildduploads.py (+7/-2) lib/lp/soyuz/doc/distroarchseriesbinarypackage.rst (+56/-48) lib/lp/soyuz/doc/gina-multiple-arch.rst (+7/-2) lib/lp/soyuz/doc/gina.rst (+11/-3) lib/lp/soyuz/model/binarypackagebuild.py (+56/-15) lib/lp/soyuz/model/sourcepackagerelease.py (+14/-9) lib/lp/soyuz/scripts/gina/handlers.py (+13/-19) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ines Almeida | Approve | ||
Review via email: mp+449467@code.launchpad.net |
Commit message
Convert BinaryPackageBuild to Storm
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | diff --git a/lib/lp/archiveuploader/tests/test_buildduploads.py b/lib/lp/archiveuploader/tests/test_buildduploads.py |
2 | index 0425a43..c368db7 100644 |
3 | --- a/lib/lp/archiveuploader/tests/test_buildduploads.py |
4 | +++ b/lib/lp/archiveuploader/tests/test_buildduploads.py |
5 | @@ -15,6 +15,7 @@ from lp.buildmaster.interfaces.processor import IProcessorSet |
6 | from lp.registry.interfaces.distribution import IDistributionSet |
7 | from lp.registry.interfaces.pocket import PackagePublishingPocket |
8 | from lp.services.database.constants import UTC_NOW |
9 | +from lp.services.database.interfaces import IStore |
10 | from lp.soyuz.enums import PackagePublishingStatus, PackageUploadStatus |
11 | from lp.soyuz.interfaces.binarypackagebuild import IBinaryPackageBuildSet |
12 | from lp.soyuz.interfaces.publishing import IPublishingSet |
13 | @@ -77,14 +78,18 @@ class TestStagedBinaryUploadBase(TestUploadProcessorBase): |
14 | self.build_uploadprocessor = self.getUploadProcessor( |
15 | self.layer.txn, builds=True |
16 | ) |
17 | - self.builds_before_upload = BinaryPackageBuild.select().count() |
18 | + self.builds_before_upload = ( |
19 | + IStore(BinaryPackageBuild).find(BinaryPackageBuild).count() |
20 | + ) |
21 | self.source_queue = None |
22 | self._uploadSource() |
23 | self.layer.txn.commit() |
24 | |
25 | def assertBuildsCreated(self, amount): |
26 | """Assert that a given 'amount' of build records was created.""" |
27 | - builds_count = BinaryPackageBuild.select().count() |
28 | + builds_count = ( |
29 | + IStore(BinaryPackageBuild).find(BinaryPackageBuild).count() |
30 | + ) |
31 | self.assertEqual(self.builds_before_upload + amount, builds_count) |
32 | |
33 | def _prepareUpload(self, upload_dir): |
34 | diff --git a/lib/lp/soyuz/doc/distroarchseriesbinarypackage.rst b/lib/lp/soyuz/doc/distroarchseriesbinarypackage.rst |
35 | index 1a36167..2b51ad9 100644 |
36 | --- a/lib/lp/soyuz/doc/distroarchseriesbinarypackage.rst |
37 | +++ b/lib/lp/soyuz/doc/distroarchseriesbinarypackage.rst |
38 | @@ -48,30 +48,34 @@ builds that are in sampledata! |
39 | XXX: noodles 2008-11-05 bug=294585: The dependency on a database id |
40 | needs to be removed. |
41 | |
42 | - >>> bpr = BinaryPackageBuild.get(8).createBinaryPackageRelease( |
43 | - ... binarypackagename=firefox_name.id, |
44 | - ... version="120.6-0", |
45 | - ... summary="Firefox loves lollies", |
46 | - ... description="Lolly-pop loving application", |
47 | - ... binpackageformat=binpackageformat, |
48 | - ... component=main_component.id, |
49 | - ... section=misc_section.id, |
50 | - ... priority=priority, |
51 | - ... shlibdeps=None, |
52 | - ... depends=None, |
53 | - ... recommends=None, |
54 | - ... suggests=None, |
55 | - ... conflicts=None, |
56 | - ... replaces=None, |
57 | - ... provides=None, |
58 | - ... pre_depends=None, |
59 | - ... enhances=None, |
60 | - ... breaks=None, |
61 | - ... built_using=None, |
62 | - ... essential=False, |
63 | - ... installedsize=0, |
64 | - ... architecturespecific=False, |
65 | - ... debug_package=None, |
66 | + >>> bpr = ( |
67 | + ... IStore(BinaryPackageBuild) |
68 | + ... .get(BinaryPackageBuild, 8) |
69 | + ... .createBinaryPackageRelease( |
70 | + ... binarypackagename=firefox_name.id, |
71 | + ... version="120.6-0", |
72 | + ... summary="Firefox loves lollies", |
73 | + ... description="Lolly-pop loving application", |
74 | + ... binpackageformat=binpackageformat, |
75 | + ... component=main_component.id, |
76 | + ... section=misc_section.id, |
77 | + ... priority=priority, |
78 | + ... shlibdeps=None, |
79 | + ... depends=None, |
80 | + ... recommends=None, |
81 | + ... suggests=None, |
82 | + ... conflicts=None, |
83 | + ... replaces=None, |
84 | + ... provides=None, |
85 | + ... pre_depends=None, |
86 | + ... enhances=None, |
87 | + ... breaks=None, |
88 | + ... built_using=None, |
89 | + ... essential=False, |
90 | + ... installedsize=0, |
91 | + ... architecturespecific=False, |
92 | + ... debug_package=None, |
93 | + ... ) |
94 | ... ) |
95 | |
96 | >>> pe = BinaryPackagePublishingHistory( |
97 | @@ -93,30 +97,34 @@ needs to be removed. |
98 | XXX: noodles 2008-11-06 bug=294585: The dependency on a database id |
99 | needs to be removed. |
100 | |
101 | - >>> bpr = BinaryPackageBuild.get(9).createBinaryPackageRelease( |
102 | - ... binarypackagename=pmount_name.id, |
103 | - ... version="cr98.34", |
104 | - ... summary="Pmount bakes cakes", |
105 | - ... description="Phat cake-baker application", |
106 | - ... binpackageformat=binpackageformat, |
107 | - ... component=main_component.id, |
108 | - ... section=misc_section.id, |
109 | - ... priority=priority, |
110 | - ... shlibdeps=None, |
111 | - ... depends=None, |
112 | - ... recommends=None, |
113 | - ... suggests=None, |
114 | - ... conflicts=None, |
115 | - ... replaces=None, |
116 | - ... provides=None, |
117 | - ... pre_depends=None, |
118 | - ... enhances=None, |
119 | - ... breaks=None, |
120 | - ... built_using=None, |
121 | - ... essential=False, |
122 | - ... installedsize=0, |
123 | - ... architecturespecific=False, |
124 | - ... debug_package=None, |
125 | + >>> bpr = ( |
126 | + ... IStore(BinaryPackageBuild) |
127 | + ... .get(BinaryPackageBuild, 9) |
128 | + ... .createBinaryPackageRelease( |
129 | + ... binarypackagename=pmount_name.id, |
130 | + ... version="cr98.34", |
131 | + ... summary="Pmount bakes cakes", |
132 | + ... description="Phat cake-baker application", |
133 | + ... binpackageformat=binpackageformat, |
134 | + ... component=main_component.id, |
135 | + ... section=misc_section.id, |
136 | + ... priority=priority, |
137 | + ... shlibdeps=None, |
138 | + ... depends=None, |
139 | + ... recommends=None, |
140 | + ... suggests=None, |
141 | + ... conflicts=None, |
142 | + ... replaces=None, |
143 | + ... provides=None, |
144 | + ... pre_depends=None, |
145 | + ... enhances=None, |
146 | + ... breaks=None, |
147 | + ... built_using=None, |
148 | + ... essential=False, |
149 | + ... installedsize=0, |
150 | + ... architecturespecific=False, |
151 | + ... debug_package=None, |
152 | + ... ) |
153 | ... ) |
154 | |
155 | >>> pe = BinaryPackagePublishingHistory( |
156 | diff --git a/lib/lp/soyuz/doc/gina-multiple-arch.rst b/lib/lp/soyuz/doc/gina-multiple-arch.rst |
157 | index c9bbea2..495b8eb 100644 |
158 | --- a/lib/lp/soyuz/doc/gina-multiple-arch.rst |
159 | +++ b/lib/lp/soyuz/doc/gina-multiple-arch.rst |
160 | @@ -27,7 +27,9 @@ Get the current counts of stuff in the database: |
161 | >>> orig_bpr_count = ( |
162 | ... IStore(BinaryPackageRelease).find(BinaryPackageRelease).count() |
163 | ... ) |
164 | - >>> orig_build_count = BinaryPackageBuild.select().count() |
165 | + >>> orig_build_count = ( |
166 | + ... IStore(BinaryPackageBuild).find(BinaryPackageBuild).count() |
167 | + ... ) |
168 | >>> orig_sbpph_count = IStore(SBPPH).find(SBPPH).count() |
169 | |
170 | Create a distribution series and an arch series for dapper: |
171 | @@ -157,7 +159,10 @@ distroarchseries: |
172 | ... - orig_bpr_count |
173 | ... ) |
174 | 4 |
175 | - >>> BinaryPackageBuild.select().count() - orig_build_count |
176 | + >>> ( |
177 | + ... IStore(BinaryPackageBuild).find(BinaryPackageBuild).count() |
178 | + ... - orig_build_count |
179 | + ... ) |
180 | 2 |
181 | >>> IStore(SBPPH).find(SBPPH).count() - orig_sbpph_count |
182 | 4 |
183 | diff --git a/lib/lp/soyuz/doc/gina.rst b/lib/lp/soyuz/doc/gina.rst |
184 | index db82fd9..39bcbdb 100644 |
185 | --- a/lib/lp/soyuz/doc/gina.rst |
186 | +++ b/lib/lp/soyuz/doc/gina.rst |
187 | @@ -34,7 +34,9 @@ Get the current counts of stuff in the database: |
188 | >>> orig_bpr_count = ( |
189 | ... IStore(BinaryPackageRelease).find(BinaryPackageRelease).count() |
190 | ... ) |
191 | - >>> orig_build_count = BinaryPackageBuild.select().count() |
192 | + >>> orig_build_count = ( |
193 | + ... IStore(BinaryPackageBuild).find(BinaryPackageBuild).count() |
194 | + ... ) |
195 | >>> orig_sbpph_count = IStore(SBPPH).find(SBPPH).count() |
196 | >>> orig_sspph_main_count = ( |
197 | ... IStore(SSPPH) |
198 | @@ -431,7 +433,10 @@ work. |
199 | ... - orig_bpr_count |
200 | ... ) |
201 | 40 |
202 | - >>> BinaryPackageBuild.select().count() - orig_build_count |
203 | + >>> ( |
204 | + ... IStore(BinaryPackageBuild).find(BinaryPackageBuild).count() |
205 | + ... - orig_build_count |
206 | + ... ) |
207 | 13 |
208 | >>> IStore(SBPPH).find(SBPPH).count() - orig_sbpph_count |
209 | 46 |
210 | @@ -681,7 +686,10 @@ changed, etc. |
211 | ... - orig_bpr_count |
212 | ... ) |
213 | 40 |
214 | - >>> BinaryPackageBuild.select().count() - orig_build_count |
215 | + >>> ( |
216 | + ... IStore(BinaryPackageBuild).find(BinaryPackageBuild).count() |
217 | + ... - orig_build_count |
218 | + ... ) |
219 | 13 |
220 | |
221 | But the overrides do generate extra publishing entries: |
222 | diff --git a/lib/lp/soyuz/model/binarypackagebuild.py b/lib/lp/soyuz/model/binarypackagebuild.py |
223 | index b71a38d..9c9623c 100644 |
224 | --- a/lib/lp/soyuz/model/binarypackagebuild.py |
225 | +++ b/lib/lp/soyuz/model/binarypackagebuild.py |
226 | @@ -45,11 +45,12 @@ from lp.registry.interfaces.sourcepackage import SourcePackageUrgency |
227 | from lp.registry.model.sourcepackagename import SourcePackageName |
228 | from lp.services.config import config |
229 | from lp.services.database.bulk import load_related |
230 | +from lp.services.database.constants import DEFAULT |
231 | from lp.services.database.decoratedresultset import DecoratedResultSet |
232 | from lp.services.database.enumcol import DBEnum |
233 | from lp.services.database.interfaces import IStore |
234 | -from lp.services.database.sqlbase import SQLBase, sqlvalues |
235 | -from lp.services.database.sqlobject import SQLObjectNotFound |
236 | +from lp.services.database.sqlbase import sqlvalues |
237 | +from lp.services.database.stormbase import StormBase |
238 | from lp.services.librarian.browser import ProxiedLibraryFileAlias |
239 | from lp.services.librarian.interfaces import ILibraryFileAlias |
240 | from lp.services.librarian.model import LibraryFileAlias, LibraryFileContent |
241 | @@ -137,12 +138,14 @@ def storm_validate_external_dependencies(build, attr, value): |
242 | |
243 | |
244 | @implementer(IBinaryPackageBuild) |
245 | -class BinaryPackageBuild(PackageBuildMixin, SQLBase): |
246 | - _table = "BinaryPackageBuild" |
247 | - _defaultOrder = "id" |
248 | +class BinaryPackageBuild(PackageBuildMixin, StormBase): |
249 | + __storm_table__ = "BinaryPackageBuild" |
250 | + __storm_order__ = "id" |
251 | |
252 | job_type = BuildFarmJobType.PACKAGEBUILD |
253 | |
254 | + id = Int(primary=True) |
255 | + |
256 | build_farm_job_id = Int(name="build_farm_job") |
257 | build_farm_job = Reference(build_farm_job_id, BuildFarmJob.id) |
258 | |
259 | @@ -215,6 +218,46 @@ class BinaryPackageBuild(PackageBuildMixin, SQLBase): |
260 | buildinfo_id = Int(name="buildinfo") |
261 | buildinfo = Reference(buildinfo_id, "LibraryFileAlias.id") |
262 | |
263 | + def __init__( |
264 | + self, |
265 | + build_farm_job, |
266 | + distro_arch_series, |
267 | + source_package_release, |
268 | + archive, |
269 | + pocket, |
270 | + arch_indep, |
271 | + status, |
272 | + processor=None, |
273 | + virtualized=None, |
274 | + date_created=DEFAULT, |
275 | + builder=None, |
276 | + buildinfo=None, |
277 | + ): |
278 | + # Compute these before creating the row, to avoid violating not-null |
279 | + # constraints if these other rows aren't in the cache. |
280 | + distribution = distro_arch_series.distroseries.distribution |
281 | + distro_series = distro_arch_series.distroseries |
282 | + is_distro_archive = archive.is_main |
283 | + source_package_name = source_package_release.sourcepackagename |
284 | + |
285 | + super().__init__() |
286 | + self.build_farm_job = build_farm_job |
287 | + self.distro_arch_series = distro_arch_series |
288 | + self.source_package_release = source_package_release |
289 | + self.archive = archive |
290 | + self.pocket = pocket |
291 | + self.arch_indep = arch_indep |
292 | + self.status = status |
293 | + self.processor = processor |
294 | + self.virtualized = virtualized |
295 | + self.date_created = date_created |
296 | + self.builder = builder |
297 | + self.buildinfo = buildinfo |
298 | + self.distribution = distribution |
299 | + self.distro_series = distro_series |
300 | + self.is_distro_archive = is_distro_archive |
301 | + self.source_package_name = source_package_name |
302 | + |
303 | def getLatestSourcePublication(self): |
304 | from lp.soyuz.model.publishing import SourcePackagePublishingHistory |
305 | |
306 | @@ -748,7 +791,7 @@ class BinaryPackageBuild(PackageBuildMixin, SQLBase): |
307 | assert self.buildinfo == buildinfo |
308 | |
309 | def verifySuccessfulUpload(self) -> bool: |
310 | - return bool(self.binarypackages) |
311 | + return not self.binarypackages.is_empty() |
312 | |
313 | def notify(self, extra_info=None): |
314 | """See `IPackageBuild`. |
315 | @@ -855,7 +898,7 @@ class BinaryPackageBuildSet(SpecificBuildFarmJobSourceMixin): |
316 | ) |
317 | processor = distro_arch_series.processor |
318 | virtualized = is_build_virtualized(archive, processor) |
319 | - return BinaryPackageBuild( |
320 | + build = BinaryPackageBuild( |
321 | build_farm_job=build_farm_job, |
322 | distro_arch_series=distro_arch_series, |
323 | source_package_release=source_package_release, |
324 | @@ -866,20 +909,18 @@ class BinaryPackageBuildSet(SpecificBuildFarmJobSourceMixin): |
325 | processor=processor, |
326 | virtualized=virtualized, |
327 | builder=builder, |
328 | - is_distro_archive=archive.is_main, |
329 | - distribution=distro_arch_series.distroseries.distribution, |
330 | - distro_series=distro_arch_series.distroseries, |
331 | - source_package_name=source_package_release.sourcepackagename, |
332 | buildinfo=buildinfo, |
333 | date_created=date_created, |
334 | ) |
335 | + IStore(build).flush() |
336 | + return build |
337 | |
338 | def getByID(self, id): |
339 | """See `IBinaryPackageBuildSet`.""" |
340 | - try: |
341 | - return BinaryPackageBuild.get(id) |
342 | - except SQLObjectNotFound as e: |
343 | - raise NotFoundError(str(e)) |
344 | + build = IStore(BinaryPackageBuild).get(BinaryPackageBuild, id) |
345 | + if build is None: |
346 | + raise NotFoundError(id) |
347 | + return build |
348 | |
349 | def getByBuildFarmJob(self, build_farm_job): |
350 | """See `ISpecificBuildFarmJobSource`.""" |
351 | diff --git a/lib/lp/soyuz/model/sourcepackagerelease.py b/lib/lp/soyuz/model/sourcepackagerelease.py |
352 | index 8c27732..ba1ec93 100644 |
353 | --- a/lib/lp/soyuz/model/sourcepackagerelease.py |
354 | +++ b/lib/lp/soyuz/model/sourcepackagerelease.py |
355 | @@ -216,19 +216,24 @@ class SourcePackageRelease(SQLBase): |
356 | @property |
357 | def builds(self): |
358 | """See `ISourcePackageRelease`.""" |
359 | + # Circular import. |
360 | + from lp.soyuz.model.archive import Archive |
361 | + |
362 | # Excluding PPA builds may seem like a strange thing to do, but, |
363 | # since Archive.copyPackage can copy packages across archives, a |
364 | # build may well have a different archive to the corresponding |
365 | # sourcepackagerelease. |
366 | - return BinaryPackageBuild.select( |
367 | - """ |
368 | - source_package_release = %s AND |
369 | - archive.id = binarypackagebuild.archive AND |
370 | - archive.purpose IN %s |
371 | - """ |
372 | - % sqlvalues(self.id, MAIN_ARCHIVE_PURPOSES), |
373 | - orderBy=["-date_created", "id"], |
374 | - clauseTables=["Archive"], |
375 | + return ( |
376 | + IStore(BinaryPackageBuild) |
377 | + .find( |
378 | + BinaryPackageBuild, |
379 | + BinaryPackageBuild.source_package_release == self, |
380 | + BinaryPackageBuild.archive == Archive.id, |
381 | + Archive.purpose.is_in(MAIN_ARCHIVE_PURPOSES), |
382 | + ) |
383 | + .order_by( |
384 | + Desc(BinaryPackageBuild.date_created), BinaryPackageBuild.id |
385 | + ) |
386 | ) |
387 | |
388 | @property |
389 | diff --git a/lib/lp/soyuz/scripts/gina/handlers.py b/lib/lp/soyuz/scripts/gina/handlers.py |
390 | index 5af9a8b..67368b9 100644 |
391 | --- a/lib/lp/soyuz/scripts/gina/handlers.py |
392 | +++ b/lib/lp/soyuz/scripts/gina/handlers.py |
393 | @@ -40,7 +40,6 @@ from lp.registry.model.distroseries import DistroSeries |
394 | from lp.registry.model.sourcepackagename import SourcePackageName |
395 | from lp.services.database.constants import UTC_NOW |
396 | from lp.services.database.interfaces import IStore |
397 | -from lp.services.database.sqlbase import quote |
398 | from lp.services.database.sqlobject import SQLObjectNotFound |
399 | from lp.services.librarian.interfaces import ILibraryFileAliasSet |
400 | from lp.services.scripts import log |
401 | @@ -928,11 +927,6 @@ class BinaryPackageHandler: |
402 | def ensureBuild(self, binary, srcpkg, distroarchseries, archtag): |
403 | """Ensure a build record.""" |
404 | distribution = distroarchseries.distroseries.distribution |
405 | - clauseTables = [ |
406 | - "BinaryPackageBuild", |
407 | - "DistroArchSeries", |
408 | - "DistroSeries", |
409 | - ] |
410 | |
411 | # XXX kiko 2006-02-03: |
412 | # This method doesn't work for real bin-only NMUs that are |
413 | @@ -942,23 +936,23 @@ class BinaryPackageHandler: |
414 | # once, and the two checks below will of course blow up when |
415 | # doing it the second time. |
416 | |
417 | - query = ( |
418 | - "BinaryPackageBuild.source_package_release = %d AND " |
419 | - "BinaryPackageBuild.distro_arch_series = " |
420 | - " DistroArchSeries.id AND " |
421 | - "BinaryPackageBuild.archive = %d AND " |
422 | - "DistroArchSeries.distroseries = DistroSeries.id AND " |
423 | - "DistroSeries.distribution = %d" |
424 | - % (srcpkg.id, distribution.main_archive.id, distribution.id) |
425 | - ) |
426 | + clauses = [ |
427 | + BinaryPackageBuild.source_package_release == srcpkg, |
428 | + BinaryPackageBuild.archive == distribution.main_archive, |
429 | + BinaryPackageBuild.distro_arch_series == DistroArchSeries.id, |
430 | + DistroArchSeries.distroseries == DistroSeries.id, |
431 | + DistroSeries.distribution == distribution, |
432 | + ] |
433 | |
434 | if archtag != "all": |
435 | - query += "AND DistroArchSeries.architecturetag = %s" % quote( |
436 | - archtag |
437 | - ) |
438 | + clauses.append(DistroArchSeries.architecturetag == archtag) |
439 | |
440 | try: |
441 | - build = BinaryPackageBuild.selectOne(query, clauseTables) |
442 | + build = ( |
443 | + IStore(BinaryPackageBuild) |
444 | + .find(BinaryPackageBuild, *clauses) |
445 | + .one() |
446 | + ) |
447 | except NotOneError: |
448 | # XXX kiko 2005-10-27: Untested. |
449 | raise MultipleBuildError( |
LGTM 👍