Skip to content

Commit

Permalink
Lots of tests, that pass on AmazonS3 unless the phase of the moon is …
Browse files Browse the repository at this point in the history
…wrong. There is a non-trivial degree of lag in S3 applying WebsiteConfiguration changes sometimes, eu-west-1 was taking 20+ seconds during part of the last day. Compounded by the Amazon eventual-consistency made developing these tests difficult at times.

Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
  • Loading branch information
robbat2 authored and Robin H. Johnson committed Apr 20, 2016
1 parent 819eecb commit e065523
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 54 deletions.
6 changes: 6 additions & 0 deletions s3tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ def teardown_wrapped():


def normalize_xml(xml, pretty_print=True):
if xml is None:
return xml

root = etree.fromstring(xml.encode(encoding='ascii'))

for element in root.iter('*'):
Expand All @@ -285,6 +288,9 @@ def normalize_xml(xml, pretty_print=True):
return xmlstr

def assert_xml_equal(got, want):
assert want is not None, 'Wanted XML cannot be None'
if got is None:
raise AssertionError('Got input to validate was None')
checker = LXMLOutputChecker()
if not checker.check_output(want, got, 0):
message = checker.output_difference(Example("", want), got, 0)
Expand Down
12 changes: 6 additions & 6 deletions s3tests/functional/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ def get_new_bucket(target=None, name=None, headers=None):
bucket = connection.create_bucket(name, location=target.conf.api_name, headers=headers)
return bucket

def _make_request(method, bucket, key, body=None, authenticated=False, response_headers=None, request_headers=None, expires_in=100000, path_style=True):
def _make_request(method, bucket, key, body=None, authenticated=False, response_headers=None, request_headers=None, expires_in=100000, path_style=True, timeout=None):
"""
issue a request for a specified method, on a specified <bucket,key>,
with a specified (optional) body (encrypted per the connection), and
Expand All @@ -425,9 +425,9 @@ def _make_request(method, bucket, key, body=None, authenticated=False, response_
else:
path = '/{obj}'.format(bucket=key.bucket.name, obj=key.name)

return _make_raw_request(host=s3.main.host, port=s3.main.port, method=method, path=path, body=body, request_headers=request_headers, secure=s3.main.is_secure)
return _make_raw_request(host=s3.main.host, port=s3.main.port, method=method, path=path, body=body, request_headers=request_headers, secure=s3.main.is_secure, timeout=timeout)

def _make_bucket_request(method, bucket, body=None, authenticated=False, response_headers=None, request_headers=None, expires_in=100000, path_style=True):
def _make_bucket_request(method, bucket, body=None, authenticated=False, response_headers=None, request_headers=None, expires_in=100000, path_style=True, timeout=None):
"""
issue a request for a specified method, on a specified <bucket,key>,
with a specified (optional) body (encrypted per the connection), and
Expand All @@ -451,9 +451,9 @@ def _make_bucket_request(method, bucket, body=None, authenticated=False, respons
else:
path = '/'

return _make_raw_request(host=s3.main.host, port=s3.main.port, method=method, path=path, body=body, request_headers=request_headers, secure=s3.main.is_secure)
return _make_raw_request(host=s3.main.host, port=s3.main.port, method=method, path=path, body=body, request_headers=request_headers, secure=s3.main.is_secure, timeout=timeout)

def _make_raw_request(host, port, method, path, body=None, request_headers=None, secure=False):
def _make_raw_request(host, port, method, path, body=None, request_headers=None, secure=False, timeout=None):
if secure:
class_ = HTTPSConnection
else:
Expand All @@ -464,7 +464,7 @@ def _make_raw_request(host, port, method, path, body=None, request_headers=None,

skip_host=('Host' in request_headers)
skip_accept_encoding = False
c = class_(host, port, strict=True)
c = class_(host, port, strict=True, timeout=timeout)

# We do the request manually, so we can muck with headers
#c.request(method, path, body=body, headers=request_headers)
Expand Down
Loading

0 comments on commit e065523

Please sign in to comment.