From 768298370493ec849266bc877bdfff9535f78366 Mon Sep 17 00:00:00 2001 From: Abhishek Lekshmanan Date: Tue, 26 Mar 2019 11:22:00 +0100 Subject: [PATCH] boto3/test_s3: range encoding helper function takes a size argument This is to avoid a get_object call for every range check as the object size will not change during this duration and we'd most likely already know the object sizes beforehand Signed-off-by: Abhishek Lekshmanan (cherry picked from commit 741f2cbc9e054bcf94718391c305d7d4b07de59d) --- s3tests_boto3/functional/test_s3.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/s3tests_boto3/functional/test_s3.py b/s3tests_boto3/functional/test_s3.py index 333604a..cb64593 100644 --- a/s3tests_boto3/functional/test_s3.py +++ b/s3tests_boto3/functional/test_s3.py @@ -9302,9 +9302,7 @@ def _multipart_upload_enc(client, bucket_name, key, size, part_size, init_header return (upload_id, s, parts) -def _check_content_using_range_enc(client, bucket_name, key, data, step, enc_headers=None): - response = client.get_object(Bucket=bucket_name, Key=key) - size = response['ContentLength'] +def _check_content_using_range_enc(client, bucket_name, key, data, size, step, enc_headers=None): for ofs in range(0, size, step): toread = size - ofs if toread > step: @@ -9362,8 +9360,8 @@ def test_encryption_sse_c_multipart_upload(): size = response['ContentLength'] assert len(body) == size - _check_content_using_range_enc(client, bucket_name, key, data, 1000000, enc_headers=enc_headers) - _check_content_using_range_enc(client, bucket_name, key, data, 10000000, enc_headers=enc_headers) + _check_content_using_range_enc(client, bucket_name, key, data, size, 1000000, enc_headers=enc_headers) + _check_content_using_range_enc(client, bucket_name, key, data, size, 10000000, enc_headers=enc_headers) @pytest.mark.encryption def test_encryption_sse_c_unaligned_multipart_upload():