Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

serve s3: add runner for the ceph/s3-tests compatibility suite

Nick Craig-Wood82644742b77f
diff --git a/cmd/serve/s3/s3tests/README.md b/cmd/serve/s3/s3tests/README.md
new file mode 100644
index 000000000..8ac27df1f
--- /dev/null
+++ b/cmd/serve/s3/s3tests/README.md
@@ -0,0 +1,70 @@
+# s3-tests for rclone serve s3
+
+This runs the [ceph/s3-tests](https://github.com/ceph/s3-tests) S3
+compatibility suite against `rclone serve s3`.
+
+It needs `git`, `go` and `python3` (with the `venv` module). Run it with
+
+```sh
+cmd/serve/s3/s3tests/run.sh
+```
+
+This fetches s3-tests at a pinned commit, makes a Python venv with the
+pinned `requirements.txt` (both cached in `~/.cache/rclone-s3tests`),
+builds rclone from this tree and serves a temporary local directory
+with the three users s3-tests needs. A full run takes about 10 minutes.
+
+To run a subset, pass test ids or pytest options
+
+```sh
+cmd/serve/s3/s3tests/run.sh s3tests/functional/test_s3.py::test_bucket_list_empty
+cmd/serve/s3/s3tests/run.sh -k multipart
+```
+
+To test a different remote or flags
+
+```sh
+RCLONE_REMOTE=:memory: cmd/serve/s3/s3tests/run.sh
+RCLONE_ARGS="--vfs-cache-mode full" cmd/serve/s3/s3tests/run.sh
+```
+
+See the top of `run.sh` for the other environment variables.
+
+## Results
+
+Results go to a temporary directory (or `$S3TESTS_OUT`) which has
+
+- `pytest.log` - the full pytest output, with tracebacks
+- `junit.xml` - machine readable results
+- `rclone.log` - the log from `rclone serve s3`
+- `report.txt` - the summary printed at the end
+
+The summary shows pass/fail/skip counts by feature area and the
+commonest failures.
+
+Many tests fail because they test features `serve s3` doesn't
+implement (ACLs, versioning, lifecycle, bucket policies, encryption,
+object lock, etc), so rather than tracking the failures,
+`expected-pass.txt` lists the tests which should pass. The run fails
+if any of them don't, and lists any other tests which now pass. After
+fixing something, add the newly passing tests with
+
+```sh
+cmd/serve/s3/s3tests/run.sh --update
+```
+
+and commit the change to `expected-pass.txt` with the fix.
+
+## Files
+
+- `run.sh` - the test runner
+- `report.py` - summarises the results and checks them against `expected-pass.txt`
+- `rclone_shim.py` - pytest plugin adapting the s3-tests cleanup to
+ `serve s3` (it doesn't change what the tests test)
+- `s3tests.conf.in` - the s3-tests config
+- `requirements.txt` - pinned Python dependencies
+- `expected-pass.txt` - the tests which should pass
+
+The s3-tests suite has moved into the ceph repository
+(`src/test/rgw/s3-tests` in [ceph/ceph](https://github.com/ceph/ceph)).
+`run.sh` uses the final commit of the standalone repository.
diff --git a/cmd/serve/s3/s3tests/expected-pass.txt b/cmd/serve/s3/s3tests/expected-pass.txt
new file mode 100644
index 000000000..68b3a1a96
--- /dev/null
+++ b/cmd/serve/s3/s3tests/expected-pass.txt
@@ -0,0 +1,209 @@
+# Tests expected to pass - maintained by run.sh --update
+s3tests/functional/test_headers.py::test_bucket_create_bad_contentlength_empty
+s3tests/functional/test_headers.py::test_bucket_create_bad_contentlength_negative
+s3tests/functional/test_headers.py::test_bucket_create_bad_contentlength_none
+s3tests/functional/test_headers.py::test_bucket_create_bad_expect_empty
+s3tests/functional/test_headers.py::test_bucket_create_contentlength_none
+s3tests/functional/test_headers.py::test_object_acl_create_contentlength_none
+s3tests/functional/test_headers.py::test_object_create_bad_contentlength_empty
+s3tests/functional/test_headers.py::test_object_create_bad_contentlength_negative
+s3tests/functional/test_headers.py::test_object_create_bad_contenttype_empty
+s3tests/functional/test_headers.py::test_object_create_bad_contenttype_invalid
+s3tests/functional/test_headers.py::test_object_create_bad_contenttype_none
+s3tests/functional/test_headers.py::test_object_create_bad_expect_empty
+s3tests/functional/test_headers.py::test_object_create_bad_expect_none
+s3tests/functional/test_headers.py::test_object_create_bad_md5_bad
+s3tests/functional/test_headers.py::test_object_create_bad_md5_empty
+s3tests/functional/test_headers.py::test_object_create_bad_md5_invalid_short
+s3tests/functional/test_headers.py::test_object_create_bad_md5_none
+s3tests/functional/test_s3.py::test_100_continue_error_retry
+s3tests/functional/test_s3.py::test_abort_multipart_upload
+s3tests/functional/test_s3.py::test_abort_multipart_upload_not_found
+s3tests/functional/test_s3.py::test_atomic_conditional_write_1mb
+s3tests/functional/test_s3.py::test_atomic_dual_write_1mb
+s3tests/functional/test_s3.py::test_atomic_dual_write_4mb
+s3tests/functional/test_s3.py::test_atomic_dual_write_8mb
+s3tests/functional/test_s3.py::test_atomic_multipart_upload_write
+s3tests/functional/test_s3.py::test_atomic_read_1mb
+s3tests/functional/test_s3.py::test_atomic_read_4mb
+s3tests/functional/test_s3.py::test_atomic_read_8mb
+s3tests/functional/test_s3.py::test_atomic_write_1mb
+s3tests/functional/test_s3.py::test_atomic_write_4mb
+s3tests/functional/test_s3.py::test_atomic_write_8mb
+s3tests/functional/test_s3.py::test_atomic_write_bucket_gone
+s3tests/functional/test_s3.py::test_basic_key_count
+s3tests/functional/test_s3.py::test_bucket_create_delete
+s3tests/functional/test_s3.py::test_bucket_create_exists_nonowner
+s3tests/functional/test_s3.py::test_bucket_create_naming_bad_ip
+s3tests/functional/test_s3.py::test_bucket_create_naming_bad_short_one
+s3tests/functional/test_s3.py::test_bucket_create_naming_bad_short_two
+s3tests/functional/test_s3.py::test_bucket_create_naming_bad_starts_nonalpha
+s3tests/functional/test_s3.py::test_bucket_create_naming_dns_dash_at_end
+s3tests/functional/test_s3.py::test_bucket_create_naming_dns_dash_dot
+s3tests/functional/test_s3.py::test_bucket_create_naming_dns_dot_dash
+s3tests/functional/test_s3.py::test_bucket_create_naming_dns_dot_dot
+s3tests/functional/test_s3.py::test_bucket_create_naming_dns_long
+s3tests/functional/test_s3.py::test_bucket_create_naming_dns_underscore
+s3tests/functional/test_s3.py::test_bucket_create_naming_good_contains_hyphen
+s3tests/functional/test_s3.py::test_bucket_create_naming_good_contains_period
+s3tests/functional/test_s3.py::test_bucket_create_naming_good_long_60
+s3tests/functional/test_s3.py::test_bucket_create_naming_good_long_61
+s3tests/functional/test_s3.py::test_bucket_create_naming_good_long_62
+s3tests/functional/test_s3.py::test_bucket_create_naming_good_long_63
+s3tests/functional/test_s3.py::test_bucket_create_naming_good_starts_alpha
+s3tests/functional/test_s3.py::test_bucket_create_naming_good_starts_digit
+s3tests/functional/test_s3.py::test_bucket_create_special_key_names
+s3tests/functional/test_s3.py::test_bucket_delete_nonempty
+s3tests/functional/test_s3.py::test_bucket_delete_notexist
+s3tests/functional/test_s3.py::test_bucket_head
+s3tests/functional/test_s3.py::test_bucket_head_notexist
+s3tests/functional/test_s3.py::test_bucket_list_delimiter_empty
+s3tests/functional/test_s3.py::test_bucket_list_delimiter_none
+s3tests/functional/test_s3.py::test_bucket_list_delimiter_not_exist
+s3tests/functional/test_s3.py::test_bucket_list_delimiter_prefix
+s3tests/functional/test_s3.py::test_bucket_list_delimiter_prefix_underscore
+s3tests/functional/test_s3.py::test_bucket_list_delimiter_unreadable
+s3tests/functional/test_s3.py::test_bucket_list_distinct
+s3tests/functional/test_s3.py::test_bucket_list_empty
+s3tests/functional/test_s3.py::test_bucket_list_long_name
+s3tests/functional/test_s3.py::test_bucket_list_many
+s3tests/functional/test_s3.py::test_bucket_list_marker_after_list
+s3tests/functional/test_s3.py::test_bucket_list_marker_empty
+s3tests/functional/test_s3.py::test_bucket_list_marker_none
+s3tests/functional/test_s3.py::test_bucket_list_marker_not_in_list
+s3tests/functional/test_s3.py::test_bucket_list_marker_unreadable
+s3tests/functional/test_s3.py::test_bucket_list_maxkeys_invalid
+s3tests/functional/test_s3.py::test_bucket_list_maxkeys_none
+s3tests/functional/test_s3.py::test_bucket_list_maxkeys_one
+s3tests/functional/test_s3.py::test_bucket_list_prefix_alt
+s3tests/functional/test_s3.py::test_bucket_list_prefix_basic
+s3tests/functional/test_s3.py::test_bucket_list_prefix_delimiter_basic
+s3tests/functional/test_s3.py::test_bucket_list_prefix_delimiter_prefix_delimiter_not_exist
+s3tests/functional/test_s3.py::test_bucket_list_prefix_empty
+s3tests/functional/test_s3.py::test_bucket_list_prefix_none
+s3tests/functional/test_s3.py::test_bucket_list_prefix_not_exist
+s3tests/functional/test_s3.py::test_bucket_list_special_prefix
+s3tests/functional/test_s3.py::test_bucket_listv2_both_continuationtoken_startafter
+s3tests/functional/test_s3.py::test_bucket_listv2_continuationtoken
+s3tests/functional/test_s3.py::test_bucket_listv2_delimiter_empty
+s3tests/functional/test_s3.py::test_bucket_listv2_delimiter_none
+s3tests/functional/test_s3.py::test_bucket_listv2_delimiter_not_exist
+s3tests/functional/test_s3.py::test_bucket_listv2_delimiter_prefix
+s3tests/functional/test_s3.py::test_bucket_listv2_delimiter_prefix_underscore
+s3tests/functional/test_s3.py::test_bucket_listv2_delimiter_unreadable
+s3tests/functional/test_s3.py::test_bucket_listv2_fetchowner_defaultempty
+s3tests/functional/test_s3.py::test_bucket_listv2_fetchowner_empty
+s3tests/functional/test_s3.py::test_bucket_listv2_many
+s3tests/functional/test_s3.py::test_bucket_listv2_maxkeys_none
+s3tests/functional/test_s3.py::test_bucket_listv2_maxkeys_one
+s3tests/functional/test_s3.py::test_bucket_listv2_prefix_alt
+s3tests/functional/test_s3.py::test_bucket_listv2_prefix_basic
+s3tests/functional/test_s3.py::test_bucket_listv2_prefix_delimiter_basic
+s3tests/functional/test_s3.py::test_bucket_listv2_prefix_delimiter_prefix_delimiter_not_exist
+s3tests/functional/test_s3.py::test_bucket_listv2_prefix_empty
+s3tests/functional/test_s3.py::test_bucket_listv2_prefix_none
+s3tests/functional/test_s3.py::test_bucket_listv2_prefix_not_exist
+s3tests/functional/test_s3.py::test_bucket_listv2_prefix_unreadable
+s3tests/functional/test_s3.py::test_bucket_listv2_startafter_after_list
+s3tests/functional/test_s3.py::test_bucket_listv2_startafter_not_in_list
+s3tests/functional/test_s3.py::test_bucket_listv2_startafter_unreadable
+s3tests/functional/test_s3.py::test_bucket_notexist
+s3tests/functional/test_s3.py::test_bucket_recreate_new_acl
+s3tests/functional/test_s3.py::test_bucket_recreate_overwrite_acl
+s3tests/functional/test_s3.py::test_buckets_create_then_list
+s3tests/functional/test_s3.py::test_buckets_list_ctime
+s3tests/functional/test_s3.py::test_bucketv2_notexist
+s3tests/functional/test_s3.py::test_copy_enc[sse-c-unencrypted-STANDARD-STANDARD-1024]
+s3tests/functional/test_s3.py::test_copy_enc[sse-c-unencrypted-STANDARD-STANDARD-1048576]
+s3tests/functional/test_s3.py::test_copy_enc[sse-c-unencrypted-STANDARD-STANDARD-1]
+s3tests/functional/test_s3.py::test_copy_enc[sse-c-unencrypted-STANDARD-STANDARD-8388608]
+s3tests/functional/test_s3.py::test_copy_enc[sse-kms-unencrypted-STANDARD-STANDARD-1024]
+s3tests/functional/test_s3.py::test_copy_enc[sse-kms-unencrypted-STANDARD-STANDARD-1048576]
+s3tests/functional/test_s3.py::test_copy_enc[sse-kms-unencrypted-STANDARD-STANDARD-1]
+s3tests/functional/test_s3.py::test_copy_enc[sse-kms-unencrypted-STANDARD-STANDARD-8388608]
+s3tests/functional/test_s3.py::test_copy_enc[unencrypted-unencrypted-STANDARD-STANDARD-1024]
+s3tests/functional/test_s3.py::test_copy_enc[unencrypted-unencrypted-STANDARD-STANDARD-1048576]
+s3tests/functional/test_s3.py::test_copy_enc[unencrypted-unencrypted-STANDARD-STANDARD-1]
+s3tests/functional/test_s3.py::test_copy_enc[unencrypted-unencrypted-STANDARD-STANDARD-8388608]
+s3tests/functional/test_s3.py::test_copy_object_ifmatch_good
+s3tests/functional/test_s3.py::test_copy_object_ifnonematch_failed
+s3tests/functional/test_s3.py::test_encrypted_transfer_13b
+s3tests/functional/test_s3.py::test_encrypted_transfer_1MB
+s3tests/functional/test_s3.py::test_encrypted_transfer_1b
+s3tests/functional/test_s3.py::test_encrypted_transfer_1kb
+s3tests/functional/test_s3.py::test_get_obj_tagging
+s3tests/functional/test_s3.py::test_get_object_ifmatch_good
+s3tests/functional/test_s3.py::test_get_object_ifmodifiedsince_good
+s3tests/functional/test_s3.py::test_get_object_ifnonematch_failed
+s3tests/functional/test_s3.py::test_get_object_ifunmodifiedsince_failed
+s3tests/functional/test_s3.py::test_list_buckets_bad_auth
+s3tests/functional/test_s3.py::test_list_buckets_invalid_auth
+s3tests/functional/test_s3.py::test_list_multipart_upload
+s3tests/functional/test_s3.py::test_multi_object_delete
+s3tests/functional/test_s3.py::test_multi_object_delete_key_limit
+s3tests/functional/test_s3.py::test_multi_objectv2_delete
+s3tests/functional/test_s3.py::test_multi_objectv2_delete_key_limit
+s3tests/functional/test_s3.py::test_multipart_upload_complete_without_create
+s3tests/functional/test_s3.py::test_multipart_upload_contents
+s3tests/functional/test_s3.py::test_multipart_upload_empty
+s3tests/functional/test_s3.py::test_multipart_upload_incorrect_etag
+s3tests/functional/test_s3.py::test_multipart_upload_missing_part
+s3tests/functional/test_s3.py::test_multipart_upload_multiple_sizes
+s3tests/functional/test_s3.py::test_multipart_upload_overwrite_existing_object
+s3tests/functional/test_s3.py::test_object_acl_full_control_verify_owner
+s3tests/functional/test_s3.py::test_object_copy_16m
+s3tests/functional/test_s3.py::test_object_copy_bucket_not_found
+s3tests/functional/test_s3.py::test_object_copy_canned_acl
+s3tests/functional/test_s3.py::test_object_copy_diff_bucket
+s3tests/functional/test_s3.py::test_object_copy_key_not_found
+s3tests/functional/test_s3.py::test_object_copy_same_bucket
+s3tests/functional/test_s3.py::test_object_copy_verify_contenttype
+s3tests/functional/test_s3.py::test_object_copy_zero_size
+s3tests/functional/test_s3.py::test_object_head_zero_bytes
+s3tests/functional/test_s3.py::test_object_lock_changing_mode_from_governance_with_bypass
+s3tests/functional/test_s3.py::test_object_lock_get_legal_hold
+s3tests/functional/test_s3.py::test_object_lock_put_legal_hold
+s3tests/functional/test_s3.py::test_object_metadata_replaced_on_put
+s3tests/functional/test_s3.py::test_object_presigned_put_object_with_acl
+s3tests/functional/test_s3.py::test_object_presigned_put_object_with_acl_tenant
+s3tests/functional/test_s3.py::test_object_put_authenticated
+s3tests/functional/test_s3.py::test_object_raw_authenticated
+s3tests/functional/test_s3.py::test_object_raw_authenticated_bucket_acl
+s3tests/functional/test_s3.py::test_object_raw_authenticated_bucket_gone
+s3tests/functional/test_s3.py::test_object_raw_authenticated_object_acl
+s3tests/functional/test_s3.py::test_object_raw_authenticated_object_gone
+s3tests/functional/test_s3.py::test_object_raw_response_headers
+s3tests/functional/test_s3.py::test_object_read_not_exist
+s3tests/functional/test_s3.py::test_object_write_cache_control
+s3tests/functional/test_s3.py::test_object_write_check_etag
+s3tests/functional/test_s3.py::test_object_write_file
+s3tests/functional/test_s3.py::test_object_write_read_update_read_delete
+s3tests/functional/test_s3.py::test_object_write_to_nonexist_bucket
+s3tests/functional/test_s3.py::test_post_object_condition_is_case_sensitive
+s3tests/functional/test_s3.py::test_post_object_empty_conditions
+s3tests/functional/test_s3.py::test_post_object_expires_is_case_sensitive
+s3tests/functional/test_s3.py::test_post_object_invalid_content_length_argument
+s3tests/functional/test_s3.py::test_post_object_invalid_date_format
+s3tests/functional/test_s3.py::test_post_object_missing_conditions_list
+s3tests/functional/test_s3.py::test_post_object_missing_content_length_argument
+s3tests/functional/test_s3.py::test_post_object_missing_expires_condition
+s3tests/functional/test_s3.py::test_post_object_missing_signature
+s3tests/functional/test_s3.py::test_post_object_no_key_specified
+s3tests/functional/test_s3.py::test_post_object_upload_size_below_minimum
+s3tests/functional/test_s3.py::test_post_object_upload_size_limit_exceeded
+s3tests/functional/test_s3.py::test_put_max_kvsize_tags
+s3tests/functional/test_s3.py::test_put_max_tags
+s3tests/functional/test_s3.py::test_put_modify_tags
+s3tests/functional/test_s3.py::test_put_object_ifmatch_good
+s3tests/functional/test_s3.py::test_put_object_ifmatch_overwrite_existed_good
+s3tests/functional/test_s3.py::test_put_object_ifnonmatch_good
+s3tests/functional/test_s3.py::test_put_object_ifnonmatch_nonexisted_good
+s3tests/functional/test_s3.py::test_ranged_request_empty_object
+s3tests/functional/test_s3.py::test_ranged_request_invalid_range
+s3tests/functional/test_s3.py::test_sse_kms_multipart_invalid_chunks_1
+s3tests/functional/test_s3.py::test_sse_kms_multipart_invalid_chunks_2
+s3tests/functional/test_s3.py::test_sse_kms_present
+s3tests/functional/test_s3.py::test_sse_kms_transfer_13b
+s3tests/functional/test_s3.py::test_sse_kms_transfer_1MB
+s3tests/functional/test_s3.py::test_sse_kms_transfer_1b
+s3tests/functional/test_s3.py::test_sse_kms_transfer_1kb
diff --git a/cmd/serve/s3/s3tests/rclone_shim.py b/cmd/serve/s3/s3tests/rclone_shim.py
new file mode 100644
index 000000000..cf26a0796
--- /dev/null
+++ b/cmd/serve/s3/s3tests/rclone_shim.py
@@ -0,0 +1,66 @@
+"""pytest plugin adapting the s3-tests fixtures to rclone serve s3.
+
+It only changes how the tests clean up after themselves, never what
+they test.
+"""
+from botocore.exceptions import ClientError
+import s3tests.functional as f
+
+_list_versions = f.list_versions
+_nuke_bucket = f.nuke_bucket
+
+
+def list_versions(client, bucket, batch_size):
+ """List objects to delete, falling back to ListObjectsV2 if
+ ListObjectVersions isn't implemented."""
+ try:
+ yield from _list_versions(client, bucket, batch_size)
+ return
+ except ClientError as e:
+ if e.response['Error']['Code'] != 'NotImplemented':
+ raise
+ paginator = client.get_paginator('list_objects_v2')
+ for page in paginator.paginate(Bucket=bucket, PaginationConfig={'PageSize': batch_size}):
+ objs = page.get('Contents', [])
+ if objs:
+ yield [{'Key': o['Key']} for o in objs]
+
+
+def nuke_bucket(client, bucket):
+ """Delete bucket after aborting its incomplete multipart uploads,
+ which the s3-tests cleanup leaves behind."""
+ try:
+ for page in client.get_paginator('list_multipart_uploads').paginate(Bucket=bucket):
+ for u in page.get('Uploads', []):
+ client.abort_multipart_upload(Bucket=bucket, Key=u['Key'], UploadId=u['UploadId'])
+ except ClientError:
+ pass
+ _nuke_bucket(client, bucket)
+
+
+# Buckets which couldn't be deleted. Each fails the teardown of the
+# test which left it, once; later tests skip it rather than every one
+# of them erroring in setup.
+_stuck = set()
+
+
+def nuke_prefixed_buckets(prefix, client=None):
+ """Delete all the buckets starting with prefix."""
+ if client is None:
+ client = f.get_client()
+ err = None
+ for name in f.get_buckets_list(client, prefix):
+ if name in _stuck:
+ continue
+ try:
+ nuke_bucket(client, name)
+ except Exception as e:
+ _stuck.add(name)
+ err = e
+ if err:
+ raise err
+
+
+f.list_versions = list_versions
+f.nuke_bucket = nuke_bucket
+f.nuke_prefixed_buckets = nuke_prefixed_buckets
diff --git a/cmd/serve/s3/s3tests/report.py b/cmd/serve/s3/s3tests/report.py
new file mode 100755
index 000000000..0ea65c773
--- /dev/null
+++ b/cmd/serve/s3/s3tests/report.py
@@ -0,0 +1,146 @@
+#!/usr/bin/env python3
+"""Summarise an s3-tests JUnit XML result and check it against the
+list of tests expected to pass.
+
+usage: report.py [--update] [--s3tests DIR] junit.xml expected-pass.txt
+
+Exits 1 if any test in expected-pass.txt which was run didn't pass.
+With --update, rewrites expected-pass.txt with the tests which passed
+(keeping expected tests which weren't run).
+"""
+import argparse
+import ast
+import collections
+import os
+import re
+import sys
+import xml.etree.ElementTree as ET
+
+# Feature areas, matched in order against the test name and its pytest
+# markers. The first match wins.
+FEATURES = [
+ ('object_lock', ['object_lock', 'retention', 'legal_hold']),
+ ('versioning', ['versioning', 'version', 'delete_marker']),
+ ('lifecycle', ['lifecycle', 'transition', 'restore', 'read_through']),
+ ('logging', ['bucket_logging']),
+ ('encryption', ['encryption', 'sse', 'encrypted']),
+ ('policy', ['bucket_policy', 'policy']),
+ ('acl/ownership', ['acl', 'grant', 'ownership', 'access_bucket', 'public']),
+ ('tagging', ['tagging', 'tags']),
+ ('cors', ['cors']),
+ ('post_object', ['post_object']),
+ ('checksum', ['checksum']),
+ ('conditional', ['conditional_write', 'if_match', 'if_none_match', 'ifmatch',
+ 'ifnonematch', 'if_modified', 'ifmodified', 'unmodified']),
+ ('multipart', ['multipart']),
+ ('copy', ['copy']),
+ ('list', ['list', 'delimiter', 'prefix', 'marker', 'max_keys', 'maxkeys',
+ 'continuationtoken', 'startafter', 'fetchowner', 'encoding']),
+ ('auth/headers', ['auth', 'contentlength', 'content_length', 'md5', 'expect',
+ 'date', 'header', 'anonymous', 'presigned', 'cookie']),
+ ('bucket', ['bucket_create', 'bucket_name', 'bucket_head', 'bucket_delete',
+ 'buckets_create', 'bucket_list_long_name']),
+ ('range', ['range']),
+ ('metadata', ['metadata']),
+]
+
+
+def load_markers(s3tests):
+ """Return {test name: set of pytest markers} from the s3-tests source."""
+ markers = {}
+ d = os.path.join(s3tests, 's3tests', 'functional')
+ for fn in ('test_s3.py', 'test_headers.py'):
+ try:
+ tree = ast.parse(open(os.path.join(d, fn)).read())
+ except OSError:
+ continue
+ for n in tree.body:
+ if isinstance(n, ast.FunctionDef) and n.name.startswith('test_'):
+ markers[n.name] = {m.group(1) for m in
+ (re.match(r'pytest\.mark\.(\w+)', ast.unparse(dec))
+ for dec in n.decorator_list) if m}
+ return markers
+
+
+def feature(name, markers):
+ """Return the feature area of test name."""
+ marks = markers.get(name.split('[')[0], set())
+ for area, pats in FEATURES:
+ if any(p in name or p in marks for p in pats):
+ return area
+ return 'other'
+
+
+def load_results(path):
+ """Return {test id: (status, message)} from a JUnit XML file."""
+ results = {}
+ for tc in ET.parse(path).iter('testcase'):
+ tid = tc.get('classname').replace('.', '/') + '.py::' + tc.get('name')
+ status, msg = 'pass', ''
+ for c in tc:
+ if c.tag in ('failure', 'error'):
+ status = 'fail'
+ msg = msg or c.get('message') or ''
+ elif c.tag == 'skipped' and status == 'pass':
+ status = 'skip'
+ results[tid] = (status, re.sub(r'\s+', ' ', msg))
+ return results
+
+
+def main():
+ p = argparse.ArgumentParser()
+ p.add_argument('--update', action='store_true')
+ p.add_argument('--s3tests', default='')
+ p.add_argument('junit')
+ p.add_argument('expected')
+ args = p.parse_args()
+
+ results = load_results(args.junit)
+ markers = load_markers(args.s3tests) if args.s3tests else {}
+
+ table = collections.defaultdict(collections.Counter)
+ reasons = collections.Counter()
+ for tid, (status, msg) in results.items():
+ table[feature(tid.split('::')[1], markers)][status] += 1
+ if status == 'fail':
+ reasons[re.sub(r'rclone-[a-z0-9]+-\d+', 'BUCKET', msg)[:110]] += 1
+ total = collections.Counter()
+ print(f"{'feature':16s} {'pass':>5s} {'fail':>5s} {'skip':>5s}")
+ for area, c in sorted(table.items(), key=lambda kv: -sum(kv[1].values())):
+ print(f"{area:16s} {c['pass']:5d} {c['fail']:5d} {c['skip']:5d}")
+ total.update(c)
+ print(f"{'TOTAL':16s} {total['pass']:5d} {total['fail']:5d} {total['skip']:5d}")
+ print("\nCommonest failures:")
+ for msg, n in reasons.most_common(15):
+ print(f"{n:5d} {msg}")
+
+ try:
+ with open(args.expected) as fh:
+ expected = {l.strip() for l in fh if l.strip() and not l.startswith('#')}
+ except FileNotFoundError:
+ expected = set()
+ passed = {t for t, (s, _) in results.items() if s == 'pass'}
+ regressions = sorted(t for t in expected if t in results and t not in passed)
+ new = sorted(passed - expected)
+
+ if new:
+ print(f"\n{len(new)} tests pass which aren't in {os.path.basename(args.expected)}:")
+ for t in new:
+ print(" " + t)
+ if regressions:
+ print(f"\n{len(regressions)} REGRESSIONS - expected to pass but didn't:")
+ for t in regressions:
+ print(f" {t}: {results[t][1][:150]}")
+
+ if args.update:
+ keep = (expected - set(results)) | passed
+ with open(args.expected, 'w') as fh:
+ fh.write("# Tests expected to pass - maintained by run.sh --update\n")
+ fh.writelines(t + "\n" for t in sorted(keep))
+ print(f"\nWrote {len(keep)} tests to {args.expected}")
+ return 0
+ return 1 if regressions else 0
+
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/cmd/serve/s3/s3tests/requirements.txt b/cmd/serve/s3/s3tests/requirements.txt
new file mode 100644
index 000000000..27a8aba66
--- /dev/null
+++ b/cmd/serve/s3/s3tests/requirements.txt
@@ -0,0 +1,14 @@
+# Pinned Python dependencies for ceph/s3-tests. boto3 changes its
+# defaults (e.g. checksums) between releases, so bump these deliberately.
+boto3==1.43.114
+botocore==1.43.114
+gevent==26.9.0
+httplib2==0.32.0
+isodate==0.7.2
+lxml==6.1.3
+munch==4.0.0
+pytest==9.1.1
+pytest-timeout==2.4.0
+pytz==2026.5
+PyYAML==6.0.3
+requests==2.34.2
diff --git a/cmd/serve/s3/s3tests/run.sh b/cmd/serve/s3/s3tests/run.sh
new file mode 100755
index 000000000..4a7c46e03
--- /dev/null
+++ b/cmd/serve/s3/s3tests/run.sh
@@ -0,0 +1,113 @@
+#!/usr/bin/env bash
+# Run the ceph/s3-tests S3 compatibility suite against rclone serve s3.
+#
+# usage: run.sh [--update] [pytest args...]
+#
+# With no pytest args, runs the whole of test_s3.py and test_headers.py.
+# Pass test ids (e.g. s3tests/functional/test_s3.py::test_bucket_list_empty)
+# or pytest options (e.g. -k multipart) to run a subset.
+#
+# --update rewrites expected-pass.txt with the tests which passed.
+#
+# Environment variables:
+# RCLONE rclone binary to test (default: build from this tree)
+# RCLONE_REMOTE remote to serve (default: a temporary local directory)
+# RCLONE_ARGS extra flags for rclone serve s3
+# S3TESTS_CACHE where s3-tests and its venv are kept
+# (default: ~/.cache/rclone-s3tests)
+# S3TESTS_OUT where results are written (default: a temporary directory)
+# S3TESTS_TIMEOUT per test timeout in seconds (default: 120)
+
+set -euo pipefail
+
+# ceph/s3-tests was frozen here when the suite moved into ceph/ceph
+# (src/test/rgw/s3-tests).
+S3TESTS_REPO=https://github.com/ceph/s3-tests
+S3TESTS_COMMIT=5b3987116eca0b4b8fa57d6b10f3db57bab196b6
+
+HERE=$(cd "$(dirname "$0")" && pwd)
+TOP=$(cd "$HERE/../../../.." && pwd)
+
+UPDATE=""
+if [ "${1:-}" = "--update" ]; then
+ UPDATE="--update"
+ shift
+fi
+if [ $# -eq 0 ]; then
+ set -- s3tests/functional/test_s3.py s3tests/functional/test_headers.py
+fi
+
+CACHE=${S3TESTS_CACHE:-$HOME/.cache/rclone-s3tests}
+OUT=${S3TESTS_OUT:-$(mktemp -d -t rclone-s3tests.XXXXXX)}
+mkdir -p "$CACHE" "$OUT"
+
+# Fetch s3-tests at the pinned commit
+SRC=$CACHE/s3-tests-$S3TESTS_COMMIT
+if [ ! -d "$SRC" ]; then
+ echo "Fetching s3-tests $S3TESTS_COMMIT"
+ git init -q "$SRC.tmp"
+ git -C "$SRC.tmp" fetch -q --depth 1 "$S3TESTS_REPO" "$S3TESTS_COMMIT"
+ git -C "$SRC.tmp" checkout -q FETCH_HEAD
+ mv "$SRC.tmp" "$SRC"
+fi
+
+# Make a venv for the pinned requirements
+VENV=$CACHE/venv-$(sha256sum "$HERE/requirements.txt" | cut -c1-12)
+if [ ! -x "$VENV/bin/python" ]; then
+ echo "Creating venv $VENV"
+ python3 -m venv "$VENV.tmp"
+ "$VENV.tmp/bin/pip" install -q -r "$HERE/requirements.txt"
+ mv "$VENV.tmp" "$VENV"
+fi
+
+if [ -z "${RCLONE:-}" ]; then
+ echo "Building rclone"
+ RCLONE=$OUT/rclone
+ (cd "$TOP" && go build -o "$RCLONE" .)
+fi
+
+REMOTE=${RCLONE_REMOTE:-$OUT/data}
+if [ -z "${RCLONE_REMOTE:-}" ]; then
+ rm -rf "$REMOTE"
+ mkdir -p "$REMOTE"
+fi
+
+# The keys must match s3tests.conf.in
+# shellcheck disable=SC2086
+"$RCLONE" --config /notfound serve s3 --addr 127.0.0.1:0 \
+ --auth-key '0555b35654ad1656d804,h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q==' \
+ --auth-key 'NOPQRSTUVWXYZABCDEFG,nopqrstuvwxyzabcdefghijklmnabcdefghijklm' \
+ --auth-key 'HIJKLMNOPQRSTUVWXYZA,opqrstuvwxyzabcdefghijklmnopqrstuvwxyzab' \
+ ${RCLONE_ARGS:-} "$REMOTE" > "$OUT/rclone.log" 2>&1 &
+RCLONE_PID=$!
+trap 'kill $RCLONE_PID 2>/dev/null || true' EXIT
+
+PORT=""
+for _ in $(seq 100); do
+ PORT=$(sed -n 's/.*Starting s3 server on \[http:\/\/127\.0\.0\.1:\([0-9]*\)\/\].*/\1/p' "$OUT/rclone.log")
+ [ -n "$PORT" ] && break
+ if ! kill -0 $RCLONE_PID 2>/dev/null; then
+ cat "$OUT/rclone.log"
+ echo "rclone serve s3 failed to start"
+ exit 1
+ fi
+ sleep 0.1
+done
+if [ -z "$PORT" ]; then
+ echo "Timed out waiting for rclone serve s3 to start"
+ exit 1
+fi
+sed "s/@PORT@/$PORT/" "$HERE/s3tests.conf.in" > "$OUT/s3tests.conf"
+
+echo "Running s3-tests against rclone serve s3 on port $PORT - results in $OUT"
+cd "$SRC"
+set +e
+PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=$HERE S3TEST_CONF=$OUT/s3tests.conf "$VENV/bin/python" -m pytest \
+ -p no:cacheprovider -p rclone_shim \
+ --timeout="${S3TESTS_TIMEOUT:-120}" -v -rfE \
+ --junitxml="$OUT/junit.xml" "$@" > "$OUT/pytest.log" 2>&1
+set -e
+tail -1 "$OUT/pytest.log"
+
+"$VENV/bin/python" "$HERE/report.py" $UPDATE --s3tests "$SRC" \
+ "$OUT/junit.xml" "$HERE/expected-pass.txt" | tee "$OUT/report.txt"
diff --git a/cmd/serve/s3/s3tests/s3tests.conf.in b/cmd/serve/s3/s3tests/s3tests.conf.in
new file mode 100644
index 000000000..58ea829df
--- /dev/null
+++ b/cmd/serve/s3/s3tests/s3tests.conf.in
@@ -0,0 +1,58 @@
+# s3-tests configuration for rclone serve s3. run.sh fills in @PORT@.
+#
+# The access keys here must match the --auth-key flags in run.sh.
+
+[DEFAULT]
+host = 127.0.0.1
+port = @PORT@
+is_secure = False
+ssl_verify = False
+
+[fixtures]
+bucket prefix = rclone-{random}-
+iam name prefix = s3-tests-
+iam path prefix = /s3-tests/
+
+[s3 main]
+display_name = M. Tester
+user_id = testid
+api_name = default
+access_key = 0555b35654ad1656d804
+secret_key = h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q==
+
+[s3 alt]
+display_name = john.doe
+user_id = 56789abcdef0123456789abcdef0123456789abcdef0123456789abcdef01234
+access_key = NOPQRSTUVWXYZABCDEFG
+secret_key = nopqrstuvwxyzabcdefghijklmnabcdefghijklm
+
+[s3 tenant]
+display_name = testx$tenanteduser
+user_id = testx$9876543210abcdef0123456789abcdef0123456789abcdef0123456789abcdef
+access_key = HIJKLMNOPQRSTUVWXYZA
+secret_key = opqrstuvwxyzabcdefghijklmnopqrstuvwxyzab
+tenant = testx
+
+[iam]
+user_id = 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
+access_key = ABCDEFGHIJKLMNOPQRST
+secret_key = abcdefghijklmnopqrstuvwxyzabcdefghijklmn
+display_name = youruseridhere
+
+[iam root]
+access_key = AAAAAAAAAAAAAAAAAAaa
+secret_key = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+account_id = RGW11111111111111111
+user_id = RGW11111111111111111
+
+[iam alt root]
+access_key = BBBBBBBBBBBBBBBBBBbb
+secret_key = bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+account_id = RGW22222222222222222
+user_id = RGW22222222222222222