mirror of
https://github.com/ceph/s3-tests.git
synced 2024-11-21 23:29:47 +00:00
s3tests: extend object versions test
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
This commit is contained in:
parent
0f0e833801
commit
5d67c7f5df
1 changed files with 59 additions and 36 deletions
|
@ -5202,19 +5202,25 @@ def test_versioning_bucket_create_suspend():
|
||||||
bucket.configure_versioning(False)
|
bucket.configure_versioning(False)
|
||||||
check_versioning(bucket, "Suspended")
|
check_versioning(bucket, "Suspended")
|
||||||
|
|
||||||
@attr(resource='object')
|
def test_obj_versions(bucket, objname, contents):
|
||||||
@attr(method='create')
|
# check to see if object is pointing at correct version
|
||||||
@attr(operation='create versioned object')
|
key = bucket.get_key(objname)
|
||||||
@attr(assertion='can create access and remove appropriate versions')
|
|
||||||
@attr('versioning')
|
|
||||||
def test_versioning_obj_create_read_remove():
|
|
||||||
bucket = get_new_bucket()
|
|
||||||
objname = 'testobj'
|
|
||||||
|
|
||||||
total = 5
|
if len(contents) > 0:
|
||||||
|
print contents[-1]
|
||||||
|
print 'testing obj head', objname
|
||||||
|
eq(key.get_contents_as_string(), contents[-1])
|
||||||
|
i = len(contents)
|
||||||
|
for key in bucket.list_versions():
|
||||||
|
i -= 1
|
||||||
|
print 'testing obj version-id=', key.version_id
|
||||||
|
eq(key.get_contents_as_string(), contents[i])
|
||||||
|
else:
|
||||||
|
eq(key, None)
|
||||||
|
|
||||||
|
def create_multiple_versions(bucket, objname, num_versions):
|
||||||
c = []
|
c = []
|
||||||
for i in xrange(total):
|
for i in xrange(num_versions):
|
||||||
c.append('content-{i}'.format(i=i))
|
c.append('content-{i}'.format(i=i))
|
||||||
|
|
||||||
key = bucket.new_key(objname)
|
key = bucket.new_key(objname)
|
||||||
|
@ -5223,39 +5229,56 @@ def test_versioning_obj_create_read_remove():
|
||||||
if i == 0:
|
if i == 0:
|
||||||
bucket.configure_versioning(True)
|
bucket.configure_versioning(True)
|
||||||
check_versioning(bucket, "Enabled")
|
check_versioning(bucket, "Enabled")
|
||||||
|
|
||||||
# check to see if object is pointing at correct version
|
|
||||||
key = bucket.get_key(objname)
|
|
||||||
eq(key.get_contents_as_string(), c[-1])
|
|
||||||
print 'total', total
|
|
||||||
|
|
||||||
k = []
|
k = []
|
||||||
for o in bucket.list_versions():
|
for o in bucket.list_versions():
|
||||||
|
print o, o.version_id
|
||||||
k.insert(0, o)
|
k.insert(0, o)
|
||||||
|
print 'created obj name=', objname, 'version-id=', o.version_id
|
||||||
|
|
||||||
for j in xrange(total):
|
eq(len(k), len(c))
|
||||||
|
|
||||||
|
for j in xrange(num_versions):
|
||||||
print j, k[j], k[j].version_id
|
print j, k[j], k[j].version_id
|
||||||
|
|
||||||
for j in xrange(total):
|
return (k, c)
|
||||||
# check by versioned key
|
|
||||||
rmkey = k.pop(-1)
|
|
||||||
eq(rmkey.get_contents_as_string(), c[-1])
|
|
||||||
|
|
||||||
# remove version
|
|
||||||
print 'removing version_id=', rmkey.version_id
|
|
||||||
bucket.delete_key(rmkey.name, version_id = rmkey.version_id)
|
|
||||||
c.pop(-1)
|
|
||||||
|
|
||||||
# check to see if object is pointing at correct version
|
def remove_obj_version(bucket, k, c, i):
|
||||||
key = bucket.get_key(objname)
|
# check by versioned key
|
||||||
|
i = i % len(k)
|
||||||
|
rmkey = k.pop(i)
|
||||||
|
eq(rmkey.get_contents_as_string(), c.pop(i))
|
||||||
|
|
||||||
if len(c) > 0:
|
# remove version
|
||||||
print c[-1]
|
print 'removing version_id=', rmkey.version_id
|
||||||
eq(key.get_contents_as_string(), c[-1])
|
bucket.delete_key(rmkey.name, version_id = rmkey.version_id)
|
||||||
i = len(c)
|
|
||||||
for key in bucket.list_versions():
|
def do_test_create_remove_versions(bucket, objname, num_versions, remove_start_idx, idx_inc):
|
||||||
i -= 1
|
(k, c) = create_multiple_versions(bucket, objname, num_versions)
|
||||||
eq(key.get_contents_as_string(), c[i])
|
|
||||||
else:
|
test_obj_versions(bucket, objname, c)
|
||||||
eq(key, None)
|
|
||||||
|
idx = remove_start_idx
|
||||||
|
|
||||||
|
for j in xrange(num_versions):
|
||||||
|
remove_obj_version(bucket, k, c, idx)
|
||||||
|
idx += idx_inc
|
||||||
|
test_obj_versions(bucket, objname, c)
|
||||||
|
|
||||||
|
@attr(resource='object')
|
||||||
|
@attr(method='create')
|
||||||
|
@attr(operation='create versioned object')
|
||||||
|
@attr(assertion='can create access and remove appropriate versions')
|
||||||
|
@attr('versioning')
|
||||||
|
def test_versioning_obj_create_read_remove():
|
||||||
|
bucket = get_new_bucket()
|
||||||
|
objname = 'testobj'
|
||||||
|
num_vers = 5
|
||||||
|
|
||||||
|
do_test_create_remove_versions(bucket, objname, num_vers, -1, 0)
|
||||||
|
do_test_create_remove_versions(bucket, objname, num_vers, -1, 0)
|
||||||
|
do_test_create_remove_versions(bucket, objname, num_vers, 0, 0)
|
||||||
|
do_test_create_remove_versions(bucket, objname, num_vers, 1, 0)
|
||||||
|
do_test_create_remove_versions(bucket, objname, num_vers, 4, -1)
|
||||||
|
do_test_create_remove_versions(bucket, objname, num_vers, 3, 3)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue