From 4fec9219ced91c2c95b35f8aeedcc3573b655b86 Mon Sep 17 00:00:00 2001 From: caleb miles Date: Fri, 16 Nov 2012 14:49:37 -0500 Subject: [PATCH] test_s3: test enforcement of minimum part size in multi-part upload. Signed-off-by: caleb miles --- s3tests/functional/test_s3.py | 49 +++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/s3tests/functional/test_s3.py b/s3tests/functional/test_s3.py index 7f9a495..c5fa4dd 100644 --- a/s3tests/functional/test_s3.py +++ b/s3tests/functional/test_s3.py @@ -2895,6 +2895,55 @@ def test_abort_multipart_upload(): upload.cancel_upload() +@attr(resource='object') +@attr(method='put') +@attr(operation='check that multi-part upload enforces a minimum size') +@attr(assertion='successful') +def test_multipart_minimum_part_size_parts_too_small(): + bucket = get_new_bucket() + key="mymultipart" + mp = bucket.initiate_multipart_upload(key) + + # upload a few bad parts + for i in range(0, 10): + mp.upload_part_from_file(StringIO('foobar'), i+1) + + e = assert_raises(boto.exception.S3ResponseError, mp.complete_upload) + eq(e.status, 400) + +@attr(resource='object') +@attr(method='put') +@attr(operation='check that a single part upload of arbitrary size succeeds') +@attr(assertion='successful') +def test_multipart_size_single_part_upload(): + bucket = get_new_bucket() + key="mymultipart" + mp = bucket.initiate_multipart_upload(key) + + # create a single part under 5Mb + mp.upload_part_from_file(StringIO('foo'), 1) + + mp.complete_upload() + +@attr(resource='object') +@attr(method='put') +@attr(operation='test that a single bad part will cause failure for parts > 1') +@attr(assertion='successful') +def test_multipart_size_bad_single_part(): + bucket = get_new_bucket() + key="mymultipart" + mp = bucket.initiate_multipart_upload(key) + + # create the single bad part + mp.upload_part_from_file(StringIO('foo'), 1) + + # upload a host of good parts + for i in range(2, 10): + mp.upload_part_from_file(StringIO(('foobar'*1024*1024)), i+1) + + e = assert_raises(boto.exception.S3ResponseError, mp.complete_upload) + eq(e.status, 400) + @attr(resource='object') @attr(method='put') @attr(operation='concurrent multi-part uploads')