]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/s3-tests: test HEAD bucket object count excludes incomplete multipart parts
authorOguzhan Ozmen <oozmen@bloomberg.net>
Wed, 24 Jun 2026 16:49:40 +0000 (16:49 +0000)
committerOguzhan Ozmen <oozmen@bloomberg.net>
Wed, 24 Jun 2026 16:53:29 +0000 (16:53 +0000)
Add test_head_bucket_usage_multipart_incomplete to verify that
X-RGW-Object-Count (returned by HEAD Bucket with ?read-stats=true)
does not count in-progress multipart upload parts as completed
objects.

After uploading 2 parts without completing, HEAD bucket should
report 0 objects and ListObjectsV2 should return 0 keys.

Tests: https://tracker.ceph.com/issues/77509
Signed-off-by: Oguzhan Ozmen <oozmen@bloomberg.net>
src/test/rgw/s3-tests/s3tests/functional/test_s3.py

index 9878c248606c2f1b3681628f5b0f50455e428979..6dd04d5a2ad237381ff6ce9882c02c358b4288be 100644 (file)
@@ -1127,6 +1127,40 @@ def test_head_bucket_usage():
     assert hdrs['X-RGW-Bytes-Used'] == '3'
     assert hdrs['X-RGW-Quota-Max-Buckets'] == '1000'
 
+@pytest.mark.fails_on_aws
+@pytest.mark.fails_on_dbstore
+def test_head_bucket_usage_multipart_incomplete():
+    bucket_name = get_new_bucket()
+    client = get_client()
+
+    # initiate a multipart upload and upload 2 parts without completing
+    response = client.create_multipart_upload(Bucket=bucket_name, Key='mpu-obj')
+    upload_id = response['UploadId']
+    part_body = 'x' * (5 * 1024 * 1024)
+    for part_num in (1, 2):
+        client.upload_part(Bucket=bucket_name, Key='mpu-obj',
+                           UploadId=upload_id, PartNumber=part_num,
+                           Body=part_body)
+
+    # HEAD bucket with read-stats should show 0 objects: incomplete
+    # multipart parts are not counted as user-visible objects.
+    def add_read_stats_param(request, **kwargs):
+        request.params['read-stats'] = 'true'
+
+    client.meta.events.register('request-created.s3.HeadBucket', add_read_stats_param)
+    client.meta.events.register('after-call.s3.HeadBucket', get_http_response)
+    client.head_bucket(Bucket=bucket_name)
+    hdrs = http_response['headers']
+    assert hdrs['X-RGW-Object-Count'] == '0'
+
+    # ListObjects should also return nothing
+    response = client.list_objects_v2(Bucket=bucket_name)
+    assert response['KeyCount'] == 0
+
+    # cleanup
+    client.abort_multipart_upload(Bucket=bucket_name, Key='mpu-obj',
+                                  UploadId=upload_id)
+
 @pytest.mark.fails_on_aws
 @pytest.mark.fails_on_dbstore
 def test_bucket_list_unordered():