MINOR: improve s3 test connection (#16158)

This commit is contained in:
Mayur Singal 2024-05-07 22:29:00 +05:30 committed by GitHub
parent 1acf7d92d3
commit 5cae2137d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -61,13 +61,15 @@ def test_connection(
def test_buckets(connection: S3Connection, client: S3ObjectStoreClient): def test_buckets(connection: S3Connection, client: S3ObjectStoreClient):
if connection.bucketNames: if connection.bucketNames:
return partial( for bucket_name in connection.bucketNames:
client.s3_client.list_objects, Bucket=connection.bucketNames[0] client.s3_client.list_objects(Bucket=bucket_name)
) return
return client.s3_client.list_buckets client.s3_client.list_buckets()
test_fn = { test_fn = {
"ListBuckets": test_buckets(service_connection, client), "ListBuckets": partial(
test_buckets, client=client, connection=service_connection
),
"GetMetrics": partial( "GetMetrics": partial(
client.cloudwatch_client.list_metrics, Namespace="AWS/S3" client.cloudwatch_client.list_metrics, Namespace="AWS/S3"
), ),