Merge lp:~fgallina/ols-store-tests/register-name-window-updates into lp:~ubuntuone-pqm-team/ols-store-tests/store-acceptance-tests

Proposed by Fabián Ezequiel Gallina
Status: Merged
Approved by: Vincent Ladeuil
Approved revision: 43
Merged at revision: 39
Proposed branch: lp:~fgallina/ols-store-tests/register-name-window-updates
Merge into: lp:~ubuntuone-pqm-team/ols-store-tests/store-acceptance-tests
Diff against target: 334 lines (+112/-68)
11 files modified
.bzrignore (+1/-1)
Makefile (+2/-22)
README (+23/-0)
dependencies.txt (+1/-0)
ols-vms.conf (+0/-8)
run-landing-tests.sh (+9/-0)
setup-dev-env (+0/-10)
tests/api/cpi/test_package.py (+1/-1)
tests/api/cpi/test_snaps.py (+1/-1)
tests/api/snap/test_register_name.py (+66/-22)
tests/api/snap/test_snap_release.py (+8/-3)
To merge this branch: bzr merge lp:~fgallina/ols-store-tests/register-name-window-updates
Reviewer Review Type Date Requested Status
Fabián Ezequiel Gallina (community) Approve
Matias Bordese (community) Approve
Review via email: mp+318464@code.launchpad.net

Commit message

Update store acceptance tests for name registration

To post a comment you must log in.
Revision history for this message
Matias Bordese (matiasb) wrote :

Looks good, but I have a question.

Revision history for this message
Fabián Ezequiel Gallina (fgallina) :
Revision history for this message
Matias Bordese (matiasb) :
review: Approve
Revision history for this message
Matias Bordese (matiasb) wrote :

LGTM, thanks

review: Approve
Revision history for this message
Fabián Ezequiel Gallina (fgallina) wrote :

LGTM, last commit from a separate already approved branch to enable landings once again.

review: Approve
Revision history for this message
Otto Co-Pilot (otto-copilot) wrote :
Revision history for this message
Otto Co-Pilot (otto-copilot) wrote :
Revision history for this message
Otto Co-Pilot (otto-copilot) wrote :
Revision history for this message
Vincent Ladeuil (vila) wrote :

