mirror of
https://github.com/ceph/s3-tests.git
synced 2024-11-28 19:31:39 +00:00
test Head/GetObject on completed multipart parts
Signed-off-by: Casey Bodley <cbodley@redhat.com>
This commit is contained in:
parent
e29d6246fc
commit
d552124680
1 changed files with 63 additions and 0 deletions
|
@ -6411,6 +6411,69 @@ def test_multipart_upload_incorrect_etag():
|
||||||
assert status == 400
|
assert status == 400
|
||||||
assert error_code == 'InvalidPart'
|
assert error_code == 'InvalidPart'
|
||||||
|
|
||||||
|
@pytest.mark.fails_on_dbstore
|
||||||
|
def test_multipart_get_part():
|
||||||
|
bucket_name = get_new_bucket()
|
||||||
|
client = get_client()
|
||||||
|
key = "mymultipart"
|
||||||
|
|
||||||
|
part_size = 5*1024*1024
|
||||||
|
part_sizes = 3 * [part_size] + [1*1024*1024]
|
||||||
|
part_count = len(part_sizes)
|
||||||
|
total_size = sum(part_sizes)
|
||||||
|
|
||||||
|
(upload_id, data, parts) = _multipart_upload(bucket_name, key, total_size, part_size, resend_parts=[2])
|
||||||
|
|
||||||
|
# request part before complete
|
||||||
|
e = assert_raises(ClientError, client.get_object, Bucket=bucket_name, Key=key, PartNumber=1)
|
||||||
|
status, error_code = _get_status_and_error_code(e.response)
|
||||||
|
assert status == 404
|
||||||
|
assert error_code == 'NoSuchKey'
|
||||||
|
|
||||||
|
client.complete_multipart_upload(Bucket=bucket_name, Key=key, UploadId=upload_id, MultipartUpload={'Parts': parts})
|
||||||
|
assert len(parts) == part_count
|
||||||
|
|
||||||
|
for part, size in zip(parts, part_sizes):
|
||||||
|
response = client.head_object(Bucket=bucket_name, Key=key, PartNumber=part['PartNumber'])
|
||||||
|
assert response['PartsCount'] == part_count
|
||||||
|
assert response['ETag'] == '"{}"'.format(part['ETag'])
|
||||||
|
|
||||||
|
response = client.get_object(Bucket=bucket_name, Key=key, PartNumber=part['PartNumber'])
|
||||||
|
assert response['PartsCount'] == part_count
|
||||||
|
assert response['ETag'] == '"{}"'.format(part['ETag'])
|
||||||
|
assert response['ContentLength'] == size
|
||||||
|
# compare contents
|
||||||
|
for chunk in response['Body'].iter_chunks():
|
||||||
|
assert chunk.decode() == data[0:len(chunk)]
|
||||||
|
data = data[len(chunk):]
|
||||||
|
|
||||||
|
# request PartNumber out of range
|
||||||
|
e = assert_raises(ClientError, client.get_object, Bucket=bucket_name, Key=key, PartNumber=5)
|
||||||
|
status, error_code = _get_status_and_error_code(e.response)
|
||||||
|
assert status == 400
|
||||||
|
assert error_code == 'InvalidPart'
|
||||||
|
|
||||||
|
@pytest.mark.fails_on_dbstore
|
||||||
|
def test_non_multipart_get_part():
|
||||||
|
bucket_name = get_new_bucket()
|
||||||
|
client = get_client()
|
||||||
|
key = "singlepart"
|
||||||
|
|
||||||
|
response = client.put_object(Bucket=bucket_name, Key=key, Body='body')
|
||||||
|
etag = response['ETag']
|
||||||
|
|
||||||
|
# request for PartNumber > 1 results in InvalidPart
|
||||||
|
e = assert_raises(ClientError, client.get_object, Bucket=bucket_name, Key=key, PartNumber=2)
|
||||||
|
status, error_code = _get_status_and_error_code(e.response)
|
||||||
|
assert status == 400
|
||||||
|
assert error_code == 'InvalidPart'
|
||||||
|
|
||||||
|
# request for PartNumber = 1 gives back the entire object
|
||||||
|
response = client.get_object(Bucket=bucket_name, Key=key, PartNumber=1)
|
||||||
|
assert response['ETag'] == etag
|
||||||
|
assert _get_body(response) == 'body'
|
||||||
|
|
||||||
|
|
||||||
def _simple_http_req_100_cont(host, port, is_secure, method, resource):
|
def _simple_http_req_100_cont(host, port, is_secure, method, resource):
|
||||||
"""
|
"""
|
||||||
Send the specified request w/expect 100-continue
|
Send the specified request w/expect 100-continue
|
||||||
|
|
Loading…
Reference in a new issue