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
=== modified file 'core_result_checker/__init__.py'
--- core_result_checker/__init__.py 2015-05-25 21:23:51 +0000
+++ core_result_checker/__init__.py 2015-05-27 22:28:49 +0000
@@ -49,10 +49,16 @@
49 logger = get_logger(__name__, message)49 logger = get_logger(__name__, message)
50 logger.info("Got: %r", message)50 logger.info("Got: %r", message)
51 try:51 try:
52 channel = message['channel']
53 device = message['device']
54 image_name = message['image_name']
55 exit_code = message['exit_code']52 exit_code = message['exit_code']
53 container_name = message['swift_container_name']
54 tarball_name = message['swift_tarball_filename']
55 # Additionally unpack values we're required to output, so we
56 # catch upstream errors as soon as possible:
57 message['source_name']
58 message['source_version']
59 message['series']
60 message['distribution']
61 message['test_name']
56 except KeyError as e:62 except KeyError as e:
57 logger.error("Unable to unpack incoming message: %s", str(e))63 logger.error("Unable to unpack incoming message: %s", str(e))
58 return MessageActions.Retry64 return MessageActions.Retry
@@ -65,12 +71,6 @@
65 )71 )
66 self.queue_manager.retry_test_run(message)72 self.queue_manager.retry_test_run(message)
67 return MessageActions.Acknowledge73 return MessageActions.Acknowledge
68 container_name = "core-{}-{}-{}".format(
69 channel,
70 device,
71 image_name,
72 ).replace('/', '_')
73 tarball_name = container_name + "-results.tgz"
7474
75 # check to see if swift is consistent yet:75 # check to see if swift is consistent yet:
76 if not self.swift_manager.container_contains_file(76 if not self.swift_manager.container_contains_file(
@@ -81,8 +81,15 @@
81 self.queue_manager.retry_for_swift(message)81 self.queue_manager.retry_for_swift(message)
82 return MessageActions.Acknowledge82 return MessageActions.Acknowledge
8383
84 # Make the swift container public, add the public url to the tarball
85 # to the result payload:
84 try:86 try:
85 self.swift_manager.make_container_public(container_name)87 public_container_url = self.swift_manager.make_container_public(
88 container_name
89 )
90 message['test_url'] = '/'.join(
91 (public_container_url, tarball_name)
92 )
86 except RuntimeError as e:93 except RuntimeError as e:
87 logger.error(94 logger.error(
88 "Unable to publish swift container '%s'. Error: %s.",95 "Unable to publish swift container '%s'. Error: %s.",
@@ -91,6 +98,9 @@
91 )98 )
92 return MessageActions.Retry99 return MessageActions.Retry
93 logger.info("Swift container made public OK.")100 logger.info("Swift container made public OK.")
101
102 # Update message payload with additional data:
103 message['test_status'] = 'PASS' if exit_code == 0 else 'FAIL'
94 self.queue_manager.complete_test(message)104 self.queue_manager.complete_test(message)
95 return MessageActions.Acknowledge105 return MessageActions.Acknowledge
96106
@@ -125,14 +135,17 @@
125135
126 """A class that knows how to interact with swift."""136 """A class that knows how to interact with swift."""
127137
128 def __init__(self, nova_config):138 def __init__(self, nova_config, public_endpoint):
129 self.config = nova_config139 self.config = nova_config
140 self.public_endpoint = public_endpoint.rstrip('/')
130141
131 def make_container_public(self, container_name):142 def make_container_public(self, container_name):
132 """Make a swift contianer public.143 """Make a swift contianer public.
133144
134 Raises RuntimeError on failure, returns None otherwise.145 Raises RuntimeError on failure, returns None otherwise.
135146
147 Returns the public http url for the container in swift.
148
136 """149 """
137 swift = SwiftService(self.config)150 swift = SwiftService(self.config)
138 result = swift.post(151 result = swift.post(
@@ -146,6 +159,7 @@
146 result['error']159 result['error']
147 )160 )
148 )161 )
162 return '/'.join((self.public_endpoint, container_name))
149163
150 def container_contains_file(self, container_name, file_name):164 def container_contains_file(self, container_name, file_name):
151 swift = SwiftService(self.config)165 swift = SwiftService(self.config)
@@ -281,7 +295,10 @@
281 complete_payload,295 complete_payload,
282 3296 3
283 )297 )
284 swift_manager = SwiftManager(config['nova'])298 swift_manager = SwiftManager(
299 config['nova'],
300 config['swift']['public_url']
301 )
285 worker = Worker(swift_manager, queue_manager)302 worker = Worker(swift_manager, queue_manager)
286 queue_monitor = SimpleRabbitQueueWorker(303 queue_monitor = SimpleRabbitQueueWorker(
287 connection,304 connection,

Subscribers

People subscribed via source and target branches

to all changes: