Merge lp:~thomir-deactivatedaccount/autopkgtest-result-checker/snappy-proposed-migration-add-missing-payload-keys into lp:autopkgtest-result-checker/snappy-proposed-migration

Proposed by Thomi Richards
Status: Merged
Approved by: Thomi Richards
Approved revision: 20
Merged at revision: 20
Proposed branch: lp:~thomir-deactivatedaccount/autopkgtest-result-checker/snappy-proposed-migration-add-missing-payload-keys
Merge into: lp:autopkgtest-result-checker/snappy-proposed-migration
Diff against target: 102 lines (+29/-12)
1 file modified
core_result_checker/__init__.py (+29/-12)
To merge this branch: bzr merge lp:~thomir-deactivatedaccount/autopkgtest-result-checker/snappy-proposed-migration-add-missing-payload-keys
Reviewer Review Type Date Requested Status
Francis Ginther Approve
Review via email: mp+260391@code.launchpad.net

Commit message

Update result-checker service with new required payloads.

Description of the change

Update result-checker service with new required payloads.

To post a comment you must log in.
20. By Thomi Richards

Fix pep8 issue.

Revision history for this message
Francis Ginther (fginther) wrote :

Approved.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'core_result_checker/__init__.py'
2--- core_result_checker/__init__.py 2015-05-25 21:23:51 +0000
3+++ core_result_checker/__init__.py 2015-05-27 22:28:49 +0000
4@@ -49,10 +49,16 @@
5 logger = get_logger(__name__, message)
6 logger.info("Got: %r", message)
7 try:
8- channel = message['channel']
9- device = message['device']
10- image_name = message['image_name']
11 exit_code = message['exit_code']
12+ container_name = message['swift_container_name']
13+ tarball_name = message['swift_tarball_filename']
14+ # Additionally unpack values we're required to output, so we
15+ # catch upstream errors as soon as possible:
16+ message['source_name']
17+ message['source_version']
18+ message['series']
19+ message['distribution']
20+ message['test_name']
21 except KeyError as e:
22 logger.error("Unable to unpack incoming message: %s", str(e))
23 return MessageActions.Retry
24@@ -65,12 +71,6 @@
25 )
26 self.queue_manager.retry_test_run(message)
27 return MessageActions.Acknowledge
28- container_name = "core-{}-{}-{}".format(
29- channel,
30- device,
31- image_name,
32- ).replace('/', '_')
33- tarball_name = container_name + "-results.tgz"
34
35 # check to see if swift is consistent yet:
36 if not self.swift_manager.container_contains_file(
37@@ -81,8 +81,15 @@
38 self.queue_manager.retry_for_swift(message)
39 return MessageActions.Acknowledge
40
41+ # Make the swift container public, add the public url to the tarball
42+ # to the result payload:
43 try:
44- self.swift_manager.make_container_public(container_name)
45+ public_container_url = self.swift_manager.make_container_public(
46+ container_name
47+ )
48+ message['test_url'] = '/'.join(
49+ (public_container_url, tarball_name)
50+ )
51 except RuntimeError as e:
52 logger.error(
53 "Unable to publish swift container '%s'. Error: %s.",
54@@ -91,6 +98,9 @@
55 )
56 return MessageActions.Retry
57 logger.info("Swift container made public OK.")
58+
59+ # Update message payload with additional data:
60+ message['test_status'] = 'PASS' if exit_code == 0 else 'FAIL'
61 self.queue_manager.complete_test(message)
62 return MessageActions.Acknowledge
63
64@@ -125,14 +135,17 @@
65
66 """A class that knows how to interact with swift."""
67
68- def __init__(self, nova_config):
69+ def __init__(self, nova_config, public_endpoint):
70 self.config = nova_config
71+ self.public_endpoint = public_endpoint.rstrip('/')
72
73 def make_container_public(self, container_name):
74 """Make a swift contianer public.
75
76 Raises RuntimeError on failure, returns None otherwise.
77
78+ Returns the public http url for the container in swift.
79+
80 """
81 swift = SwiftService(self.config)
82 result = swift.post(
83@@ -146,6 +159,7 @@
84 result['error']
85 )
86 )
87+ return '/'.join((self.public_endpoint, container_name))
88
89 def container_contains_file(self, container_name, file_name):
90 swift = SwiftService(self.config)
91@@ -281,7 +295,10 @@
92 complete_payload,
93 3
94 )
95- swift_manager = SwiftManager(config['nova'])
96+ swift_manager = SwiftManager(
97+ config['nova'],
98+ config['swift']['public_url']
99+ )
100 worker = Worker(swift_manager, queue_manager)
101 queue_monitor = SimpleRabbitQueueWorker(
102 connection,

Subscribers

People subscribed via source and target branches

to all changes: