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

Subscribers

People subscribed via source and target branches

to all changes: