From e064dc6a857ddf619017f9e6968e4b5f68ee0908 Mon Sep 17 00:00:00 2001 From: zhang Shaowen Date: Tue, 20 Nov 2018 21:05:57 +0800 Subject: [PATCH 1/2] Add test case for appending object. Signed-off-by: zhang Shaowen --- s3tests/functional/test_s3.py | 64 +++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/s3tests/functional/test_s3.py b/s3tests/functional/test_s3.py index e4d41f6..ba5ec24 100644 --- a/s3tests/functional/test_s3.py +++ b/s3tests/functional/test_s3.py @@ -65,6 +65,7 @@ from . import ( is_slow_backend, _make_request, _make_bucket_request, + _make_raw_request, ) @@ -2761,6 +2762,69 @@ def test_put_object_ifnonmatch_overwrite_existed_failed(): eq(got_old_data, 'bar') +@attr(resource='object') +@attr(method='put') +@attr(operation='append object') +@attr(assertion='success') +@attr('fails_on_aws') +@attr('appendobject') +def test_append_object(): + bucket = get_new_bucket() + key = bucket.new_key('foo') + expires_in = 100000 + url = key.generate_url(expires_in, method='PUT') + o = urlparse(url) + path = o.path + '?' + o.query + path1 = path + '&append&position=0' + res = _make_raw_request(host=s3.main.host, port=s3.main.port, method='PUT', path=path1, body='abc') + path2 = path + '&append&position=3' + res = _make_raw_request(host=s3.main.host, port=s3.main.port, method='PUT', path=path2, body='abc') + eq(res.status, 200) + eq(res.reason, 'OK') + + key = bucket.get_key('foo') + eq(key.size, 6) + + +@attr(resource='object') +@attr(method='put') +@attr(operation='append to normal object') +@attr(assertion='fails 409') +@attr('fails_on_aws') +@attr('appendobject') +def test_append_normal_object(): + bucket = get_new_bucket() + key = bucket.new_key('foo') + key.set_contents_from_string('abc') + expires_in = 100000 + url = key.generate_url(expires_in, method='PUT') + o = urlparse(url) + path = o.path + '?' + o.query + path = path + '&append&position=3' + res = _make_raw_request(host=s3.main.host, port=s3.main.port, method='PUT', path=path, body='abc') + eq(res.status, 409) + + +@attr(resource='object') +@attr(method='put') +@attr(operation='append position not right') +@attr(assertion='fails 409') +@attr('fails_on_aws') +@attr('appendobject') +def test_append_object_position_wrong(): + bucket = get_new_bucket() + key = bucket.new_key('foo') + expires_in = 100000 + url = key.generate_url(expires_in, method='PUT') + o = urlparse(url) + path = o.path + '?' + o.query + path1 = path + '&append&position=0' + res = _make_raw_request(host=s3.main.host, port=s3.main.port, method='PUT', path=path1, body='abc') + path2 = path + '&append&position=9' + res = _make_raw_request(host=s3.main.host, port=s3.main.port, method='PUT', path=path2, body='abc') + eq(res.status, 409) + eq(int(res.getheader('x-rgw-next-append-position')), 3) + def _setup_request(bucket_acl=None, object_acl=None): """ add a foo key, and specified key and bucket acls to From e92835a00bceb57ebac34897a777211aee0dde92 Mon Sep 17 00:00:00 2001 From: zhang Shaowen Date: Tue, 26 Feb 2019 10:10:29 +0800 Subject: [PATCH 2/2] add https support in apppend object test cases Signed-off-by: zhang Shaowen --- s3tests/functional/test_s3.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/s3tests/functional/test_s3.py b/s3tests/functional/test_s3.py index ba5ec24..8025f0d 100644 --- a/s3tests/functional/test_s3.py +++ b/s3tests/functional/test_s3.py @@ -2776,9 +2776,9 @@ def test_append_object(): o = urlparse(url) path = o.path + '?' + o.query path1 = path + '&append&position=0' - res = _make_raw_request(host=s3.main.host, port=s3.main.port, method='PUT', path=path1, body='abc') + res = _make_raw_request(host=s3.main.host, port=s3.main.port, method='PUT', path=path1, body='abc', secure=s3.main.is_secure) path2 = path + '&append&position=3' - res = _make_raw_request(host=s3.main.host, port=s3.main.port, method='PUT', path=path2, body='abc') + res = _make_raw_request(host=s3.main.host, port=s3.main.port, method='PUT', path=path2, body='abc', secure=s3.main.is_secure) eq(res.status, 200) eq(res.reason, 'OK') @@ -2801,7 +2801,7 @@ def test_append_normal_object(): o = urlparse(url) path = o.path + '?' + o.query path = path + '&append&position=3' - res = _make_raw_request(host=s3.main.host, port=s3.main.port, method='PUT', path=path, body='abc') + res = _make_raw_request(host=s3.main.host, port=s3.main.port, method='PUT', path=path, body='abc', secure=s3.main.is_secure) eq(res.status, 409) @@ -2819,9 +2819,9 @@ def test_append_object_position_wrong(): o = urlparse(url) path = o.path + '?' + o.query path1 = path + '&append&position=0' - res = _make_raw_request(host=s3.main.host, port=s3.main.port, method='PUT', path=path1, body='abc') + res = _make_raw_request(host=s3.main.host, port=s3.main.port, method='PUT', path=path1, body='abc', secure=s3.main.is_secure) path2 = path + '&append&position=9' - res = _make_raw_request(host=s3.main.host, port=s3.main.port, method='PUT', path=path2, body='abc') + res = _make_raw_request(host=s3.main.host, port=s3.main.port, method='PUT', path=path2, body='abc', secure=s3.main.is_secure) eq(res.status, 409) eq(int(res.getheader('x-rgw-next-append-position')), 3)