Merge lp:~ricardokirkner/ols-store-tests/include-store-revnos into lp:~ubuntuone-pqm-team/ols-store-tests/store-acceptance-tests

Proposed by Ricardo Kirkner
Status: Merged
Approved by: Ricardo Kirkner
Approved revision: 30
Merged at revision: 29
Proposed branch: lp:~ricardokirkner/ols-store-tests/include-store-revnos
Merge into: lp:~ubuntuone-pqm-team/ols-store-tests/store-acceptance-tests
Diff against target: 78 lines (+60/-3)
2 files modified
Makefile (+6/-3)
get_store_versions.py (+54/-0)
To merge this branch: bzr merge lp:~ricardokirkner/ols-store-tests/include-store-revnos
Reviewer Review Type Date Requested Status
Vincent Ladeuil (community) Approve
Ubuntu One PQM Team Pending
Review via email: mp+305735@code.launchpad.net

Commit message

fetch (and display) store service's versions when running tests

To post a comment you must log in.
Revision history for this message
Vincent Ladeuil (vila) wrote :

Looks like a good reuse of resources to me ;)

review: Approve
31. By Ricardo Kirkner

minor tweaks

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2016-07-11 13:01:46 +0000
3+++ Makefile 2016-09-14 18:00:48 +0000
4@@ -20,9 +20,12 @@
5 ${VSSH} 'sudo apt-get update && sudo apt-get upgrade -y'
6
7 branch-up-to-date:
8- ${VSSH} 'cd ~/work && bzr pull --overwrite'
9-
10-test: vm-up-to-date branch-up-to-date
11+ ${VSSH} 'cd work && bzr pull --overwrite'
12+
13+store-versions: vm-started
14+ ${VSSH} 'cd work && ./get_store_versions.py'
15+
16+test: store-versions vm-up-to-date branch-up-to-date
17 @${VSSH} 'cd work && \
18 TEST_USER_EMAIL=$(TEST_USER_EMAIL) \
19 TEST_USER_PASSWORD=$(TEST_USER_PASSWORD) \
20
21=== added file 'get_store_versions.py'
22--- get_store_versions.py 1970-01-01 00:00:00 +0000
23+++ get_store_versions.py 2016-09-14 18:00:48 +0000
24@@ -0,0 +1,54 @@
25+#!/usr/bin/env python3
26+
27+import requests
28+
29+REQ_HEADERS = {
30+ 'Cache-Control': 'no-cache',
31+}
32+
33+DEFAULT_HEADER = "X-BZR-REVISION-NUMBER"
34+
35+SERVICES_INFO = dict(
36+ CPI=('HEAD', 'https://search.apps.ubuntu.com/api/v1',
37+ 'https://search.apps.staging.ubuntu.com/api/v1'),
38+ SCA=('GET', 'https://myapps.developer.ubuntu.com/',
39+ 'https://myapps.developer.staging.ubuntu.com/'),
40+ SSO=('GET', 'https://login.ubuntu.com/',
41+ 'https://login.staging.ubuntu.com/'),
42+)
43+
44+
45+def get_deployed_revno(service, environment):
46+ """Get revno from service."""
47+ request_type, prod, stag = SERVICES_INFO[service]
48+ if environment == 'staging':
49+ url = stag
50+ else:
51+ url = prod
52+
53+ with requests.Session() as session:
54+ resp = session.get(url)
55+ if resp.status_code == 200:
56+ revno = resp.headers[DEFAULT_HEADER]
57+ else:
58+ print("{} 500'ed: {}".format(service, resp.text))
59+ revno = 0
60+
61+ return service, environment, revno
62+
63+
64+def main(environ):
65+ coros = []
66+ for service in SERVICES_INFO:
67+ coro = get_deployed_revno(service, environ)
68+ coros.append(coro)
69+
70+ data = {(service, kind): value for service, kind, value in coros}
71+ for service in sorted(SERVICES_INFO):
72+ print("{}: {}: {:>5}".format(service, environ,
73+ data[(service, environ)]))
74+
75+
76+if __name__ == '__main__':
77+ environ = 'staging'
78+ main(environ)

Subscribers

People subscribed via source and target branches

to all changes: