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
1=== modified file 'lib/lp/snappy/model/snapstoreclient.py'
2--- lib/lp/snappy/model/snapstoreclient.py 2018-12-10 13:54:34 +0000
3+++ lib/lp/snappy/model/snapstoreclient.py 2019-06-14 14:46:36 +0000
4@@ -253,15 +253,18 @@
5 lfa.close()
6
7 @classmethod
8- def _uploadApp(cls, snap, upload_data):
9+ def _uploadApp(cls, snapbuild, upload_data):
10 """Create a new store upload based on the uploaded file."""
11+ snap = snapbuild.snap
12 assert config.snappy.store_url is not None
13 assert snap.store_name is not None
14+ assert snapbuild.date_started is not None
15 upload_url = urlappend(config.snappy.store_url, "dev/api/snap-push/")
16 data = {
17 "name": snap.store_name,
18 "updown_id": upload_data["upload_id"],
19 "series": snap.store_series.name,
20+ "built_at": snapbuild.date_started.isoformat(),
21 }
22 # XXX cjwatson 2016-05-09: This should add timeline information, but
23 # that's currently difficult in jobs.
24@@ -293,7 +296,7 @@
25 continue
26 upload_data = cls._uploadFile(lfa, lfc)
27 return cls.refreshIfNecessary(
28- snapbuild.snap, cls._uploadApp, snapbuild.snap, upload_data)
29+ snapbuild.snap, cls._uploadApp, snapbuild, upload_data)
30
31 @classmethod
32 def refreshDischargeMacaroon(cls, snap):
33
34=== modified file 'lib/lp/snappy/tests/test_snapstoreclient.py'
35--- lib/lp/snappy/tests/test_snapstoreclient.py 2019-06-14 14:26:30 +0000
36+++ lib/lp/snappy/tests/test_snapstoreclient.py 2019-06-14 14:46:36 +0000
37@@ -35,6 +35,7 @@
38 import transaction
39 from zope.component import getUtility
40
41+from lp.buildmaster.enums import BuildStatus
42 from lp.services.config import config
43 from lp.services.features.testing import FeatureFixture
44 from lp.services.log.logger import BufferLogger
45@@ -363,6 +364,8 @@
46 filename="test-snap.manifest", content="dummy manifest content")
47 self.factory.makeSnapFile(
48 snapbuild=snapbuild, libraryfile=manifest_lfa)
49+ snapbuild.updateStatus(BuildStatus.BUILDING)
50+ snapbuild.updateStatus(BuildStatus.FULLYBUILT)
51 return snapbuild
52
53 @responses.activate
54@@ -394,6 +397,7 @@
55 auth=("Macaroon", MacaroonsVerify(self.root_key)),
56 json_data={
57 "name": "test-snap", "updown_id": 1, "series": "rolling",
58+ "built_at": snapbuild.date_started.isoformat(),
59 }),
60 ]))
61
62@@ -429,6 +433,7 @@
63 auth=("Macaroon", MacaroonsVerify(root_key)),
64 json_data={
65 "name": "test-snap", "updown_id": 1, "series": "rolling",
66+ "built_at": snapbuild.date_started.isoformat(),
67 }),
68 ]))
69