Merge lp:~twom/launchpad/snap-release-ordering into lp:launchpad

Proposed by Tom Wardill
Status: Merged
Merged at revision: 18983
Proposed branch: lp:~twom/launchpad/snap-release-ordering
Merge into: lp:launchpad
Diff against target: 68 lines (+10/-2)
2 files modified
lib/lp/snappy/model/snapstoreclient.py (+5/-2)
lib/lp/snappy/tests/test_snapstoreclient.py (+5/-0)
To merge this branch: bzr merge lp:~twom/launchpad/snap-release-ordering
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+368832@code.launchpad.net

Commit message

Add built_at to snap upload metadata

Description of the change

Allow rejecting of misordered builds at the store level by sending the time for the build start.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) wrote :

Style nit throughout which I haven't commented in every location: when you have a multi-line list or dict, please put a trailing comma on every item rather than on all but the last, in order that future changes can have smaller diffs.

review: Needs Fixing
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/snappy/model/snapstoreclient.py'
--- lib/lp/snappy/model/snapstoreclient.py 2018-12-10 13:54:34 +0000
+++ lib/lp/snappy/model/snapstoreclient.py 2019-06-14 14:46:36 +0000
@@ -253,15 +253,18 @@
253 lfa.close()253 lfa.close()
254254
255 @classmethod255 @classmethod
256 def _uploadApp(cls, snap, upload_data):256 def _uploadApp(cls, snapbuild, upload_data):
257 """Create a new store upload based on the uploaded file."""257 """Create a new store upload based on the uploaded file."""
258 snap = snapbuild.snap
258 assert config.snappy.store_url is not None259 assert config.snappy.store_url is not None
259 assert snap.store_name is not None260 assert snap.store_name is not None
261 assert snapbuild.date_started is not None
260 upload_url = urlappend(config.snappy.store_url, "dev/api/snap-push/")262 upload_url = urlappend(config.snappy.store_url, "dev/api/snap-push/")
261 data = {263 data = {
262 "name": snap.store_name,264 "name": snap.store_name,
263 "updown_id": upload_data["upload_id"],265 "updown_id": upload_data["upload_id"],
264 "series": snap.store_series.name,266 "series": snap.store_series.name,
267 "built_at": snapbuild.date_started.isoformat(),
265 }268 }
266 # XXX cjwatson 2016-05-09: This should add timeline information, but269 # XXX cjwatson 2016-05-09: This should add timeline information, but
267 # that's currently difficult in jobs.270 # that's currently difficult in jobs.
@@ -293,7 +296,7 @@
293 continue296 continue
294 upload_data = cls._uploadFile(lfa, lfc)297 upload_data = cls._uploadFile(lfa, lfc)
295 return cls.refreshIfNecessary(298 return cls.refreshIfNecessary(
296 snapbuild.snap, cls._uploadApp, snapbuild.snap, upload_data)299 snapbuild.snap, cls._uploadApp, snapbuild, upload_data)
297300
298 @classmethod301 @classmethod
299 def refreshDischargeMacaroon(cls, snap):302 def refreshDischargeMacaroon(cls, snap):
300303
=== modified file 'lib/lp/snappy/tests/test_snapstoreclient.py'
--- lib/lp/snappy/tests/test_snapstoreclient.py 2019-06-14 14:26:30 +0000
+++ lib/lp/snappy/tests/test_snapstoreclient.py 2019-06-14 14:46:36 +0000
@@ -35,6 +35,7 @@
35import transaction35import transaction
36from zope.component import getUtility36from zope.component import getUtility
3737
38from lp.buildmaster.enums import BuildStatus
38from lp.services.config import config39from lp.services.config import config
39from lp.services.features.testing import FeatureFixture40from lp.services.features.testing import FeatureFixture
40from lp.services.log.logger import BufferLogger41from lp.services.log.logger import BufferLogger
@@ -363,6 +364,8 @@
363 filename="test-snap.manifest", content="dummy manifest content")364 filename="test-snap.manifest", content="dummy manifest content")
364 self.factory.makeSnapFile(365 self.factory.makeSnapFile(
365 snapbuild=snapbuild, libraryfile=manifest_lfa)366 snapbuild=snapbuild, libraryfile=manifest_lfa)
367 snapbuild.updateStatus(BuildStatus.BUILDING)
368 snapbuild.updateStatus(BuildStatus.FULLYBUILT)
366 return snapbuild369 return snapbuild
367370
368 @responses.activate371 @responses.activate
@@ -394,6 +397,7 @@
394 auth=("Macaroon", MacaroonsVerify(self.root_key)),397 auth=("Macaroon", MacaroonsVerify(self.root_key)),
395 json_data={398 json_data={
396 "name": "test-snap", "updown_id": 1, "series": "rolling",399 "name": "test-snap", "updown_id": 1, "series": "rolling",
400 "built_at": snapbuild.date_started.isoformat(),
397 }),401 }),
398 ]))402 ]))
399403
@@ -429,6 +433,7 @@
429 auth=("Macaroon", MacaroonsVerify(root_key)),433 auth=("Macaroon", MacaroonsVerify(root_key)),
430 json_data={434 json_data={
431 "name": "test-snap", "updown_id": 1, "series": "rolling",435 "name": "test-snap", "updown_id": 1, "series": "rolling",
436 "built_at": snapbuild.date_started.isoformat(),
432 }),437 }),
433 ]))438 ]))
434439