You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by ma...@apache.org on 2013/09/03 17:13:57 UTC

git commit: Fix s3 multipart test cases broken by LIBCLOUD-378

Updated Branches:
  refs/heads/trunk 007d4e890 -> 326e81f09


Fix s3 multipart test cases broken by LIBCLOUD-378

The breakage was caused by an overzealous check.
Also added test cases for checking small and big uploads via
S3 multipart upload API


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/326e81f0
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/326e81f0
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/326e81f0

Branch: refs/heads/trunk
Commit: 326e81f09902514a290f5aeb292426b56e2e95b7
Parents: 007d4e8
Author: Mahendra <ma...@apache.org>
Authored: Tue Sep 3 20:40:54 2013 +0530
Committer: Mahendra <ma...@apache.org>
Committed: Tue Sep 3 20:40:54 2013 +0530

----------------------------------------------------------------------
 libcloud/test/storage/test_s3.py | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/326e81f0/libcloud/test/storage/test_s3.py
----------------------------------------------------------------------
diff --git a/libcloud/test/storage/test_s3.py b/libcloud/test/storage/test_s3.py
index 75c6789..af6afd2 100644
--- a/libcloud/test/storage/test_s3.py
+++ b/libcloud/test/storage/test_s3.py
@@ -34,6 +34,7 @@ from libcloud.storage.drivers.s3 import S3StorageDriver, S3USWestStorageDriver
 from libcloud.storage.drivers.s3 import S3EUWestStorageDriver
 from libcloud.storage.drivers.s3 import S3APSEStorageDriver
 from libcloud.storage.drivers.s3 import S3APNEStorageDriver
+from libcloud.storage.drivers.s3 import CHUNK_SIZE
 from libcloud.storage.drivers.dummy import DummyIterator
 
 from libcloud.test import StorageMockHttp, MockRawResponse # pylint: disable-msg=E0611
@@ -243,8 +244,6 @@ class S3MockHttp(StorageMockHttp, MockHttpTestCase):
                 self.assertEqual(part_no, str(count))
                 self.assertEqual(etag, headers['etag'])
 
-            self.assertEqual(count, 3)
-
             body = self.fixtures.load('complete_multipart.xml')
             return (httplib.OK,
                     body,
@@ -755,7 +754,7 @@ class S3Tests(unittest.TestCase):
         self.assertTrue('some-value' in obj.meta_data)
         self.driver_type._upload_file = old_func
 
-    def test_upload_object_via_stream(self):
+    def test_upload_small_object_via_stream(self):
 
         if self.driver.supports_s3_multipart_upload:
             self.mock_raw_response_klass.type = 'MULTIPART'
@@ -777,6 +776,28 @@ class S3Tests(unittest.TestCase):
         self.assertEqual(obj.name, object_name)
         self.assertEqual(obj.size, 3)
 
+    def test_upload_big_object_via_stream(self):
+
+        if self.driver.supports_s3_multipart_upload:
+            self.mock_raw_response_klass.type = 'MULTIPART'
+            self.mock_response_klass.type = 'MULTIPART'
+        else:
+            self.mock_raw_response_klass.type = None
+            self.mock_response_klass.type = None
+
+        container = Container(name='foo_bar_container', extra={},
+                              driver=self.driver)
+        object_name = 'foo_test_stream_data'
+        iterator = DummyIterator(data=['2'*CHUNK_SIZE, '3'*CHUNK_SIZE, '5'])
+        extra = {'content_type': 'text/plain'}
+        obj = self.driver.upload_object_via_stream(container=container,
+                                                   object_name=object_name,
+                                                   iterator=iterator,
+                                                   extra=extra)
+
+        self.assertEqual(obj.name, object_name)
+        self.assertEqual(obj.size, CHUNK_SIZE*2 + 1)
+
     def test_upload_object_via_stream_abort(self):
         if not self.driver.supports_s3_multipart_upload:
             return