HeadBucket: add read-stats query string for usage test

Refs: https://github.com/ceph/ceph/pull/56756

Signed-off-by: Seena Fallah <seenafallah@gmail.com>
(cherry picked from commit 3145b1b0c3)
This commit is contained in:
Seena Fallah 2024-12-10 22:21:10 +01:00 committed by Casey Bodley
parent d23cb37d70
commit f723879d10

View file

@ -1098,10 +1098,13 @@ def test_account_usage():
@pytest.mark.fails_on_aws
@pytest.mark.fails_on_dbstore
def test_head_bucket_usage():
# boto3.set_stream_logger(name='botocore')
client = get_client()
bucket_name = _create_objects(keys=['foo'])
# adds the unordered query parameter
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']
@ -3322,6 +3325,10 @@ def test_bucket_head_extended():
bucket_name = get_new_bucket()
client = get_client()
def add_read_stats_param(request, **kwargs):
request.params['read-stats'] = 'true'
client.meta.events.register('request-created.s3.HeadBucket', add_read_stats_param)
response = client.head_bucket(Bucket=bucket_name)
assert int(response['ResponseMetadata']['HTTPHeaders']['x-rgw-object-count']) == 0
assert int(response['ResponseMetadata']['HTTPHeaders']['x-rgw-bytes-used']) == 0