From 409567582772efd5f98bc40bb48cb07e3b034f14 Mon Sep 17 00:00:00 2001 From: caleb miles Date: Wed, 31 Oct 2012 15:32:03 -0400 Subject: [PATCH] test_s3: test multi-part uploads using boto provided functionality. Tests the implementation of multi-part upload and verifies written object. Signed-off-by: caleb miles --- s3tests/functional/test_s3.py | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/s3tests/functional/test_s3.py b/s3tests/functional/test_s3.py index fca7e1e..4e79532 100644 --- a/s3tests/functional/test_s3.py +++ b/s3tests/functional/test_s3.py @@ -4004,6 +4004,46 @@ def test_multipart_upload(): eq(obj_count, 1) eq(bytes_used, 30 * 1024 * 1024) +@attr(resource='object') +@attr(method='put') +@attr(operation='check contents of multi-part upload') +@attr(assertion='successful') +def test_multipart_upload_contents(): + bucket = get_new_bucket() + key_name="mymultipart" + num_parts=5 + payload='foo'*10*1024*1024 + mp=bucket.initiate_multipart_upload(key_name) + for i in range(0, num_parts): + mp.upload_part_from_file(StringIO(payload), i+1) + + mp.complete_upload() + key=bucket.get_key(key_name) + test_string=key.get_contents_as_string() + assert test_string == payload*num_parts + + +@attr(resource='object') +@attr(method='put') +@attr(operation=' multi-part upload overwrites existing key') +@attr(assertion='successful') +def test_multipart_upload_overwrite_existing_object(): + bucket = get_new_bucket() + key_name="mymultipart" + payload='bar'*10*1024*1024 + num_parts=5 + key=bucket.new_key(key_name) + key.set_contents_from_string(payload) + + mp=bucket.initiate_multipart_upload(key_name) + for i in range(0, num_parts): + mp.upload_part_from_file(StringIO(payload), i+1) + + mp.complete_upload() + key=bucket.get_key(key_name) + test_string=key.get_contents_as_string() + assert test_string == payload*num_parts + @attr(resource='object') @attr(method='put') @attr(operation='abort multi-part upload')