Merge lp:~vila/ols-store-tests/better-reporting into lp:ols-store-tests

Proposed by Vincent Ladeuil
Status: Merged
Approved by: Vincent Ladeuil
Approved revision: 33
Merged at revision: 31
Proposed branch: lp:~vila/ols-store-tests/better-reporting
Merge into: lp:ols-store-tests
Diff against target: 85 lines (+18/-9)
4 files modified
olsstore/__init__.py (+12/-3)
olsstore/_upload.py (+2/-2)
olsstore/config.py (+1/-1)
olsstore/tests/tapes/olsstore.tests.test_upload.TestUpload.test_upload_works (+3/-3)
To merge this branch: bzr merge lp:~vila/ols-store-tests/better-reporting
Reviewer Review Type Date Requested Status
Fabián Ezequiel Gallina (community) Approve
Review via email: mp+321268@code.launchpad.net

Commit message

Improve reporting on download errors and increase wait for upload scans.

Description of the change

This improves the reporting when downloading from updown with the url received from cpi (instead of failing later on with a SHAMismatchError which is confusing).

This also increases waiting for upload to succeed to avoid spurious failures with 'Package scan took too long'.

To post a comment you must log in.
Revision history for this message
Fabián Ezequiel Gallina (fgallina) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'olsstore/__init__.py'
2--- olsstore/__init__.py 2016-07-11 09:08:32 +0000
3+++ olsstore/__init__.py 2017-03-29 10:25:57 +0000
4@@ -202,8 +202,17 @@
5 name, download_path))
6 return
7 logger.info('Downloading {}'.format(name, download_path))
8- # FIXME: Check the status code ! -- vila 2016-05-04
9- download = self.cpi.get(download_url)
10+ auth = _macaroon_auth(self.conf)
11+ download = self.updown.get(download_url,
12+ headers={'Authorization': auth})
13+ if not download.ok:
14+ # This only happens when something is wrong server side and improve
15+ # the reporting to help diagnosis. Arguably this should retry
16+ # silently but in practice this only happens for wrong reasons.
17+ raise StoreError(
18+ fmt='Failed to download from {url}: {status} {reason}.',
19+ url=download_url, status=download.status_code,
20+ reason=download.reason)
21 with open(download_path, 'wb') as f:
22 # FIXME: Cough, we may want to buffer here (and a progress bar
23 # would be nice) -- vila 2016-04-26
24@@ -273,7 +282,7 @@
25
26
27 class SSOClient(Client):
28- """The Single Sign On server deals with authentification.
29+ """The Single Sign On server deals with authentication.
30
31 It is used directly or indirectly by other servers.
32 """
33
34=== modified file 'olsstore/_upload.py'
35--- olsstore/_upload.py 2016-06-27 10:53:30 +0000
36+++ olsstore/_upload.py 2017-03-29 10:25:57 +0000
37@@ -273,9 +273,9 @@
38
39 def get_scan_data(store, status_url):
40 """Return metadata about the state of the upload scan process."""
41- # initial retry after 5 seconds
42+ # initial retry after SCAN_STATUS_POLL_DELAY seconds
43 # linear backoff after that
44- # abort after 5 retries
45+ # abort after SCAN_STATUS_POLL_RETRIES retries
46 @retry(terminator=is_scan_completed,
47 retries=config.SCAN_STATUS_POLL_RETRIES,
48 delay=config.SCAN_STATUS_POLL_DELAY,
49
50=== modified file 'olsstore/config.py'
51--- olsstore/config.py 2016-06-27 10:53:30 +0000
52+++ olsstore/config.py 2017-03-29 10:25:57 +0000
53@@ -23,7 +23,7 @@
54
55 DEFAULT_SERIES = '16'
56 SCAN_STATUS_POLL_DELAY = 5
57-SCAN_STATUS_POLL_RETRIES = 5
58+SCAN_STATUS_POLL_RETRIES = 10
59 UBUNTU_SSO_API_ROOT_URL = 'https://login.ubuntu.com/api/v2/'
60 UBUNTU_STORE_API_ROOT_URL = 'https://myapps.developer.ubuntu.com/dev/api/'
61 UBUNTU_STORE_SEARCH_ROOT_URL = 'https://search.apps.ubuntu.com/'
62
63=== modified file 'olsstore/tests/tapes/olsstore.tests.test_upload.TestUpload.test_upload_works'
64--- olsstore/tests/tapes/olsstore.tests.test_upload.TestUpload.test_upload_works 2017-01-17 17:01:04 +0000
65+++ olsstore/tests/tapes/olsstore.tests.test_upload.TestUpload.test_upload_works 2017-03-29 10:25:57 +0000
66@@ -12,15 +12,15 @@
67 "status_code": 200
68 },
69 {
70- "content": "{\"status_details_url\": \"https://myapps.developer.staging.ubuntu.com/dev/api/snaps/sIzw8iQ2Ws6tRpbNV1VETWtSPrPIQdJg/builds/9f35b9f6-5e93-4dc9-bfc9-300694b2b3f6/status\", \"status_url\": \"https://myapps.developer.staging.ubuntu.com/dev/api/click-scan-complete/updown/a-snap-id/\", \"success\": true}",
71+ "content": "{\"status_details_url\": \"https://dashboard.staging.snapcraft.io/dev/api/snaps/sIzw8iQ2Ws6tRpbNV1VETWtSPrPIQdJg/builds/4f2ffd3a-9597-4719-9d95-746f39e74148/status\", \"status_url\": \"https://myapps.developer.staging.ubuntu.com/dev/api/click-scan-complete/updown/a-snap-id/\", \"success\": true}",
72 "status_code": 202
73 },
74 {
75- "content": "{\"application_url\": \"\", \"completed\": false, \"message\": \"Task state is unknown.\", \"package_name\": null, \"revision\": 42}",
76+ "content": "{\"application_url\": \"\", \"completed\": false, \"message\": \"Task 6a081cee-95f6-4aa2-bd9c-7fb18ce6ae51 is waiting for execution.\", \"package_name\": null, \"revision\": 42}",
77 "status_code": 200
78 },
79 {
80- "content": "{\"application_url\": \"https://myapps.developer.staging.ubuntu.com/dev/click-apps/577/\", \"completed\": true, \"message\": \"\", \"package_name\": \"basic\", \"revision\": 42}",
81+ "content": "{\"application_url\": \"https://dashboard.staging.snapcraft.io/dev/click-apps/577/\", \"completed\": true, \"message\": \"\", \"package_name\": \"basic\", \"revision\": 42}",
82 "status_code": 200
83 }
84 ]
85\ No newline at end of file

Subscribers

People subscribed via source and target branches