Merge lp:~ralsina/tanuki-agent/orgless-e2e-snap into lp:tanuki-agent

Proposed by Roberto Alsina
Status: Merged
Approved by: Roberto Alsina
Approved revision: 183
Merged at revision: 179
Proposed branch: lp:~ralsina/tanuki-agent/orgless-e2e-snap
Merge into: lp:tanuki-agent
Prerequisite: lp:~ralsina/tanuki-agent/orgless-e2e-gm
Diff against target: 200 lines (+164/-9)
2 files modified
scripts/e2e-snap.py (+152/-0)
scripts/e2e.py (+12/-9)
To merge this branch: bzr merge lp:~ralsina/tanuki-agent/orgless-e2e-snap
Reviewer Review Type Date Requested Status
Roberto Alsina (community) Approve
Celso Providelo (community) Approve
Review via email: mp+279352@code.launchpad.net

Commit message

Orgless e2e-snap script

Description of the change

Orgless e2e-snap script

To post a comment you must log in.
Revision history for this message
Celso Providelo (cprov) wrote :

ROberto,

Minor rename suggested inline, looks good to land anyway.

Thank you.

review: Approve
Revision history for this message
Roberto Alsina (ralsina) wrote :

approving for the class rename

review: Approve
Revision history for this message
Tanuki Bot (tanuki-bot) wrote :
Download full text (3.5 KiB)

The attempt to merge lp:~ralsina/tanuki-agent/orgless-e2e-snap into lp:tanuki-agent failed. Below is the output from the failed tests.

rm -rf env logs
rm -f version_info.py
find . -name '*.pyc' -delete
find . -name '*.~*' -delete
virtualenv -p python3 env
Using base prefix '/usr'
New python executable in env/bin/python3
Also creating executable in env/bin/python
Installing setuptools, pip...done.
Running virtualenv with interpreter /usr/bin/python3
bzr version-info -r "-1" --format=custom --template="revno = '{revno}'\n" > "version_info.py" || echo "revno = 'UNKNOWN'" > "version_info.py"
rm -rf /tmp/pip-cache
bzr branch lp:~tanuki/tanuki-agent/pip-cache /tmp/pip-cache
env/bin/pip install --no-index --find-links=/tmp/pip-cache -r requirements.txt
Ignoring indexes: https://pypi.python.org/simple/
Downloading/unpacking docopt==0.6.2 (from -r requirements.txt (line 1))
Downloading/unpacking requests==2.7.0 (from -r requirements.txt (line 2))
Downloading/unpacking requests-oauthlib==0.5.0 (from -r requirements.txt (line 3))
Downloading/unpacking oauthlib==1.0.3 (from -r requirements.txt (line 4))
Installing collected packages: docopt, requests, requests-oauthlib, oauthlib
Successfully installed docopt requests requests-oauthlib oauthlib
Cleaning up...
env/bin/pip install --no-index --find-links=/tmp/pip-cache -r test_requirements.txt
Ignoring indexes: https://pypi.python.org/simple/
Downloading/unpacking flake8==2.4.1 (from -r test_requirements.txt (line 1))
Downloading/unpacking pytest==2.7.2 (from -r test_requirements.txt (line 2))
Downloading/unpacking pytest-capturelog==0.7 (from -r test_requirements.txt (line 3))
Downloading/unpacking Markdown==2.6.2 (from -r test_requirements.txt (line 4))
Downloading/unpacking pep8>=1.5.7,!=1.6.0,!=1.6.1,!=1.6.2 (from flake8==2.4.1->-r test_requirements.txt (line 1))
Downloading/unpacking mccabe>=0.2.1,<0.4 (from flake8==2.4.1->-r test_requirements.txt (line 1))
Downloading/unpacking pyflakes>=0.8.1,<0.9 (from flake8==2.4.1->-r test_requirements.txt (line 1))
Downloading/unpacking py>=1.4.29 (from pytest==2.7.2->-r test_requirements.txt (line 2))
Installing collected packages: flake8, pytest, pytest-capturelog, Markdown, pep8, mccabe, pyflakes, py
Successfully installed flake8 pytest pytest-capturelog Markdown pep8 mccabe pyflakes py
Cleaning up...
rm -rf logs
env/bin/py.test agent.py test_agent.py
============================= test session starts ==============================
platform linux -- Python 3.4.3 -- py-1.4.30 -- pytest-2.7.2
rootdir: /tmp/tarmac/branch.43DxWp, inifile:
plugins: capturelog
collected 48 items

