swift result download: Correctly handle "204 No content" status

bzr-import-20160707
Martin Pitt 10 years ago
parent cb66355e95
commit ffe0a99db1

@ -269,6 +269,8 @@ class AutoPackageTest(object):
f = urlopen(url)
if f.getcode() == 200:
result_paths = f.read().strip().splitlines()
elif f.getcode() == 204: # No content
result_paths = []
else:
self.log_error('Failure to fetch swift results from %s: %u' %
(url, f.getcode()))

@ -85,7 +85,7 @@ class SwiftHTTPRequestHandler(BaseHTTPRequestHandler):
find_adapter = lambda i: (i >= 0) and (i + 1) or None
objs = set([o[:find_adapter(o.find(d))] for o in objs])
self.send_response(200)
self.send_response(objs and 200 or 204) # 204: "No Content"
self.send_header('Content-type', 'text/plain')
self.end_headers()
self.wfile.write(('\n'.join(sorted(objs)) + '\n').encode('UTF-8'))

@ -247,7 +247,7 @@ lightgreen 1 i386 green 2
'series/amd64/g/green/20150101_100201@': (4, 'green 2'),
}})
self.do_test(
out = self.do_test(
[],
# FIXME: while we only submit requests through AMQP, but don't consider
# their results, we don't expect this to hold back stuff.
@ -257,6 +257,9 @@ lightgreen 1 i386 green 2
r'autopkgtest for lightgreen 1: .*amd64.*Regression.*i386.*in progress',
r'autopkgtest for darkgreen 1: .*amd64.*in progress.*i386.*Pass'])
# not expecting any failures to retrieve from swift
self.assertNotIn('Failure', out, out)
# there should be some pending ones
self.assertIn('darkgreen 1 amd64 green 2', self.pending_requests)
self.assertIn('lightgreen 1 i386 green 2', self.pending_requests)

Loading…
Cancel
Save