]> git-server-git.apps.pok.os.sepia.ceph.com Git - s3-tests.git/commitdiff
test_s3: fix test_bucket_logging_request_id for newer botocore 752/head
authorcheese-cakee <farzanaman99@gmail.com>
Fri, 15 May 2026 20:02:36 +0000 (01:32 +0530)
committercheese-cakee <farzanaman99@gmail.com>
Fri, 15 May 2026 20:37:56 +0000 (02:07 +0530)
The test was using a boto3 event handler to capture the x-amz-request-id
header, incorrectly accessing kwargs["response"] in an after-call event.
Botocore's after-call event does not pass a "response" kwarg; it passes
"parsed", "http_response", "model", and "context". Fix by reading the
request ID directly from the put_object() response, which is simpler and
works across all botocore versions.

Fixes: https://tracker.ceph.com/issues/76587
Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
s3tests/functional/test_s3.py

index c34c1e46946105c721784c1172e35e70aa32b9cf..36aa5d462cec7bc52826f534a157828d65ecb7af 100644 (file)
@@ -15795,14 +15795,9 @@ def test_bucket_logging_request_id():
     assert response['ResponseMetadata']['HTTPStatusCode'] == 200
 
     # capture x-amz-request-id from the put_object response
-    request_id = None
-    def capture_request_id(**kwargs):
-        nonlocal request_id
-        request_id = kwargs['response']['ResponseMetadata']['HTTPHeaders'].get('x-amz-request-id')
-    client.meta.events.register('after-call.s3.PutObject', capture_request_id)
-
-    client.put_object(Bucket=src_bucket_name, Key=key, Body=randcontent())
-    assert request_id is not None, 'failed to capture x-amz-request-id from response'
+    response = client.put_object(Bucket=src_bucket_name, Key=key, Body=randcontent())
+    request_id = response['ResponseMetadata']['HTTPHeaders'].get('x-amz-request-id')
+    assert request_id is not None, 'failed to read x-amz-request-id from response headers'
 
     _flush_logs(client, src_bucket_name)
     response = client.list_objects_v2(Bucket=log_bucket_name)