18:01:58 E: ======================================================================
18:01:58 E: ERROR: test_create_customer_success (snap.test_snap_purchases_customers.CreateCustomerTestCase)
18:01:58 E: ----------------------------------------------------------------------
18:01:58 E: (Network error: ProxyError: HTTPSConnectionPool(host='api.stripe.com', port=443): Max retries exceeded with url: /v1/tokens (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 403 Forbidden',))))

should be fixed by https://code.launchpad.net/~vila/canonical-is-puppet/jaas_ols_slaves-to-api_stripe_com/+merge/318731

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2016-09-19 13:15:06 +0000
3+++ .bzrignore 2017-03-01 16:59:34 +0000
4@@ -1,2 +1,2 @@
5 env
6-branches/
7+branches/*
8
9=== modified file 'Makefile'
10--- Makefile 2016-09-19 16:49:12 +0000
11+++ Makefile 2017-03-01 16:59:34 +0000
12@@ -22,27 +22,7 @@
13 install-wheels: $(ENV)
14 $(PIP) install --find-links=$(WHEELS_DIR) --no-index $(ARGS)
15
16-vm-setup: ols-vms.conf dependencies.txt
17- if [ `ols-vms status ${VM}` = 'RUNNING' ] ; then ols-vms stop ${VM} ; fi
18- ols-vms setup ${VM}
19- touch vm-setup
20-
21-vm-built: vm-setup
22- if [ `ols-vms status ${VM}` = 'UNKNOWN' ] ; then $(MAKE) vm-setup ; fi
23-
24-vm-started: vm-built
25- if [ `ols-vms status ${VM}` = 'STOPPED' ] ; then ols-vms start ${VM} ; fi
26-
27-vm-up-to-date: vm-started
28- ${VSSH} 'sudo apt-get update && sudo apt-get upgrade -y'
29-
30-branch-up-to-date:
31- ${VSSH} 'cd work && bzr pull --overwrite'
32-
33-store-versions: vm-started
34- ${VSSH} 'cd work && ./get_store_versions.py'
35-
36-test: vm-up-to-date branch-up-to-date store-versions
37+test: bootstrap
38 @${VSSH} 'cd work && \
39 TEST_USER_EMAIL=$(TEST_USER_EMAIL) \
40 TEST_USER_PASSWORD=$(TEST_USER_PASSWORD) \
41@@ -50,5 +30,5 @@
42 STRIPE_PUBLISHABLE_KEY=$(STRIPE_PUBLISHABLE_KEY) \
43 make api-tests'
44
45-api-tests: bootstrap
46+api-tests:
47 $(PYTHON) -u -m unittest $(TEST_TARGET)
48
49=== modified file 'README'
50--- README 2016-08-18 12:49:56 +0000
51+++ README 2017-03-01 16:59:34 +0000
52@@ -73,3 +73,26 @@
53 Then you can run the tests against your local devportal instance like::
54
55 $ SCA_ROOT_URL=http://<ip>:<port> make api-tests
56+
57+ols jenkaas setup
58+=================
59+
60+Merge proposals are gated on https://jenkins.ols.canonical.com which relies
61+on ols-vms (from ppa:ubuntuone/ols-tests) to setup the lxd container defined
62+in ols-vms.conf.
63+
64+Setting up the same container locally is done with:
65+
66+$ ols-vms setup store-acceptance-tests -Olxd.user_mounts=~:/home/ubuntu,<path to secrets>:/home/ubuntu/.config/ols-store-acceptance-tests
67+
68+``<path to secrets`` should contain a ``secrets`` file exporting the
69+TEST_USER_EMAIL, TEST_USER_PASSWORD, TEST_USER_NAMESPACE and
70+STRIPE_PUBLISHABLE_KEY.
71+
72+Once the container is setup you can enter it with:
73+
74+$ ols-vms shell store-acceptance-tests
75+
76+Once there, 'cd' to your mounted working dir and 'make bootstrap'.
77+
78+ols jenkaas use './run-landing-tests.sh'.
79
80=== modified file 'dependencies.txt'
81--- dependencies.txt 2016-10-12 12:44:51 +0000
82+++ dependencies.txt 2017-03-01 16:59:34 +0000
83@@ -1,3 +1,4 @@
84+bzr
85 make
86 squashfs-tools
87 snapcraft
88
89=== modified file 'ols-vms.conf'
90--- ols-vms.conf 2016-09-19 14:52:54 +0000
91+++ ols-vms.conf 2017-03-01 16:59:34 +0000
92@@ -4,12 +4,4 @@
93 vm.architecture = amd64
94 vm.update = True
95 vm.locale = en_US.UTF-8
96-lxd.image = ubuntu:{vm.release}/{vm.architecture}
97 vm.packages = @dependencies.txt, bzr
98-# Not the best solution but good enough until jenkaas: this requires the
99-# following 'secrets' file to exist on the dev host and on jenkins slaves
100-# and contain 'export' statements for the env vars needed by the tests.
101-# FIXME: A better solution would be a config file by host or by job
102-# providing as many options as needed by the tests. -- vila 2016-07-08
103-vm.uploaded_scripts = ~/.config/ols-store-tests/secrets
104-vm.setup_scripts = setup-dev-env
105
106=== added file 'run-landing-tests.sh'
107--- run-landing-tests.sh 1970-01-01 00:00:00 +0000
108+++ run-landing-tests.sh 2017-03-01 16:59:34 +0000
109@@ -0,0 +1,9 @@
110+#!/bin/sh
111+
112+# The following is set from the host either by copying the file in the right
113+# place or by mounting the relevant directory inside the container.
114+SECRETS=~/.config/ols-store-acceptance-tests/secrets
115+test -f ${SECRETS} && . ${SECRETS}
116+
117+make api-tests
118+
119
120=== removed file 'setup-dev-env'
121--- setup-dev-env 2016-07-11 12:23:00 +0000
122+++ setup-dev-env 1970-01-01 00:00:00 +0000
123@@ -1,10 +0,0 @@
124-#!/bin/sh -ex
125-# Use a proper locale
126-sudo locale-gen en_US.UTF-8
127-# Register needed hosts
128-cat <<EOKH > ~/.ssh/known_hosts
129-bazaar.launchpad.net,91.189.90.11,91.189.95.84 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEApuXd4MHTfr1qLXWeClxTTQYZQblCA+nHvbjAjowkEd2Y4kpvntJOVewoSwa22zTbiYSmmssCuCkFHwcpnZBZN5qMWewjizav30WfeyLR5Kng5qucxmFAEkNJjCJiu194wRNKu0cD99Uk/6X/AfsWGLgmL5pa5UFk62aW+iZLUQ8=
130-EOKH
131-chmod 600 ~/.ssh/known_hosts
132-# Clone branch
133-bzr branch lp:~ubuntuone-pqm-team/ols-store-tests/store-acceptance-tests work
134
135=== modified file 'tests/api/cpi/test_package.py'
136--- tests/api/cpi/test_package.py 2016-08-08 20:26:28 +0000
137+++ tests/api/cpi/test_package.py 2017-03-01 16:59:34 +0000
138@@ -66,7 +66,7 @@
139 'icon_url',
140 'icon_urls',
141 'id',
142- 'is_published',
143+ 'release_map',
144 'keywords',
145 'last_updated',
146 'license',
147
148=== modified file 'tests/api/cpi/test_snaps.py'
149--- tests/api/cpi/test_snaps.py 2016-09-14 20:05:35 +0000
150+++ tests/api/cpi/test_snaps.py 2017-03-01 16:59:34 +0000
151@@ -55,7 +55,7 @@
152 'icon_url',
153 'icon_urls',
154 'id',
155- 'is_published',
156+ 'release_map',
157 'keywords',
158 'last_updated',
159 'license',
160
161=== modified file 'tests/api/snap/test_register_name.py'
162--- tests/api/snap/test_register_name.py 2016-08-24 05:39:11 +0000
163+++ tests/api/snap/test_register_name.py 2017-03-01 16:59:34 +0000
164@@ -1,5 +1,6 @@
165 from __future__ import unicode_literals
166
167+import math
168 import json
169 import time
170 import uuid
171@@ -54,7 +55,9 @@
172 self.package_name = 'delete-me-{}'.format(str(uuid.uuid4().int)[:32])
173
174 def assert_snap_id(self, response):
175- self.assertIn('snap_id', response.json())
176+ data = response.json()
177+ self.assertIn('snap_id', data)
178+ self.assertIsNotNone(data['snap_id'])
179
180 def assert_no_snap_id(self, response):
181 snap_id = response.json().get('snap_id')
182@@ -138,44 +141,75 @@
183 self.assertEqual(response.status_code, 429)
184 self.assertIn('Retry-After', response.headers)
185 retry_after = response.headers['Retry-After']
186+ minutes = math.ceil(float(retry_after) / 60.0)
187+ minutes_text = 'minute'
188+ if minutes != 1:
189+ minutes_text += 's'
190 body = response.json()
191+ detail = (
192+ 'You can register up to 10 snap names every 10\xa0minutes. '
193+ 'You must wait %s\xa0%s before the next snap-name '
194+ 'registration.'
195+ ) % (minutes, minutes_text)
196 expected = {
197 'status': 429,
198 'code': 'register_window',
199 'title': 'You must wait before next name registration.',
200- 'detail': 'You must wait 1\xa0minute before the next snap-name '
201- 'registration for 16.',
202+ 'detail': detail,
203 'retry_after': int(retry_after),
204 'type': u'devportal:v1:name-window-wait',
205 'error_list': [{
206 'code': 'register_window',
207- 'message': 'You must wait 1\xa0minute before the next snap-name '
208- 'registration for 16.',
209+ 'message': detail,
210 }]
211 }
212 self.assertEqual(body, expected)
213
214- def assert_invalid_request(self, response):
215+ def assert_invalid_series(self, response):
216 self.assertEqual(response.status_code, 400)
217 body = response.json()
218+ detail = (
219+ 'Select a valid choice. That choice is not one of the available '
220+ 'choices.')
221 expected = {
222- 'invalid_params': [
223- {'reason': 'Select a valid choice. That choice is not one of '
224- 'the available choices.',
225- 'code': 'invalid_choice',
226- 'name': u'series'}
227- ],
228+ 'invalid_params': [{
229+ 'reason': detail,
230+ 'code': 'invalid_choice',
231+ 'name': 'series'}],
232 'status': 400,
233 'type': 'devportal:v1:request-invalid',
234 'detail': 'Submitted data is not valid.',
235 'title': 'Invalid request.',
236 'error_list': [{
237- 'message': 'Select a valid choice. That choice is not one of the available choices.',
238+ 'message': detail,
239 'code': 'invalid_choice',
240 'extra': {'name': 'series'}}]
241 }
242 self.assertEqual(body, expected)
243
244+ def assert_invalid_snap_name(self, response, snap_name):
245+ self.assertEqual(response.status_code, 400)
246+ body = response.json()
247+ detail = (
248+ "The package name '%s' is not valid. "
249+ "It can only contain lowercase ascii letters, numbers and hyphens."
250+ ) % snap_name
251+ expected = {
252+ 'invalid_params': [{
253+ 'reason': detail,
254+ 'code': 'invalid',
255+ 'name': 'snap_name'}],
256+ 'status': 400,
257+ 'type': 'devportal:v1:request-invalid',
258+ 'detail': 'Submitted data is not valid.',
259+ 'title': 'Invalid request.',
260+ 'error_list': [{
261+ 'message': detail,
262+ 'code': 'invalid',
263+ 'extra': {'name': 'snap_name'}}]
264+ }
265+ self.assertEqual(body, expected)
266+
267 def test_register_name_successful(self):
268 response = register_name(self.package_name, auth=self.auth)
269 self.assert_success(response)
270@@ -206,23 +240,33 @@
271 self.assert_reserved_name(response, name)
272
273 def test_register_name_too_fast(self):
274- register_name(self.package_name, auth=self.auth)
275- response = register_name(
276- self.package_name, auth=self.auth, retry=False)
277+ # Attempt to hit the limit, short-circuit earlier if possible.
278+ for idx in range(10 + 1):
279+ response = register_name(
280+ self.package_name + '-%s' % idx, auth=self.auth, retry=False)
281+ if response.status_code == 429:
282+ break
283+
284 self.assert_error(response)
285 self.assert_retry_after(response)
286
287 def test_register_name_for_series(self):
288- response = register_name(self.package_name, series='16',
289- auth=self.auth)
290+ response = register_name(
291+ self.package_name, series='16', auth=self.auth)
292 self.assert_success(response)
293 self.assert_snap_id(response)
294
295 def test_register_name_for_invalid_series(self):
296- response = register_name(self.package_name, series='invalid',
297- auth=self.auth)
298- self.assert_error(response)
299- self.assert_invalid_request(response)
300+ response = register_name(
301+ self.package_name, series='invalid', auth=self.auth)
302+ self.assert_error(response)
303+ self.assert_invalid_series(response)
304+
305+ def test_register_invalid_name(self):
306+ snap_name = self.package_name + ' invalid'
307+ response = register_name(snap_name, auth=self.auth)
308+ self.assert_error(response)
309+ self.assert_invalid_snap_name(response, snap_name)
310
311 def test_register_private_name(self):
312 response = register_name(self.package_name, is_private=True,
313
314=== modified file 'tests/api/snap/test_snap_release.py'
315--- tests/api/snap/test_snap_release.py 2016-08-18 12:49:56 +0000
316+++ tests/api/snap/test_snap_release.py 2017-03-01 16:59:34 +0000
317@@ -111,9 +111,14 @@
318 {'channel': 'stable', 'info': 'none'},
319 {'channel': 'candidate', 'info': 'none'},
320 {'channel': 'beta', 'info': 'none'},
321- {'revision': revision, 'channel': 'edge', 'info': 'specific',
322- 'version': version}
323- ]
324+ {'channel': 'edge', 'revision': revision,
325+ 'info': 'specific', 'version': version}],
326+ 'channel_map_tree': {'latest': {'16': {'all': [
327+ {'channel': 'stable', 'info': 'none'},
328+ {'channel': 'candidate', 'info': 'none'},
329+ {'channel': 'beta', 'info': 'none'},
330+ {'channel': 'edge', 'revision': revision,
331+ 'info': 'specific', 'version': version}]}}},
332 })
333
334 def assert_error_body(self, response):

Subscribers

People subscribed via source and target branches