@ -29,6 +29,7 @@ CONF = config.CONF
class ObjectTest ( base . BaseObjectTest ) :
""" Test storage object """
@classmethod
def resource_setup ( cls ) :
@ -78,6 +79,7 @@ class ObjectTest(base.BaseObjectTest):
@decorators.attr ( type = ' smoke ' )
@decorators.idempotent_id ( ' 5b4ce26f-3545-46c9-a2ba-5754358a4c62 ' )
def test_create_object ( self ) :
""" Test creating object and checking the object ' s uploaded content """
# create object
object_name = data_utils . rand_name ( name = ' TestObject ' )
data = data_utils . random_bytes ( )
@ -97,7 +99,7 @@ class ObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' 5daebb1d-f0d5-4dc9-b541-69672eff00b0 ' )
def test_create_object_with_content_disposition ( self ) :
# create object with content_disposition
""" Test creating object with content-disposition """
object_name = data_utils . rand_name ( name = ' TestObject ' )
data = data_utils . random_bytes ( )
metadata = { }
@ -119,7 +121,7 @@ class ObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' 605f8317-f945-4bee-ae91-013f1da8f0a0 ' )
def test_create_object_with_content_encoding ( self ) :
# create object with content_encoding
""" Test creating object with content-encoding """
object_name = data_utils . rand_name ( name = ' TestObject ' )
# put compressed string
@ -146,7 +148,7 @@ class ObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' 73820093-0503-40b1-a478-edf0e69c7d1f ' )
def test_create_object_with_etag ( self ) :
# create object with etag
""" Test creating object with Etag """
object_name = data_utils . rand_name ( name = ' TestObject ' )
data = data_utils . random_bytes ( )
md5 = hashlib . md5 ( data ) . hexdigest ( )
@ -165,8 +167,7 @@ class ObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' 84dafe57-9666-4f6d-84c8-0814d37923b8 ' )
def test_create_object_with_expect_continue ( self ) :
# create object with expect_continue
""" Test creating object with expect_continue """
object_name = data_utils . rand_name ( name = ' TestObject ' )
data = data_utils . random_bytes ( )
@ -182,7 +183,7 @@ class ObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' 4f84422a-e2f2-4403-b601-726a4220b54e ' )
def test_create_object_with_transfer_encoding ( self ) :
# create object with transfer_encoding
""" Test creating object with transfer_encoding """
object_name = data_utils . rand_name ( name = ' TestObject ' )
data = data_utils . random_bytes ( 1024 )
headers = { ' Transfer-Encoding ' : ' chunked ' }
@ -202,7 +203,10 @@ class ObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' 0f3d62a6-47e3-4554-b0e5-1a5dc372d501 ' )
def test_create_object_with_x_fresh_metadata ( self ) :
# create object with x_fresh_metadata
""" Test creating object with x-fresh-metadata
The previous added metadata will be cleared .
"""
object_name_base = data_utils . rand_name ( name = ' TestObject ' )
data = data_utils . random_bytes ( )
metadata_1 = { ' X-Object-Meta-test-meta ' : ' Meta ' }
@ -228,7 +232,7 @@ class ObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' 1c7ed3e4-2099-406b-b843-5301d4811baf ' )
def test_create_object_with_x_object_meta ( self ) :
# create object with object_meta
""" Test creating object with x-object-meta """
object_name = data_utils . rand_name ( name = ' TestObject ' )
data = data_utils . random_bytes ( )
metadata = { ' X-Object-Meta-test-meta ' : ' Meta ' }
@ -247,7 +251,7 @@ class ObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' e4183917-33db-4153-85cc-4dacbb938865 ' )
def test_create_object_with_x_object_metakey ( self ) :
# create object with the blank value of metadata
""" Test creating object with the blank value of metadata """
object_name = data_utils . rand_name ( name = ' TestObject ' )
data = data_utils . random_bytes ( )
metadata = { ' X-Object-Meta-test-meta ' : ' ' }
@ -266,7 +270,10 @@ class ObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' ce798afc-b278-45de-a5ce-2ea124b98b99 ' )
def test_create_object_with_x_remove_object_meta ( self ) :
# create object with x_remove_object_meta
""" Test creating object with x-remove-object-meta
The metadata will be removed from the object .
"""
object_name = data_utils . rand_name ( name = ' TestObject ' )
data = data_utils . random_bytes ( )
metadata_add = { ' X-Object-Meta-test-meta ' : ' Meta ' }
@ -289,7 +296,11 @@ class ObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' ad21e342-7916-4f9e-ab62-a1f885f2aaf9 ' )
def test_create_object_with_x_remove_object_metakey ( self ) :
# create object with the blank value of remove metadata
""" Test creating object with the blank value of remove metadata
Creating object with blank metadata ' X-Remove-Object-Meta-test-meta ' ,
metadata ' x-object-meta-test-meta ' will be removed from the object .
"""
object_name = data_utils . rand_name ( name = ' TestObject ' )
data = data_utils . random_bytes ( )
metadata_add = { ' X-Object-Meta-test-meta ' : ' Meta ' }
@ -312,7 +323,7 @@ class ObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' 17738d45-03bd-4d45-9e0b-7b2f58f98687 ' )
def test_delete_object ( self ) :
# create object
""" Test deleting object """
object_name = data_utils . rand_name ( name = ' TestObject ' )
data = data_utils . random_bytes ( )
resp , _ = self . object_client . create_object ( self . container_name ,
@ -325,7 +336,7 @@ class ObjectTest(base.BaseObjectTest):
@decorators.attr ( type = ' smoke ' )
@decorators.idempotent_id ( ' 7a94c25d-66e6-434c-9c38-97d4e2c29945 ' )
def test_update_object_metadata ( self ) :
# update object metadata
""" Test updating object metadata """
object_name , _ = self . create_object ( self . container_name )
metadata = { ' X-Object-Meta-test-meta ' : ' Meta ' }
@ -343,7 +354,7 @@ class ObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' 48650ed0-c189-4e1e-ad6b-1d4770c6e134 ' )
def test_update_object_metadata_with_remove_metadata ( self ) :
# update object metadata with remove metadata
""" Test updating object metadata with remove metadata """
object_name = data_utils . rand_name ( name = ' TestObject ' )
data = data_utils . random_bytes ( )
create_metadata = { ' X-Object-Meta-test-meta1 ' : ' Meta1 ' }
@ -366,6 +377,11 @@ class ObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' f726174b-2ded-4708-bff7-729d12ce1f84 ' )
def test_update_object_metadata_with_create_and_remove_metadata ( self ) :
""" Test updating object with creation and deletion of metadata
Update object with creation and deletion of metadata with one
request , both operations will succeed .
"""
# creation and deletion of metadata with one request
object_name = data_utils . rand_name ( name = ' TestObject ' )
data = data_utils . random_bytes ( )
@ -392,8 +408,7 @@ class ObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' 08854588-6449-4bb7-8cca-f2e1040f5e6f ' )
def test_update_object_metadata_with_x_object_manifest ( self ) :
# update object metadata with x_object_manifest
""" Test updating object metadata with x_object_manifest """
# uploading segments
object_name , _ = self . _upload_segments ( )
# creating a manifest file
@ -418,7 +433,7 @@ class ObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' 0dbbe89c-6811-4d84-a2df-eca2bdd40c0e ' )
def test_update_object_metadata_with_x_object_metakey ( self ) :
# update object metadata with a blank value of metadata
""" Test updating object metadata with a blank value of metadata"""
object_name , _ = self . create_object ( self . container_name )
update_metadata = { ' X-Object-Meta-test-meta ' : ' ' }
@ -436,7 +451,7 @@ class ObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' 9a88dca4-b684-425b-806f-306cd0e57e42 ' )
def test_update_object_metadata_with_x_remove_object_metakey ( self ) :
# update object metadata with a blank value of remove metadata
""" Test updating object metadata with blank remove metadata value """
object_name = data_utils . rand_name ( name = ' TestObject ' )
data = data_utils . arbitrary_string ( )
create_metadata = { ' X-Object-Meta-test-meta ' : ' Meta ' }
@ -460,7 +475,7 @@ class ObjectTest(base.BaseObjectTest):
@decorators.attr ( type = ' smoke ' )
@decorators.idempotent_id ( ' 9a447cf6-de06-48de-8226-a8c6ed31caf2 ' )
def test_list_object_metadata ( self ) :
# get object metadata
""" Test listing object metadata """
object_name = data_utils . rand_name ( name = ' TestObject ' )
data = data_utils . random_bytes ( )
metadata = { ' X-Object-Meta-test-meta ' : ' Meta ' }
@ -478,7 +493,7 @@ class ObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' 170fb90e-f5c3-4b1f-ae1b-a18810821172 ' )
def test_list_no_object_metadata ( self ) :
# get empty list of object metadata
""" Test listing object metadata for object without metadata """
object_name , _ = self . create_object ( self . container_name )
resp , _ = self . object_client . list_object_metadata (
@ -489,8 +504,7 @@ class ObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' 23a3674c-d6de-46c3-86af-ff92bfc8a3da ' )
def test_list_object_metadata_with_x_object_manifest ( self ) :
# get object metadata with x_object_manifest
""" Test getting object metadata with x_object_manifest """
# uploading segments
object_name , _ = self . _upload_segments ( )
# creating a manifest file
@ -530,7 +544,7 @@ class ObjectTest(base.BaseObjectTest):
@decorators.attr ( type = ' smoke ' )
@decorators.idempotent_id ( ' 02610ba7-86b7-4272-9ed8-aa8d417cb3cd ' )
def test_get_object ( self ) :
# retrieve object's data (in response body)
""" Test retrieving object ' s data (in response body) """
# create object
object_name , data = self . create_object ( self . container_name )
@ -543,7 +557,7 @@ class ObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' 005f9bf6-e06d-41ec-968e-96c78e0b1d82 ' )
def test_get_object_with_metadata ( self ) :
# get object with metadata
""" Test getting object with metadata """
object_name = data_utils . rand_name ( name = ' TestObject ' )
data = data_utils . random_bytes ( )
metadata = { ' X-Object-Meta-test-meta ' : ' Meta ' }
@ -562,7 +576,7 @@ class ObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' 05a1890e-7db9-4a6c-90a8-ce998a2bddfa ' )
def test_get_object_with_range ( self ) :
# get object with range
""" Test getting object with range """
object_name = data_utils . rand_name ( name = ' TestObject ' )
data = data_utils . random_bytes ( 100 )
self . object_client . create_object ( self . container_name ,
@ -580,7 +594,7 @@ class ObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' 11b4515b-7ba7-4ca8-8838-357ded86fc10 ' )
def test_get_object_with_x_object_manifest ( self ) :
# get object with x_object_manifest
""" Test getting object with x_object_manifest """
# uploading segments
object_name , data_segments = self . _upload_segments ( )
@ -623,7 +637,7 @@ class ObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' c05b4013-e4de-47af-be84-e598062b16fc ' )
def test_get_object_with_if_match ( self ) :
# get object with if_match
""" Test getting object with if_match """
object_name = data_utils . rand_name ( name = ' TestObject ' )
data = data_utils . random_bytes ( 10 )
create_md5 = hashlib . md5 ( data ) . hexdigest ( )
@ -643,7 +657,7 @@ class ObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' be133639-e5d2-4313-9b1f-2d59fc054a16 ' )
def test_get_object_with_if_modified_since ( self ) :
# get object with if_modified_since
""" Test getting object with if_modified_since """
object_name = data_utils . rand_name ( name = ' TestObject ' )
data = data_utils . random_bytes ( )
time_now = time . time ( )
@ -663,7 +677,7 @@ class ObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' 641500d5-1612-4042-a04d-01fc4528bc30 ' )
def test_get_object_with_if_none_match ( self ) :
# get object with if_none_match
""" Test getting object with if_none_match """
object_name = data_utils . rand_name ( name = ' TestObject ' )
data = data_utils . random_bytes ( )
create_md5 = hashlib . md5 ( data ) . hexdigest ( )
@ -685,7 +699,7 @@ class ObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' 0aa1201c-10aa-467a-bee7-63cbdd463152 ' )
def test_get_object_with_if_unmodified_since ( self ) :
# get object with if_unmodified_since
""" Test getting object with if_unmodified_since """
object_name , data = self . create_object ( self . container_name )
time_now = time . time ( )
@ -700,7 +714,7 @@ class ObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' 94587078-475f-48f9-a40f-389c246e31cd ' )
def test_get_object_with_x_newest ( self ) :
# get object with x_newest
""" Test getting object with x_newest """
object_name , data = self . create_object ( self . container_name )
list_metadata = { ' X-Newest ' : ' true ' }
@ -713,6 +727,7 @@ class ObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' 1a9ab572-1b66-4981-8c21-416e2a5e6011 ' )
def test_copy_object_in_same_container ( self ) :
""" Test copying object to another object in same container """
# create source object
src_object_name = data_utils . rand_name ( name = ' SrcObject ' )
src_data = data_utils . random_bytes ( size = len ( src_object_name ) * 2 )
@ -742,7 +757,7 @@ class ObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' 2248abba-415d-410b-9c30-22dff9cd6e67 ' )
def test_copy_object_to_itself ( self ) :
# change the content type of an existing object
""" Test changing the content type of an existing object """
# create object
object_name , _ = self . create_object ( self . container_name )
@ -769,6 +784,7 @@ class ObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' 06f90388-2d0e-40aa-934c-e9a8833e958a ' )
def test_copy_object_2d_way ( self ) :
""" Test copying object ' s data to the new object using COPY """
# create source object
src_object_name = data_utils . rand_name ( name = ' SrcObject ' )
src_data = data_utils . random_bytes ( size = len ( src_object_name ) * 2 )
@ -793,6 +809,7 @@ class ObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' aa467252-44f3-472a-b5ae-5b57c3c9c147 ' )
def test_copy_object_across_containers ( self ) :
""" Test copying object to another container """
# create a container to use as a source container
src_container_name = data_utils . rand_name ( name = ' TestSourceContainer ' )
self . container_client . update_container ( src_container_name )
@ -837,6 +854,7 @@ class ObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' 5a9e2cc6-85b6-46fc-916d-0cbb7a88e5fd ' )
def test_copy_object_with_x_fresh_metadata ( self ) :
""" Test copying objectwith x_fresh_metadata """
# create source object
metadata = { ' x-object-meta-src ' : ' src_value ' }
src_object_name , data = self . create_object ( self . container_name ,
@ -858,6 +876,7 @@ class ObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' a28a8b99-e701-4d7e-9d84-3b66f121460b ' )
def test_copy_object_with_x_object_metakey ( self ) :
""" Test copying object with x_object_metakey """
# create source object
metadata = { ' x-object-meta-src ' : ' src_value ' }
src_obj_name , data = self . create_object ( self . container_name ,
@ -881,6 +900,7 @@ class ObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' edabedca-24c3-4322-9b70-d6d9f942a074 ' )
def test_copy_object_with_x_object_meta ( self ) :
""" Test copying object with x_object_meta """
# create source object
metadata = { ' x-object-meta-src ' : ' src_value ' }
src_obj_name , data = self . create_object ( self . container_name ,
@ -904,6 +924,7 @@ class ObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' e3e6a64a-9f50-4955-b987-6ce6767c97fb ' )
def test_object_upload_in_segments ( self ) :
""" Test uploading object in segments """
# create object
object_name = data_utils . rand_name ( name = ' LObject ' )
data = data_utils . arbitrary_string ( )
@ -947,10 +968,13 @@ class ObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' 50d01f12-526f-4360-9ac2-75dd508d7b68 ' )
def test_get_object_if_different ( self ) :
# http://en.wikipedia.org/wiki/HTTP_ETag
# Make a conditional request for an object using the If-None-Match
# header, it should get downloaded only if the local file is different,
# otherwise the response code should be 304 Not Modified
""" Test getting object content only when the local file is different
http : / / en . wikipedia . org / wiki / HTTP_ETag
Make a conditional request for an object using the If - None - Match
header , it should get downloaded only if the local file is different ,
otherwise the response code should be 304 Not Modified
"""
object_name , data = self . create_object ( self . container_name )
# local copy is identical, no download
md5 = hashlib . md5 ( data ) . hexdigest ( )
@ -975,6 +999,7 @@ class ObjectTest(base.BaseObjectTest):
class PublicObjectTest ( base . BaseObjectTest ) :
""" Test public storage object """
credentials = [ [ ' operator ' , CONF . object_storage . operator_role ] ,
[ ' operator_alt ' , CONF . object_storage . operator_role ] ]
@ -1000,9 +1025,11 @@ class PublicObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' 07c9cf95-c0d4-4b49-b9c8-0ef2c9b27193 ' )
def test_access_public_container_object_without_using_creds ( self ) :
# make container public-readable and access an object in it object
# anonymously, without using credentials
""" Test accessing public container object without using credentials
Make container public - readable and access an object in it object
anonymously , without using credentials .
"""
# update container metadata to make it publicly readable
cont_headers = { ' X-Container-Read ' : ' .r:*,.rlistings ' }
resp_meta , body = (
@ -1040,8 +1067,11 @@ class PublicObjectTest(base.BaseObjectTest):
@decorators.idempotent_id ( ' 54e2a2fe-42dc-491b-8270-8e4217dd4cdc ' )
def test_access_public_object_with_another_user_creds ( self ) :
# make container public-readable and access an object in it using
# another user's credentials
""" Test accessing public object with another user ' s credentials
Make container public - readable and access an object in it using
another user ' s credentials.
"""
cont_headers = { ' X-Container-Read ' : ' .r:*,.rlistings ' }
resp_meta , body = (
self . container_client . create_update_or_delete_container_metadata (