test_agent.py ................................................

========================== 48 passed in 0.34 seconds ===========================
env/bin/flake8 *.py scripts/*.py --max-line-length=99
scripts/e2e-snap.py:82:32: E222 multiple spaces after operator
scripts/e2e-snap.py:102:25: E122 continuation line missing indentation or outdented
scripts/e2e-snap.py:103:25: E122 continuation line missing indentation or outdented
scripts/e2e-snap.py:104:25: E122 continuation line missing indentation or outdented
scripts/e2e-snap.py:105:25: E122 continuation line missing indentation or outdente...

Read more...

183. By Roberto Alsina

lint

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'scripts/e2e-snap.py'
2--- scripts/e2e-snap.py 1970-01-01 00:00:00 +0000
3+++ scripts/e2e-snap.py 2015-12-03 13:01:36 +0000
4@@ -0,0 +1,152 @@
5+#!/usr/bin/env python3
6+
7+# © Canonical 2015
8+# Licensed under AGPLv3
9+
10+"""
11+Tanuki End to End Test
12+
13+Usage:
14+ e2e-image.py [-i] <configfile>
15+ e2e-image.py --default-config
16+
17+Options:
18+ -h --help Show this screen
19+ --default-config Show default configuration
20+ --server MessageHub URL override
21+ --specmgr SpecManager URL override
22+ -i Interactive
23+"""
24+
25+import docopt
26+import time
27+
28+from e2e import E2e, logger, GRY
29+
30+
31+class E2eUpdate(E2e):
32+
33+ def run(self):
34+ self.annotate('Starting.')
35+ logger.info('Server : %s', self.server)
36+ self.cleanup_products()
37+ self.annotate('As Developer or QA, Create Product via Spec Manager')
38+ self.create_product()
39+ self.submit_gm()
40+ self.annotate('As Developer or QA, Create Test Spec via Spec Manager')
41+ self.create_spec()
42+ self.prompt(
43+ 'As Lab Owner, Run agent first to register with Message Hub')
44+ self.run_agent(reg_only=True)
45+ self.pause()
46+ self.submit_snap()
47+ self.annotate('Sleeping 1s to wait for propagation to hub', color=GRY)
48+ time.sleep(1)
49+ self.annotate('As Lab Owner, Running agent')
50+ self.annotate(
51+ 'Should pick up at least 1 Test Opportunity,'
52+ ' provision and run tests', color=GRY)
53+ self.annotate('Note this can also run continously in daemon mode',
54+ color=GRY)
55+ self.pause()
56+ self.run_agent()
57+ self.prompt('Completed agent run')
58+ self.annotate('As Developer or QA, Checking result progress via Result Enumerator')
59+ self.check_progress()
60+ self.annotate('As Developer or QA, Checking final results via Result Enumerator')
61+ results = self.check_results()
62+ if self.exit_code == 0: # No need to verify it anything failed
63+ self.verify_results(results)
64+ self.cleanup_products()
65+
66+ def verify_results(self, results):
67+ for r in results['test_results']:
68+ if r['test_opportunity_id'] in self.testopp_ids:
69+ # Pop random data
70+ for k1, k2 in [
71+ ['test_spec', 'created_at'],
72+ ['product', 'created_at'],
73+ ['agent', 'timing']]:
74+ try:
75+ r[k1].pop(k2)
76+ except KeyError:
77+ logger.error('Missing key in result: r[{}][{}]'.format(k1, k2))
78+ self.exit_code = 1
79+
80+ for k in "image_unique_id", "base_image_id":
81+ i = r.pop(k)
82+ if i not in self.image_unique_ids:
83+ logger.error("%s is %s, not in %r", k, i, self.image_unique_ids)
84+ r["update_snaps"] = sorted(r["update_snaps"])
85+
86+ expected_data = {
87+ "product_id": self.product_id,
88+ "platform": "amd64",
89+ "base_channel": "stable",
90+ "base_image_reference": None,
91+ "agent_id": "e2e-id",
92+ "update_snaps": sorted([
93+ ["webdm.canonical", 1],
94+ ["ubuntu-core.canonical", 1],
95+ ["test-snap.%s" % self.namespace, 2],
96+ ["pi2.canonical", 1]
97+ ]),
98+ "spec_name": self.spec_name,
99+ "image_reference": None,
100+ "product": {
101+ "active": True,
102+ "primary_snap_name": "test-snap.%s" % self.namespace,
103+ "name": "test-product.%s" % self.namespace,
104+ "release": "rolling-core",
105+ "snaps": [
106+ "ubuntu-core.canonical",
107+ "pi2.canonical",
108+ "webdm.canonical",
109+ "test-snap.%s" % self.namespace
110+ ],
111+ "id": self.product_id
112+ },
113+ "agent": {
114+ "id": "e2e-id"
115+ },
116+ "test_payload": "{'foo': 'bar'}",
117+ "test_status": "PASSED",
118+ "result_payload": {
119+ "foo": "bar"
120+ },
121+ "base_snaps": [
122+ "ubuntu-core.canonical",
123+ "pi2.canonical",
124+ "webdm.canonical",
125+ "test-snap.%s" % self.namespace
126+ ],
127+ "primary_snap_name": "test-snap.%s" % self.namespace,
128+ "type": "update",
129+ "test_spec": {
130+ "active": True,
131+ "product_id": self.product_id,
132+ "channel_combos": [{"update": "edge", "base": "stable"}],
133+ "name": self.spec_name,
134+ "test_payload": "{'foo': 'bar'}",
135+ "platform": "amd64",
136+ "id": self.spec_id
137+ },
138+ "product_name": "test-product.%s" % self.namespace,
139+ "update_channel": "edge"
140+ }
141+
142+ for k, v in expected_data.items():
143+ try:
144+ if r[k] != v:
145+ self.exit_code = 1
146+ logger.error('expected result[{}] == {},'
147+ ' got {} instead'.format(k, v, r[k]))
148+ except KeyError:
149+ logger.error('Missing key in result: {}'.format(k))
150+ self.exit_code = 1
151+
152+if __name__ == '__main__':
153+ arguments = docopt.docopt(__doc__, version='Tanuki E2e Proto 1')
154+ e2e = E2eUpdate(arguments)
155+ e2e.run()
156+ exit(e2e.exit_code)
157
158=== modified file 'scripts/e2e.py'
159--- scripts/e2e.py 2015-12-02 19:55:42 +0000
160+++ scripts/e2e.py 2015-12-03 13:01:36 +0000
161@@ -409,27 +409,30 @@
162 self.annotate('Deleted Manifest:')
163 logger.info(res.json())
164
165- def submit_snap_revision(self):
166+ def submit_snap(self):
167 self.annotate(
168 'As Developer hacking code, Submit a new revision '
169 'of a snap to Spec Manager')
170 d = {
171- 'name': 'snap-b',
172- 'revision': 4
173+ 'channel': 'edge',
174+ 'name': 'test-snap.%s' % self.namespace,
175+ 'sequence': 2,
176 }
177+
178+ snap_url = urllib.parse.urljoin(
179+ self.specmgr_server,
180+ '/'.join(['products', self.product_id, 'snaps']))
181 logger.info(
182 'POST %s:%s',
183- self.snap_revision_url,
184- json.dumps(
185- d,
186- indent=2))
187+ snap_url,
188+ json.dumps(d, indent=2))
189 self.pause()
190
191- res = retry_it(self.session.post, self.snap_revision_url, json=d, timeout=self.timeout)
192+ res = retry_it(self.session.post, snap_url, json=d, timeout=self.timeout)
193 res.raise_for_status()
194 if res.status_code not in (200, 201, 202) or res.json() is None:
195 logger.error(
196- 'Error submitting snap revision: %r, %r',
197+ 'Error submitting snap: %r, %r',
198 res.status_code,
199 res.text)
200 raise Exception

Subscribers

People subscribed via source and target branches

to all changes: