From a445bc04644be982c772276ffac70ff860f030d4 Mon Sep 17 00:00:00 2001 From: loverustfs Date: Sat, 28 Nov 2026 22:04:46 +0800 Subject: [PATCH 1/8] Enforce S3, IAM, replication and release validation assertions --- .../rustfs-fault-tolerance-matrix.yml | 8 +- .../rustfs-validation-heal-sweep.yml | 58 ++-- rustfs-replication-test.sh | 77 ++++-- rustfs-s3-compat-test.sh | 247 +++++++++++------- rustfs-security-test.sh | 125 ++++++--- test_rustfs_replication.py | 22 ++ test_rustfs_s3_regressions.py | 20 ++ test_rustfs_security.py | 63 ++++- 8 files changed, 421 insertions(+), 199 deletions(-) diff --git a/.github/workflows/rustfs-fault-tolerance-matrix.yml b/.github/workflows/rustfs-fault-tolerance-matrix.yml index 3e2af002..746da39e 100644 --- a/.github/workflows/rustfs-fault-tolerance-matrix.yml +++ b/.github/workflows/rustfs-fault-tolerance-matrix.yml @@ -125,15 +125,13 @@ jobs: - name: Run matrix sweep (topology x EC outage combinations) timeout-minutes: 350 id: test - # No continue-on-error: an UNEXPECTED verdict (a probe that should - # fail by quorum math but passes, or vice versa) is the finding this - # sweep exists to surface, and the red run is the signal until matrix - # runs get backlog integration like the scenario suite has. + # Gate on every probe matching the quorum model, including known + # divergences. The report below still retains every verdict. env: MATRIX_EC: ${{ inputs.matrix_ec }} run: | set -euo pipefail - ARGS=(--matrix -y --package-url "${{ inputs.package_url || env.RUSTFS_NIGHTLY_PACKAGE_URL }}" --log-file "${LOG_FILE}" --results-file "${RESULTS_FILE}") + ARGS=(--matrix --strict -y --package-url "${{ inputs.package_url || env.RUSTFS_NIGHTLY_PACKAGE_URL }}" --log-file "${LOG_FILE}" --results-file "${RESULTS_FILE}") if [ -n "${{ inputs.matrix_topo }}" ]; then # Trailing value form: consumed as `--matrix-topo [ec]`. ARGS+=(--matrix-topo "${{ inputs.matrix_topo }}") diff --git a/.github/workflows/rustfs-validation-heal-sweep.yml b/.github/workflows/rustfs-validation-heal-sweep.yml index 80dba8c6..0ef685ca 100644 --- a/.github/workflows/rustfs-validation-heal-sweep.yml +++ b/.github/workflows/rustfs-validation-heal-sweep.yml @@ -361,29 +361,23 @@ jobs: "${AUTO_TESTING_SHA}" "${HEAL_ROOT}/run" \ < /dev/null \ > "${HEAL_ROOT}/results/${CASE_ID//\//_}.log" 2>&1 || rc=$? - # The case verdict is authoritative from the result JSON: drivers - # may self-report BLOCKED (diagnostic gates) with a nonzero exit; - # only FAIL / INFRA_ERROR / TIMEOUT keep the sweep red. - # Terminal verdict lives at run//cases/.json - # (run_validation_case.sh passes --validation-artifacts-dir - # run/; the heal runner appends cases/.json). + # Keep the runner's terminal receipt even when the runner fails. VERDICT="" RESULT_JSON="${HEAL_ROOT}/run/${CASE_ID}/cases/${CASE_ID}.json" if [ -f "${RESULT_JSON}" ]; then - VERDICT="$(jq -r '.verdict // empty' "${RESULT_JSON}" 2>/dev/null || true)" + VERDICT="$(jq -er --arg case_id "${CASE_ID}" ' + select(.schema_version == 1 and .case_id == $case_id) + | .verdict | strings + ' "${RESULT_JSON}" 2>/dev/null || true)" cp "${RESULT_JSON}" "${HEAL_ROOT}/results/${CASE_ID//\//_}.result.json" 2>/dev/null || true fi - # The terminal verdict is authoritative when present; otherwise - # trust the runner exit code (rc=0 with no verdict was recorded - # as FAIL before this fix — smoke run 41748362310). - STATUS="FAIL" - if [ "${VERDICT}" = "PASS" ] || { [ -z "${VERDICT}" ] && [ "${rc}" -eq 0 ]; }; then - STATUS="PASS" - elif [ "${VERDICT}" = "BLOCKED" ]; then - STATUS="BLOCKED" - elif [ "${rc}" -eq 124 ]; then - STATUS="TIMEOUT" - fi + case "${rc}:${VERDICT}" in + 124:*) STATUS=TIMEOUT ;; + 0:PASS) STATUS=PASS ;; + *:BLOCKED) STATUS=BLOCKED ;; + *:FAIL) STATUS=FAIL ;; + *) STATUS=INFRA_ERROR ;; + esac printf '%s\t%s\n' "${CASE_ID}" "${STATUS}" >> "${HEAL_ROOT}/results.txt" echo "case ${CASE_ID}: ${STATUS} (rc=${rc} verdict=${VERDICT:-none})" if [ -f "${HEAL_ROOT}/run/report.md" ]; then @@ -428,6 +422,10 @@ jobs: rows.append((case_id, module_of.get(case_id, "heal"), status)) passed = sum(1 for _, _, s in rows if s == "PASS") failed = sum(1 for _, _, s in rows if s == "FAIL") + infra_errors = sum(1 for _, _, s in rows if s == "INFRA_ERROR") + selected = (root / "heal-cases.txt").read_text().split() + reported = {case_id for case_id, _, _ in rows} + missing = [case_id for case_id in selected if case_id not in reported] timed_out = sum(1 for _, _, s in rows if s == "TIMEOUT") blocked = (root / "blocked-cases.txt").read_text().split() pinned = (root / "pinned-cases.txt").read_text().split() @@ -470,14 +468,19 @@ jobs: report += [f"- {c}: BLOCKED" for c in pinned] report += [ "", "## Totals", "", - f"- Total: {len(rows)}", + f"- Selected: {len(selected)}", + f"- Reported: {len(rows)}", + f"- Missing: {len(missing)}", f"- PASS: {passed}", f"- FAIL: {failed}", + f"- INFRA_ERROR: {infra_errors}", f"- TIMEOUT: {timed_out}", - f"- BLOCKED: {len(blocked) + len(pinned) + sum(1 for _, _, s in rows if s == 'BLOCKED')}", "", - "Failing cases keep this workflow red only as a report; the sweep artifact", - "retains every case log and per-case report for diagnosis.", "", + f"- BLOCKED among selected: {sum(1 for _, _, s in rows if s == 'BLOCKED')}", + f"- BLOCKED before selection: {len(blocked) + len(pinned)}", "", + "Every selected case must pass. The sweep artifact retains case logs and per-case reports.", "", ] + if missing: + report += ["## Missing case results", "", *[f"- {c}" for c in missing], ""] (root / "report.md").write_text("\n".join(report)) (root / "cases.md").write_text("\n".join(f"| {c} | {m} | {s} |" for c, m, s in rows) + "\n") PY @@ -567,8 +570,9 @@ jobs: HEAL_ROOT: ${{ runner.temp }}/validation-heal run: | set -euo pipefail - if grep -qE $'\t(FAIL|TIMEOUT)$' "${HEAL_ROOT}/results.txt"; then - echo "validation heal sweep has failing or timed-out cases:" - grep -E $'\t(FAIL|TIMEOUT)$' "${HEAL_ROOT}/results.txt" - exit 1 - fi + test -s "${HEAL_ROOT}/heal-cases.txt" + cut -f1 "${HEAL_ROOT}/results.txt" | diff -u "${HEAL_ROOT}/heal-cases.txt" - + awk -F '\t' ' + NF != 2 || $2 != "PASS" { print "selected heal case did not pass: " $0; invalid = 1 } + END { exit invalid } + ' "${HEAL_ROOT}/results.txt" diff --git a/rustfs-replication-test.sh b/rustfs-replication-test.sh index c76aedd1..07828da8 100755 --- a/rustfs-replication-test.sh +++ b/rustfs-replication-test.sh @@ -387,7 +387,7 @@ env_setup_main_cluster() { env_setup_site2() { local node="${NODES[0]}" - log "environment setup: second site ${SITE2_SERVICE} on ${node} (${SITE2_ENDPOINT})" + log "environment setup: second deployment ${SITE2_SERVICE} shares host ${node} (${SITE2_ENDPOINT})" ensure_volume_dirs "${node}" "${SITE2_VOLUMES}" write_remote_config "${node}" "${SITE2_CONFIG_FILE}" "$(site2_config_body)" write_site2_unit "${node}" @@ -631,20 +631,36 @@ results_summary() { fi } -# aws_wait_ep — poll until the aws call succeeds. +# aws_wait_ep [--expect-true] aws_wait_ep() { local ep="$1" desc="$2"; shift 2 - local waited=0 - while [ "${waited}" -lt "${CONVERGE_TIMEOUT}" ]; do - if aws --endpoint-url "${ep}" --region "${REGION}" "$@" >/dev/null 2>&1; then - return 0 + local expect_true=0 output="" deadline=$((SECONDS + CONVERGE_TIMEOUT)) remaining + if [ "${1:-}" = "--expect-true" ]; then + expect_true=1 + shift + fi + while [ "${SECONDS}" -lt "${deadline}" ]; do + remaining=$((deadline - SECONDS)) + if output="$(AWS_MAX_ATTEMPTS=1 timeout "${remaining}s" aws --endpoint-url "${ep}" --region "${REGION}" "$@" 2>&1)"; then + if [ "${expect_true}" -eq 0 ] || [ "${output}" = "True" ] || [ "${output}" = "true" ]; then + return 0 + fi fi - sleep "${CONVERGE_INTERVAL}"; waited=$((waited+CONVERGE_INTERVAL)) + remaining=$((deadline - SECONDS)) + [ "${remaining}" -gt 0 ] || break + sleep "$((remaining < CONVERGE_INTERVAL ? remaining : CONVERGE_INTERVAL))" done - echo "timeout (${CONVERGE_TIMEOUT}s) waiting for: ${desc}" + echo "timeout (${CONVERGE_TIMEOUT}s) waiting for: ${desc}; last response: ${output:-none}" return 1 } +wait_for_delete_marker() { + local ep="$1" desc="$2" bucket="$3" key="$4" query + printf -v query 'length((DeleteMarkers || `[]`)[?Key == `%s` && IsLatest == `true`]) == `1`' "$(jq -cn --arg key "${key}" '$key')" + aws_wait_ep "${ep}" "${desc}" --expect-true \ + s3api list-object-versions --bucket "${bucket}" --prefix "${key}" --query "${query}" --output text +} + # ==================== Bucket/object helpers ==================== new_versioned_bucket() { @@ -880,9 +896,7 @@ test_rep105() { aws_run s3api delete-object --bucket "rep105-src" --key m.txt assert_aws_ok "delete-object m.txt" \ || { rm_bucket_force main rep105-src; rm_bucket_force site2 rep105-dst; return 1; } - aws_wait_ep "${SITE2_ENDPOINT}" "delete marker replicated" \ - s3api list-object-versions --bucket rep105-dst --prefix m.txt --output json \ - --query 'length(DeleteMarkers || `[]`) > `0`' --output text \ + wait_for_delete_marker "${SITE2_ENDPOINT}" "delete marker replicated" rep105-dst m.txt \ || { rm_bucket_force main rep105-src; rm_bucket_force site2 rep105-dst; return 1; } rm_bucket_force main rep105-src rm_bucket_force site2 rep105-dst @@ -989,9 +1003,7 @@ test_rep110() { || { rm_bucket_force main rep110-src; rm_bucket_force site2 rep110-dst; return 1; } # Wait for the delete marker to arrive, then assert the end state: HEAD # must 404 and the listing must be empty. - aws_wait_ep "${SITE2_ENDPOINT}" "delete marker on target" \ - s3api list-object-versions --bucket rep110-dst --prefix gone.txt \ - --query 'length(DeleteMarkers || `[]`) > `0`' --output text \ + wait_for_delete_marker "${SITE2_ENDPOINT}" "delete marker on target" rep110-dst gone.txt \ || { rm_bucket_force main rep110-src; rm_bucket_force site2 rep110-dst; return 1; } local deadline=$(( $(date +%s) + 120 )) gone=0 while [ "$(date +%s)" -lt "${deadline}" ]; do @@ -1072,6 +1084,7 @@ run_all_site_tests() { test_site101() { local body + [ "${API_ENDPOINT%/}" != "${SITE2_ENDPOINT%/}" ] || { echo "site replication requires different endpoints"; return 1; } # The add request must reach a node directly (not the LB): the server # derives the local site's endpoint from the request Host header, and with # the LB host it no longer matches the payload's site1 endpoint — the local @@ -1085,20 +1098,19 @@ test_site101() { || { echo "site add not successful: ${body}"; return 1; } body="$(admin_api GET "/rustfs/admin/v3/site-replication/info")" [ "$(signed_code)" = "200" ] || { echo "site-replication/info HTTP $(signed_code): ${body}"; return 1; } - printf '%s' "${body}" | jq -e '.enabled == true and (.sites | length == 2)' >/dev/null 2>&1 \ - || { echo "site info does not show 2 enabled sites: ${body}"; return 1; } + printf '%s' "${body}" | jq -e '.enabled == true and ([.sites[].deploymentID | strings | select(length > 0)] | length == 2 and (unique | length == 2))' >/dev/null 2>&1 \ + || { echo "site info does not show 2 distinct enabled deployments: ${body}"; return 1; } # The peer entry must be visible from site2 as well. body="$(site2_admin_api GET "/rustfs/admin/v3/site-replication/info")" [ "$(signed_code)" = "200" ] || { echo "site2 info HTTP $(signed_code): ${body}"; return 1; } - printf '%s' "${body}" | jq -e '.enabled == true and (.sites | length == 2)' >/dev/null 2>&1 \ - || { echo "site2 does not show 2 enabled sites: ${body}"; return 1; } + printf '%s' "${body}" | jq -e '.enabled == true and ([.sites[].deploymentID | strings | select(length > 0)] | length == 2 and (unique | length == 2))' >/dev/null 2>&1 \ + || { echo "site2 does not show 2 distinct enabled deployments: ${body}"; return 1; } } # admin_wait_user — poll the admin # list-users endpoint until the user is present. RustFS does not serve the # AWS IAM query protocol (`aws iam ...` fails with "unknown service 'iam' in -# credential scope"), and `aws_wait_ep` only inspects the exit status, so the -# previous `iam list-users --query` probe could never observe convergence. +# credential scope"), so use the admin API to observe convergence. admin_wait_user() { local api_fn="$1" desc="$2" user="$3" local waited=0 body @@ -1147,7 +1159,7 @@ test_site104() { local policy='{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"AWS":["*"]},"Action":["s3:GetObject"],"Resource":["arn:aws:s3:::site104-b1/*"]}]}' aws_run s3api put-bucket-policy --bucket site104-b1 --policy "${policy}" assert_aws_ok "put-bucket-policy" || { rm_bucket_force main site104-b1; return 1; } - aws_wait_ep "${SITE2_ENDPOINT}" "bucket policy on site2" \ + aws_wait_ep "${SITE2_ENDPOINT}" "bucket policy on site2" --expect-true \ s3api get-bucket-policy --bucket site104-b1 --query 'length(Policy) > `0`' --output text \ || { rm_bucket_force main site104-b1; return 1; } rm_bucket_force main site104-b1 @@ -1184,11 +1196,11 @@ test_site105() { aws_run s3api delete-object --bucket site105-b1 --key gone.txt assert_aws_ok "delete-object gone.txt" || { rm_bucket_force main site105-b1; return 1; } aws_wait_ep "${SITE2_ENDPOINT}" "live object on site2" \ - s3api head-object --bucket site105-b1 --key live.bin \ + s3api get-object --bucket site105-b1 --key live.bin "${TEST_TMP}/site105-download" \ || { rm_bucket_force main site105-b1; return 1; } - aws_wait_ep "${SITE2_ENDPOINT}" "delete marker on site2" \ - s3api list-object-versions --bucket site105-b1 --prefix gone.txt --output json \ - --query 'length(DeleteMarkers || `[]`) > `0`' --output text \ + cmp "${TEST_TMP}/site105-live" "${TEST_TMP}/site105-download" \ + || { rm_bucket_force main site105-b1; return 1; } + wait_for_delete_marker "${SITE2_ENDPOINT}" "delete marker on site2" site105-b1 gone.txt \ || { rm_bucket_force main site105-b1; return 1; } body="$(admin_api PUT "/rustfs/admin/v3/site-replication/resync/op" "operation=start" "${peer}")" @@ -1213,9 +1225,18 @@ test_site105() { body="$(admin_api PUT "/rustfs/admin/v3/site-replication/resync/op" "operation=status" "${peer}")" [ "$(signed_code)" = "200" ] || { echo "resync status HTTP $(signed_code): ${body}"; rm_bucket_force main site105-b1; return 1; } done + printf '%s' "${entry}" | jq -e ' + (.status == "completed" or .status == "success") and + ((.failedObjects // 0) == 0) and (.errorDetail // "" | length == 0) and + (.replicatedObjects | type == "number" and . >= 2) + ' >/dev/null 2>&1 \ + || { echo "resync of site105-b1 did not complete cleanly: ${entry}"; rm_bucket_force main site105-b1; return 1; } + aws_run_site2 s3api get-object --bucket site105-b1 --key live.bin "${TEST_TMP}/site105-after-resync" + assert_aws_ok "live object after resync" \ + && cmp "${TEST_TMP}/site105-live" "${TEST_TMP}/site105-after-resync" \ + && wait_for_delete_marker "${SITE2_ENDPOINT}" "delete marker after resync" site105-b1 gone.txt \ + || { rm_bucket_force main site105-b1; return 1; } rm_bucket_force main site105-b1 - printf '%s' "${entry}" | jq -e '(.status == "completed" or .status == "success") and ((.failedObjects // 0) == 0) and ((.replicatedObjects // 0) >= 2)' >/dev/null 2>&1 \ - || { echo "resync of site105-b1 did not complete cleanly: ${entry}"; return 1; } } test_site106() { @@ -1326,6 +1347,8 @@ main() { need_cmd aws "AWS CLI (S3 + admin channels)" need_cmd jq "JSON processor" need_cmd curl "HTTP client" + need_cmd cmp "byte comparison" + need_cmd timeout "bounded convergence requests" need_cmd openssl "OpenSSL (SigV4 signing)" confirm "This DESTROYS existing rustfs data/config on: ${NODES[*]}" log "nodes: ${NODES[*]} package: $(resolve_package_url) suites: ${SELECTED_SUITES[*]}" diff --git a/rustfs-s3-compat-test.sh b/rustfs-s3-compat-test.sh index 4fe264a7..3b43b69c 100755 --- a/rustfs-s3-compat-test.sh +++ b/rustfs-s3-compat-test.sh @@ -666,7 +666,27 @@ raise SystemExit(subprocess.call(command)) PY_SIGN } -md5_of_file() { md5sum "$1" 2>/dev/null | awk '{print $1}'; } +md5_of_file() { + python3 - "$1" <<'PY_MD5' +import hashlib +import sys + +digest = hashlib.md5() +with open(sys.argv[1], "rb") as stream: + for block in iter(lambda: stream.read(1024 * 1024), b""): + digest.update(block) +print(digest.hexdigest()) +PY_MD5 +} + +utc_after() { + python3 - "$1" "$2" <<'PY_DATE' +from datetime import datetime, timedelta, timezone +import sys + +print((datetime.now(timezone.utc) + timedelta(hours=int(sys.argv[1]))).strftime(sys.argv[2])) +PY_DATE +} new_bucket() { local b="$1" @@ -730,7 +750,7 @@ test_s3c1401() { # COPY-directive CopyObject keeps source metadata, ignores requ aws_run s3api head-object --bucket "s3c1401-dst" --key f assert_aws_ok || return 1 printf '%s' "${AWS_OUT}" | jq -e \ - '.ContentType == "application/x-rustfs-src" and .Metadata.src == "1" and .Metadata.requestonly == null' >/dev/null \ + '.ContentType == "application/x-rustfs-src" and .Metadata.src == "1" and (.Metadata | has("request-only") | not)' >/dev/null \ || { echo "COPY did not preserve source metadata / drop request-only metadata: ${AWS_OUT}"; return 1; } rm_bucket "s3c1401-src"; rm_bucket "s3c1401-dst" } @@ -747,14 +767,14 @@ test_s3c1402() { # Content-Encoding: aws-chunked without decoded-content-length || { echo "wrong stored size: ${AWS_OUT}"; return 1; } aws_run s3api get-object --bucket "s3c1402-b" --key f "${TEST_TMP}/s3c1402-dl" assert_aws_ok || return 1 - [ "$(md5_of_file "${TEST_TMP}/s3c1402-dl")" = "$(md5_of_file "${TEST_TMP}/s3c1402")" ] \ + cmp -s "${TEST_TMP}/s3c1402-dl" "${TEST_TMP}/s3c1402" \ || { echo "content mismatch"; return 1; } rm_bucket "s3c1402-b" } test_s3c1403() { # concurrent UploadPart must not fail while write quorum is met (regressions #6133 #6350) local bucket="s3c1403-b" parts=32 psize=5242880 up_id i rc=0 - local pids expected_md5 actual_md5 + local pids new_bucket "${bucket}" || return 1 aws_run s3api create-multipart-upload --bucket "${bucket}" --key big assert_aws_ok || return 1 @@ -792,9 +812,11 @@ test_s3c1403() { # concurrent UploadPart must not fail while write quorum is met || { echo "wrong object size: ${AWS_OUT}"; return 1; } aws_run s3api get-object --bucket "${bucket}" --key big "${TEST_TMP}/s3c1403-dl" assert_aws_ok || return 1 - expected_md5="$({ for ((i = 1; i <= parts; i++)); do cat "${TEST_TMP}/s3c1403-p${i}"; done; } | md5sum | awk '{print $1}')" - actual_md5="$(md5_of_file "${TEST_TMP}/s3c1403-dl")" - [ "${actual_md5}" = "${expected_md5}" ] || { echo "assembled content mismatch"; return 1; } + if ! { for ((i = 1; i <= parts; i++)); do cat "${TEST_TMP}/s3c1403-p${i}" || exit 1; done; } | + cmp -s - "${TEST_TMP}/s3c1403-dl"; then + echo "assembled content mismatch" + return 1 + fi rm_bucket "${bucket}" } @@ -1058,12 +1080,12 @@ run_all_tests() { # describe the same object rather than separate S3C-* fixtures. test_validation_s3_basic_object_round_trip() { local bucket="val-basic-${RANDOM}-$$" key="object" source="${TEST_TMP}/validation-basic-source" - local downloaded="${TEST_TMP}/validation-basic-downloaded" expected_sha expected_etag put_etag + local downloaded="${TEST_TMP}/validation-basic-downloaded" expected_etag put_etag local case_rc=0 cleanup_rc=0 VALIDATION_OBJECT_CLEANUP_STATUS=PASS make_test_file "${source}" 4096 - expected_sha="$(sha256sum "${source}" | awk '{print $1}')" - expected_etag="\"$(md5_of_file "${source}")\"" + expected_etag="$(md5_of_file "${source}")" || return 1 + expected_etag="\"${expected_etag}\"" new_bucket "${bucket}" || return 1 ( @@ -1083,7 +1105,7 @@ test_validation_s3_basic_object_round_trip() { aws_run s3api get-object --bucket "${bucket}" --key "${key}" "${downloaded}" assert_aws_ok || exit 1 - [ "$(sha256sum "${downloaded}" | awk '{print $1}')" = "${expected_sha}" ] \ + cmp -s "${source}" "${downloaded}" \ || { echo "GET payload mismatch"; exit 1; } aws_run s3api list-objects-v2 --bucket "${bucket}" @@ -1313,8 +1335,15 @@ test_s3c106() { echo "invalid bucket '${invalid}' returned HTTP ${code}, expected 400: $(head -c 200 "${TEST_TMP}/curl.out")" return 1 fi - printf '%s' "$(cat "${TEST_TMP}/curl.out")" | grep -q "InvalidBucketName" \ - || echo "note: invalid name '${invalid}' rejected with 400 but body lacks InvalidBucketName: $(head -c 200 "${TEST_TMP}/curl.out")" + python3 - "${TEST_TMP}/curl.out" <<'PY_ERROR' || return 1 +import sys +from xml.etree import ElementTree + +root = ElementTree.parse(sys.argv[1]).getroot() +code = root.findtext("{*}Code") +if root.tag.rsplit("}", 1)[-1] != "Error" or code != "InvalidBucketName": + raise SystemExit(f"Expected InvalidBucketName, received {code!r}") +PY_ERROR done } @@ -1322,17 +1351,17 @@ test_s3c106() { test_s3c201() { new_bucket "s3c201-b1" || return 1 - local f exp got + local size exp got for size in 1024 1048576 104857600; do make_test_file ${TEST_TMP}/s3c-file "${size}" - exp="$(md5_of_file ${TEST_TMP}/s3c-file)" + exp="$(md5_of_file "${TEST_TMP}/s3c-file")" || return 1 aws_run s3api put-object --bucket "s3c201-b1" --key "f-${size}" --body ${TEST_TMP}/s3c-file assert_aws_ok || return 1 got="$(printf '%s' "${AWS_OUT}" | jq -r '.ETag' | tr -d '"')" [ "${got}" = "${exp}" ] || { echo "ETag ${got} != MD5 ${exp} for size ${size}"; return 1; } aws_run s3api get-object --bucket "s3c201-b1" --key "f-${size}" ${TEST_TMP}/s3c-dl assert_aws_ok || return 1 - [ "$(md5_of_file ${TEST_TMP}/s3c-dl)" = "${exp}" ] || { echo "downloaded MD5 mismatch for size ${size}"; return 1; } + cmp -s "${TEST_TMP}/s3c-file" "${TEST_TMP}/s3c-dl" || { echo "downloaded MD5 mismatch for size ${size}"; return 1; } done rm_bucket "s3c201-b1" } @@ -1350,38 +1379,36 @@ test_s3c202() { || { echo "empty object not 0 bytes: ${AWS_OUT}"; return 1; } aws_run s3api get-object --bucket "s3c202-b1" --key empty ${TEST_TMP}/s3c-empty-dl assert_aws_ok || return 1 - [ ! -s ${TEST_TMP}/s3c-empty-dl ] || { echo "empty object downloaded non-empty"; return 1; } + [ -f "${TEST_TMP}/s3c-empty-dl" ] && [ ! -s "${TEST_TMP}/s3c-empty-dl" ] || { echo "empty object downloaded non-empty"; return 1; } rm_bucket "s3c202-b1" } test_s3c203() { new_bucket "s3c203-b1" || return 1 make_test_file ${TEST_TMP}/s3c-file 1048576 - local exp - exp="$(md5_of_file ${TEST_TMP}/s3c-file)" aws_run s3api put-object --bucket "s3c203-b1" --key f --body "${TEST_TMP}/s3c-file" --expires "Tue, 01 Jan 2030 00:00:00 GMT" assert_aws_ok || return 1 aws_run s3api get-object --bucket "s3c203-b1" --key f ${TEST_TMP}/s3c-dl assert_aws_ok || return 1 printf '%s' "${AWS_OUT}" | jq -e '.Expires == "2030-01-01T00:00:00+00:00" or .Expires == "Tue, 01 Jan 2030 00:00:00 GMT"' >/dev/null \ || { echo "get-object did not return the stored Expires header: ${AWS_OUT}"; return 1; } - [ "$(md5_of_file ${TEST_TMP}/s3c-dl)" = "${exp}" ] || { echo "get-object MD5 mismatch"; return 1; } + cmp -s "${TEST_TMP}/s3c-file" "${TEST_TMP}/s3c-dl" || { echo "get-object MD5 mismatch"; return 1; } rm_bucket "s3c203-b1" } test_s3c204() { new_bucket "s3c204-b1" || return 1 - make_test_file ${TEST_TMP}/s3c-file 2048 - aws_run s3api put-object --bucket "s3c204-b1" --key f --body ${TEST_TMP}/s3c-file - assert_aws_ok || return 1 - # range 0-99 -> 206, exactly 100 bytes - local code len - code="$(aws --endpoint-url "${ENDPOINT}" --region "${REGION}" s3api get-object \ - --bucket "s3c204-b1" --key f --range "bytes=0-99" ${TEST_TMP}/s3c-range 2>/dev/null; echo $?)" - len="$(wc -c < ${TEST_TMP}/s3c-range)" - [ "${len}" = "100" ] || { echo "range GET returned ${len} bytes, expected 100"; return 1; } - # out-of-range -> 416 - aws_run s3api get-object --bucket "s3c204-b1" --key f --range "bytes=99999-100000" ${TEST_TMP}/s3c-range2 + make_test_file "${TEST_TMP}/s3c-file" 2048 || return 1 + aws_run s3api put-object --bucket "s3c204-b1" --key f --body "${TEST_TMP}/s3c-file" + assert_aws_ok || return 1 + aws_run s3api get-object --bucket "s3c204-b1" --key f --range "bytes=0-99" "${TEST_TMP}/s3c-range" + assert_aws_ok || return 1 + jq -e '.ContentRange == "bytes 0-99/2048" and .ContentLength == 100' <<< "${AWS_OUT}" >/dev/null \ + || { echo "wrong range metadata: ${AWS_OUT}"; return 1; } + head -c 100 "${TEST_TMP}/s3c-file" > "${TEST_TMP}/s3c-range-expected" || return 1 + cmp -s "${TEST_TMP}/s3c-range-expected" "${TEST_TMP}/s3c-range" \ + || { echo "range GET payload differs from the requested source bytes"; return 1; } + aws_run s3api get-object --bucket "s3c204-b1" --key f --range "bytes=99999-100000" "${TEST_TMP}/s3c-range2" assert_aws_fails_with "InvalidRange" || return 1 rm_bucket "s3c204-b1" } @@ -1425,18 +1452,20 @@ test_s3c207() { test_s3c208() { new_bucket "s3c208-b1" || return 1 + printf 's3 fixture\n' > "${TEST_TMP}/object-fixture" || return 1 local i for i in $(seq 1 5); do - aws_run s3api put-object --bucket "s3c208-b1" --key "prefix/o${i}" --body /etc/hostname + aws_run s3api put-object --bucket "s3c208-b1" --key "prefix/o${i}" --body "${TEST_TMP}/object-fixture" assert_aws_ok || return 1 done aws_run s3api delete-objects --bucket "s3c208-b1" --delete '{"Objects":[{"Key":"prefix/o1"},{"Key":"prefix/o2"},{"Key":"prefix/o3"}]}' assert_aws_ok || return 1 - printf '%s' "${AWS_OUT}" | jq -e '[.Deleted[]?] | length == 3' >/dev/null \ - || { echo "batch delete did not report 3 keys: ${AWS_OUT}"; return 1; } + printf '%s' "${AWS_OUT}" | jq -e '([.Deleted[]?.Key] | sort) == ["prefix/o1","prefix/o2","prefix/o3"] and ((.Errors // []) | length == 0)' >/dev/null \ + || { echo "batch delete did not acknowledge exactly the requested keys: ${AWS_OUT}"; return 1; } aws_run s3api list-objects-v2 --bucket "s3c208-b1" - printf '%s' "${AWS_OUT}" | jq -e '[.Contents[]?] | length == 2' >/dev/null \ - || { echo "expected 2 remaining objects: ${AWS_OUT}"; return 1; } + assert_aws_ok "list remaining keys" || return 1 + printf '%s' "${AWS_OUT}" | jq -e '[.Contents[]?.Key] == ["prefix/o4","prefix/o5"]' >/dev/null \ + || { echo "unexpected remaining keys: ${AWS_OUT}"; return 1; } rm_bucket "s3c208-b1" } @@ -1462,7 +1491,7 @@ test_s3c209() { assert_aws_ok || return 1 aws_run s3api get-object --bucket "s3c209-b2" --key f ${TEST_TMP}/s3c-dl assert_aws_ok || return 1 - [ "$(md5_of_file ${TEST_TMP}/s3c-dl)" = "$(md5_of_file ${TEST_TMP}/s3c-file)" ] || { echo "copy content mismatch"; return 1; } + cmp -s "${TEST_TMP}/s3c-dl" "${TEST_TMP}/s3c-file" || { echo "copy content mismatch"; return 1; } # REPLACE metadata directive aws_run s3api copy-object --bucket "s3c209-b2" --key f --copy-source "s3c209-b1/f" --metadata-directive REPLACE --metadata dst=1 assert_aws_ok || return 1 @@ -1505,7 +1534,7 @@ test_s3c210() { assert_aws_ok || return 1 aws_run s3api get-object --bucket "s3c210-b1" --key "${key}" ${TEST_TMP}/s3c-dl assert_aws_ok || return 1 - [ "$(md5_of_file ${TEST_TMP}/s3c-dl)" = "$(md5_of_file ${TEST_TMP}/s3c-file)" ] || { echo "special-char key download mismatch"; return 1; } + cmp -s "${TEST_TMP}/s3c-dl" "${TEST_TMP}/s3c-file" || { echo "special-char key download mismatch"; return 1; } aws_run s3api list-objects-v2 --bucket "s3c210-b1" printf '%s' "${AWS_OUT}" | jq -e --arg k "${key}" '.Contents[]? | select(.Key == $k)' >/dev/null \ || { echo "special-char key not listed: ${AWS_OUT}"; return 1; } @@ -1523,7 +1552,7 @@ test_s3c211() { assert_rc_ok "rc mv" || return 1 aws_run s3api get-object --bucket "s3c211-b1" --key g ${TEST_TMP}/s3c-dl assert_aws_ok || return 1 - [ "$(md5_of_file ${TEST_TMP}/s3c-dl)" = "$(md5_of_file ${TEST_TMP}/s3c-file)" ] || { echo "moved content mismatch"; return 1; } + cmp -s "${TEST_TMP}/s3c-dl" "${TEST_TMP}/s3c-file" || { echo "moved content mismatch"; return 1; } aws_run s3api head-object --bucket "s3c211-b1" --key f assert_aws_fails_with "404" || return 1 rm_bucket "s3c211-b1" @@ -1610,7 +1639,7 @@ test_s3c301() { printf '%s' "${AWS_OUT}" | jq -e --arg etag "${final_etag}" \ '.ETag == $etag and .ContentLength == 15728640' >/dev/null \ || { echo "multipart GET disagrees with completion: ${AWS_OUT}"; return 1; } - [ "$(md5_of_file ${TEST_TMP}/s3c-dl)" = "$(md5_of_file ${TEST_TMP}/s3c-mp)" ] || { echo "multipart download MD5 mismatch"; return 1; } + cmp -s "${TEST_TMP}/s3c-dl" "${TEST_TMP}/s3c-mp" || { echo "multipart download MD5 mismatch"; return 1; } rm_bucket "s3c301-b1" } @@ -1643,7 +1672,8 @@ test_s3c302() { --copy-source-if-modified-since "${copy_date_past}" --copy-source-if-unmodified-since "${copy_date_future}" assert_aws_ok "copy part with satisfied dates" || return 1 tail -c 5242880 "${TEST_TMP}/s3c-mp" > "${TEST_TMP}/s3c-second-part" - second_etag="\"$(md5_of_file "${TEST_TMP}/s3c-second-part")\"" + second_etag="$(md5_of_file "${TEST_TMP}/s3c-second-part")" || return 1 + second_etag="\"${second_etag}\"" aws_run s3api list-parts --bucket "s3c302-b1" --key dst --upload-id "${upload_id}" assert_aws_ok || return 1 jq -e --arg etag "${second_etag}" '.Parts | length == 1 and .[0].ETag == $etag' <<< "${AWS_OUT}" >/dev/null \ @@ -1658,7 +1688,6 @@ test_s3c302() { assert_aws_ok || return 1 aws_run s3api get-object --bucket "s3c302-b1" --key dst ${TEST_TMP}/s3c-dl assert_aws_ok || return 1 - [ "$(wc -c < ${TEST_TMP}/s3c-dl)" = "5242880" ] || { echo "upload-part-copy size mismatch"; return 1; } head -c 5242880 "${TEST_TMP}/s3c-mp" > "${TEST_TMP}/s3c-first-part" cmp -s "${TEST_TMP}/s3c-first-part" "${TEST_TMP}/s3c-dl" || { echo "conditional part-copy content mismatch"; return 1; } rm_bucket "s3c302-b1" @@ -1779,13 +1808,18 @@ test_s3c401() { test_s3c402() { new_bucket "s3c402-b1" || return 1 - aws_run s3api put-object --bucket "s3c402-b1" --key "dir/a.txt" --body /etc/hostname - aws_run s3api put-object --bucket "s3c402-b1" --key "dir/b.txt" --body /etc/hostname - aws_run s3api put-object --bucket "s3c402-b1" --key "top.txt" --body /etc/hostname + printf 's3 fixture\n' > "${TEST_TMP}/object-fixture" || return 1 + aws_run s3api put-object --bucket "s3c402-b1" --key "dir/a.txt" --body "${TEST_TMP}/object-fixture" + assert_aws_ok "seed listing fixture" || return 1 + aws_run s3api put-object --bucket "s3c402-b1" --key "dir/b.txt" --body "${TEST_TMP}/object-fixture" + assert_aws_ok "seed listing fixture" || return 1 + aws_run s3api put-object --bucket "s3c402-b1" --key "top.txt" --body "${TEST_TMP}/object-fixture" + assert_aws_ok "seed listing fixture" || return 1 aws_run s3api list-objects-v2 --bucket "s3c402-b1" --prefix "dir/" --delimiter "/" assert_aws_ok || return 1 - printf '%s' "${AWS_OUT}" | jq -e '.Contents | length == 2' >/dev/null || { echo "Contents != 2: ${AWS_OUT}"; return 1; } + printf '%s' "${AWS_OUT}" | jq -e '[.Contents[]?.Key] == ["dir/a.txt","dir/b.txt"]' >/dev/null || { echo "unexpected keys under dir/: ${AWS_OUT}"; return 1; } aws_run s3api list-objects-v2 --bucket "s3c402-b1" --delimiter "/" + assert_aws_ok "list with delimiter" || return 1 printf '%s' "${AWS_OUT}" | jq -e '[.CommonPrefixes[].Prefix] | index("dir/") != null' >/dev/null \ || { echo "CommonPrefixes missing dir/: ${AWS_OUT}"; return 1; } rm_bucket "s3c402-b1" @@ -1793,30 +1827,40 @@ test_s3c402() { test_s3c403() { new_bucket "s3c403-b1" || return 1 + printf 's3 fixture\n' > "${TEST_TMP}/object-fixture" || return 1 local i for i in $(seq 1 5); do - aws_run s3api put-object --bucket "s3c403-b1" --key "k${i}" --body /etc/hostname + aws_run s3api put-object --bucket "s3c403-b1" --key "k${i}" --body "${TEST_TMP}/object-fixture" + assert_aws_ok "seed listing fixture" || return 1 + done + local expected token="" next_token + local -a continuation=() + for expected in '["k1","k2"]' '["k3","k4"]' '["k5"]'; do + aws_run s3api list-objects-v2 --bucket "s3c403-b1" --max-keys 2 "${continuation[@]}" + assert_aws_ok || return 1 + jq -e --argjson expected "${expected}" \ + '[.Contents[]?.Key] == $expected and .KeyCount == ($expected | length) + and .IsTruncated == (($expected | length) == 2)' <<< "${AWS_OUT}" >/dev/null \ + || { echo "unexpected listing page: ${AWS_OUT}"; return 1; } + if [ "${expected}" != '["k5"]' ]; then + next_token="$(jq -er '.NextContinuationToken | strings | select(length > 0)' <<< "${AWS_OUT}")" || return 1 + [ "${next_token}" != "${token}" ] || { echo "listing repeated its continuation token"; return 1; } + token="${next_token}" + continuation=(--continuation-token "${token}") + fi done - aws_run s3api list-objects-v2 --bucket "s3c403-b1" --max-keys 2 - assert_aws_ok || return 1 - printf '%s' "${AWS_OUT}" | jq -e '.IsTruncated == true and .KeyCount == 2' >/dev/null \ - || { echo "page1 not truncated: ${AWS_OUT}"; return 1; } - local token - token="$(printf '%s' "${AWS_OUT}" | jq -r '.NextContinuationToken')" - aws_run s3api list-objects-v2 --bucket "s3c403-b1" --max-keys 2 --continuation-token "${token}" - assert_aws_ok || return 1 - printf '%s' "${AWS_OUT}" | jq -e '.IsTruncated == true' >/dev/null || { echo "page2 not truncated: ${AWS_OUT}"; return 1; } - token="$(printf '%s' "${AWS_OUT}" | jq -r '.NextContinuationToken')" - aws_run s3api list-objects-v2 --bucket "s3c403-b1" --max-keys 2 --continuation-token "${token}" - printf '%s' "${AWS_OUT}" | jq -e '.IsTruncated == false' >/dev/null || { echo "page3 should end: ${AWS_OUT}"; return 1; } rm_bucket "s3c403-b1" } test_s3c404() { new_bucket "s3c404-b1" || return 1 - aws_run s3api put-object --bucket "s3c404-b1" --key a --body /etc/hostname - aws_run s3api put-object --bucket "s3c404-b1" --key b --body /etc/hostname - aws_run s3api put-object --bucket "s3c404-b1" --key c --body /etc/hostname + printf 's3 fixture\n' > "${TEST_TMP}/object-fixture" || return 1 + aws_run s3api put-object --bucket "s3c404-b1" --key a --body "${TEST_TMP}/object-fixture" + assert_aws_ok "seed listing fixture" || return 1 + aws_run s3api put-object --bucket "s3c404-b1" --key b --body "${TEST_TMP}/object-fixture" + assert_aws_ok "seed listing fixture" || return 1 + aws_run s3api put-object --bucket "s3c404-b1" --key c --body "${TEST_TMP}/object-fixture" + assert_aws_ok "seed listing fixture" || return 1 aws_run s3api list-objects --bucket "s3c404-b1" --marker a assert_aws_ok || return 1 printf '%s' "${AWS_OUT}" | jq -e '[.Contents[].Key] == ["b","c"]' >/dev/null \ @@ -1888,7 +1932,7 @@ test_s3c503() { aws_run s3api put-object --bucket "s3c503-b1" --key f --body ${TEST_TMP}/s3c-v2 aws_run s3api get-object --bucket "s3c503-b1" --key f --version-id "${v1}" ${TEST_TMP}/s3c-dl assert_aws_ok || return 1 - [ "$(md5_of_file ${TEST_TMP}/s3c-dl)" = "$(md5_of_file ${TEST_TMP}/s3c-v1)" ] || { echo "version read mismatch"; return 1; } + cmp -s "${TEST_TMP}/s3c-dl" "${TEST_TMP}/s3c-v1" || { echo "version read mismatch"; return 1; } rm_bucket "s3c503-b1" } @@ -1935,7 +1979,7 @@ test_s3c506() { assert_aws_ok || return 1 aws_run s3api get-object --bucket "s3c506-b1" --key f ${TEST_TMP}/s3c-dl assert_aws_ok || return 1 - [ "$(md5_of_file ${TEST_TMP}/s3c-dl)" = "$(md5_of_file ${TEST_TMP}/s3c-v)" ] || { echo "restored content mismatch"; return 1; } + cmp -s "${TEST_TMP}/s3c-dl" "${TEST_TMP}/s3c-v" || { echo "restored content mismatch"; return 1; } rm_bucket "s3c506-b1" } @@ -1989,10 +2033,10 @@ assert_object_lock_protects_version() { WORM_OVERWRITE_VID="" aws_run s3api get-object --bucket "${bucket}" --key "${key}" --version-id "${vid}" "${got}" assert_aws_ok || return 1 - [ "$(md5_of_file "${got}")" = "$(md5_of_file "${expected}")" ] \ + cmp -s "${got}" "${expected}" \ || { echo "protected version ${vid} bytes differ before overwrite"; return 1; } printf 'worm-overwrite-%s\n' "${vid}" > "${overwrite}" - if [ "$(md5_of_file "${overwrite}")" = "$(md5_of_file "${expected}")" ]; then + if cmp -s "${overwrite}" "${expected}"; then printf 'x' >> "${overwrite}" fi aws_run s3api put-object --bucket "${bucket}" --key "${key}" --body "${overwrite}" @@ -2004,13 +2048,13 @@ assert_object_lock_protects_version() { || { echo "overwrite reused protected version ${vid}"; return 1; } aws_run s3api get-object --bucket "${bucket}" --key "${key}" --version-id "${vid}" "${got}" assert_aws_ok || return 1 - [ "$(md5_of_file "${got}")" = "$(md5_of_file "${expected}")" ] \ + cmp -s "${got}" "${expected}" \ || { echo "overwrite replaced protected version ${vid}"; return 1; } aws_run s3api delete-object --bucket "${bucket}" --key "${key}" --version-id "${vid}" assert_aws_fails_with "AccessDenied" || return 1 aws_run s3api get-object --bucket "${bucket}" --key "${key}" --version-id "${vid}" "${got}" assert_aws_ok || return 1 - [ "$(md5_of_file "${got}")" = "$(md5_of_file "${expected}")" ] \ + cmp -s "${got}" "${expected}" \ || { echo "protected version ${vid} changed after denied delete"; return 1; } WORM_OVERWRITE_VID="${overwrite_vid}" } @@ -2062,7 +2106,7 @@ test_s3c603() { assert_aws_ok || return 1 vid="$(printf '%s' "${AWS_OUT}" | jq -r '.VersionId // empty')" [ -n "${vid}" ] && [ "${vid}" != "null" ] || { echo "put-object returned no VersionId"; return 1; } - until="$(date -u -d '+1 day' +%Y-%m-%dT%H:%M:%SZ)" + until="$(utc_after 24 '%Y-%m-%dT%H:%M:%SZ')" || return 1 # Attach GOVERNANCE to this version before any delete or overwrite probe. aws_run s3api put-object-retention --bucket "${bucket}" --key f --version-id "${vid}" \ --retention "{\"Mode\":\"GOVERNANCE\",\"RetainUntilDate\":\"${until}\"}" @@ -2082,7 +2126,7 @@ test_s3c603() { assert_aws_fails_with "AccessDenied" || return 1 aws_run s3api get-object --bucket "${bucket}" --key f --version-id "${vid}" "${TEST_TMP}/s3c-got" assert_aws_ok || return 1 - [ "$(md5_of_file "${TEST_TMP}/s3c-got")" = "$(md5_of_file "${TEST_TMP}/s3c-v")" ] \ + cmp -s "${TEST_TMP}/s3c-got" "${TEST_TMP}/s3c-v" \ || { echo "protected version bytes changed after denied delete"; return 1; } worm_bypass_delete_version "${bucket}" f "${vid}" || return 1 worm_delete_version "${bucket}" f "${WORM_OVERWRITE_VID}" || return 1 @@ -2099,7 +2143,7 @@ test_s3c604() { assert_aws_ok || return 1 vid="$(printf '%s' "${AWS_OUT}" | jq -r '.VersionId // empty')" [ -n "${vid}" ] && [ "${vid}" != "null" ] || { echo "put-object returned no VersionId"; return 1; } - until="$(date -u -d '+1 day' +%Y-%m-%dT%H:%M:%SZ)" + until="$(utc_after 24 '%Y-%m-%dT%H:%M:%SZ')" || return 1 aws_run s3api put-object-retention --bucket "${bucket}" --key f --version-id "${vid}" \ --retention "{\"Mode\":\"COMPLIANCE\",\"RetainUntilDate\":\"${until}\"}" assert_aws_ok || return 1 @@ -2120,7 +2164,7 @@ test_s3c604() { assert_aws_fails_with "AccessDenied" || return 1 aws_run s3api get-object --bucket "${bucket}" --key f --version-id "${vid}" "${TEST_TMP}/s3c-got" assert_aws_ok || return 1 - [ "$(md5_of_file "${TEST_TMP}/s3c-got")" = "$(md5_of_file "${TEST_TMP}/s3c-v")" ] \ + cmp -s "${TEST_TMP}/s3c-got" "${TEST_TMP}/s3c-v" \ || { echo "COMPLIANCE version bytes changed after denied delete"; return 1; } # The overwrite version and delete marker are not under COMPLIANCE. worm_delete_version "${bucket}" f "${WORM_OVERWRITE_VID}" || return 1 @@ -2327,7 +2371,7 @@ test_s3c901() { || { echo "SSE-S3 header missing: ${AWS_OUT}"; return 1; } aws_run s3api get-object --bucket "s3c901-b1" --key f ${TEST_TMP}/s3c-dl assert_aws_ok || return 1 - [ "$(md5_of_file ${TEST_TMP}/s3c-dl)" = "$(md5_of_file ${TEST_TMP}/s3c-v)" ] || { echo "SSE-S3 download MD5 mismatch"; return 1; } + cmp -s "${TEST_TMP}/s3c-dl" "${TEST_TMP}/s3c-v" || { echo "SSE-S3 download MD5 mismatch"; return 1; } rm_bucket "s3c901-b1" } @@ -2350,7 +2394,7 @@ test_s3c902() { aws_run s3api get-object --bucket "s3c902-b1" --key f ${TEST_TMP}/s3c-dl \ --sse-customer-algorithm AES256 --sse-customer-key "${key}" assert_aws_ok || return 1 - [ "$(md5_of_file ${TEST_TMP}/s3c-dl)" = "$(md5_of_file ${TEST_TMP}/s3c-v)" ] || { echo "SSE-C download MD5 mismatch"; return 1; } + cmp -s "${TEST_TMP}/s3c-dl" "${TEST_TMP}/s3c-v" || { echo "SSE-C download MD5 mismatch"; return 1; } # missing key -> 400/403 aws_run s3api get-object --bucket "s3c902-b1" --key f ${TEST_TMP}/s3c-dl2 assert_aws_fails_with "400|403|InvalidRequest|AccessDenied" || return 1 @@ -2384,7 +2428,7 @@ test_s3c904() { assert_aws_ok || return 1 aws_run s3api get-object --bucket "s3c904-b1" --key dst ${TEST_TMP}/s3c-dl assert_aws_ok || return 1 - [ "$(md5_of_file ${TEST_TMP}/s3c-dl)" = "$(md5_of_file ${TEST_TMP}/s3c-v)" ] || { echo "encrypted copy MD5 mismatch"; return 1; } + cmp -s "${TEST_TMP}/s3c-dl" "${TEST_TMP}/s3c-v" || { echo "encrypted copy MD5 mismatch"; return 1; } # multipart with SSE-S3 make_test_file ${TEST_TMP}/s3c-mp 15728640 aws_run s3api create-multipart-upload --bucket "s3c904-b1" --key mp --server-side-encryption AES256 @@ -2404,7 +2448,7 @@ test_s3c904() { assert_aws_ok || return 1 aws_run s3api get-object --bucket "s3c904-b1" --key mp ${TEST_TMP}/s3c-dl assert_aws_ok || return 1 - [ "$(md5_of_file ${TEST_TMP}/s3c-dl)" = "$(md5_of_file ${TEST_TMP}/s3c-mp)" ] || { echo "encrypted multipart MD5 mismatch"; return 1; } + cmp -s "${TEST_TMP}/s3c-dl" "${TEST_TMP}/s3c-mp" || { echo "encrypted multipart MD5 mismatch"; return 1; } rm_bucket "s3c904-b1" } @@ -2424,11 +2468,8 @@ test_enc101() { assert_aws_ok || { echo "SSE-S3 put size=${size} failed: ${AWS_OUT}"; return 1; } aws_run s3api get-object --bucket "enc101-b1" --key "f-${size}" "${TEST_TMP}/enc101-dl" assert_aws_ok || return 1 - [ "$(wc -c < "${TEST_TMP}/enc101-dl")" = "${size}" ] || { echo "SSE-S3 size=${size} length mismatch"; return 1; } - if [ "${size}" -gt 0 ]; then - [ "$(md5_of_file "${TEST_TMP}/enc101-dl")" = "$(md5_of_file "${TEST_TMP}/enc101-v")" ] \ - || { echo "SSE-S3 size=${size} MD5 mismatch"; return 1; } - fi + cmp -s "${TEST_TMP}/enc101-dl" "${TEST_TMP}/enc101-v" \ + || { echo "SSE-S3 size=${size} payload mismatch"; return 1; } done rm_bucket "enc101-b1" } @@ -2513,7 +2554,7 @@ test_enc108() { aws_run s3api get-object --bucket "enc108-b1" --key mp "${TEST_TMP}/enc108-dl" \ --sse-customer-algorithm AES256 --sse-customer-key "${key_a}" assert_aws_ok || return 1 - [ "$(md5_of_file "${TEST_TMP}/enc108-dl")" = "$(md5_of_file "${TEST_TMP}/enc108-mp")" ] \ + cmp -s "${TEST_TMP}/enc108-dl" "${TEST_TMP}/enc108-mp" \ || { echo "SSE-C multipart MD5 mismatch"; return 1; } rm_bucket "enc108-b1" } @@ -2550,7 +2591,7 @@ test_enc114() { url="$(aws --endpoint-url "${ENDPOINT}" --region "${REGION}" s3 presign "s3://enc114-b1/f" --expires-in 60 2>/dev/null)" [ -n "${url}" ] || { echo "presign produced no URL"; return 1; } curl -fsS --max-time 30 -o "${TEST_TMP}/enc114-dl" "${url}" || { echo "presigned GET failed"; return 1; } - [ "$(md5_of_file "${TEST_TMP}/enc114-dl")" = "$(md5_of_file "${TEST_TMP}/enc114-v")" ] \ + cmp -s "${TEST_TMP}/enc114-dl" "${TEST_TMP}/enc114-v" \ || { echo "presigned SSE-S3 GET MD5 mismatch"; return 1; } # expired URL -> 403 url="$(aws --endpoint-url "${ENDPOINT}" --region "${REGION}" s3 presign "s3://enc114-b1/f" --expires-in 1 2>/dev/null)" @@ -2603,7 +2644,7 @@ test_s3c1001() { assert_aws_ok || return 1 # clock skew > 15 min -> RequestTimeTooSkewed local fake_date code - fake_date="$(date -u -d '+1 hour' '+%Y%m%dT%H%M%SZ')" + fake_date="$(utc_after 1 '%Y%m%dT%H%M%SZ')" || return 1 code="$(AWS_ACCESS_KEY_ID="${ACCESS_KEY}" AWS_SECRET_ACCESS_KEY="${SECRET_KEY}" AWS_DEFAULT_REGION="${REGION}" \ aws --endpoint-url "${ENDPOINT}" s3api head-object --bucket "s3c1001-b1" --key f 2>&1 | head -c 200; echo rc=$?)" # tampered signature @@ -2636,7 +2677,7 @@ test_s3c1003() { url="$(aws --endpoint-url "${ENDPOINT}" --region "${REGION}" s3 presign "s3://s3c1003-b1/f" --expires-in 3600)" code="$(curl -s -o ${TEST_TMP}/s3c-presign-dl -w '%{http_code}' "${url}")" [ "${code}" = "200" ] || { echo "presigned GET returned ${code}"; return 1; } - [ "$(md5_of_file ${TEST_TMP}/s3c-presign-dl)" = "$(md5_of_file ${TEST_TMP}/s3c-v)" ] || { echo "presigned download MD5 mismatch"; return 1; } + cmp -s "${TEST_TMP}/s3c-presign-dl" "${TEST_TMP}/s3c-v" || { echo "presigned download MD5 mismatch"; return 1; } # tampered param -> 403 local tampered tampered="${url/&X-Amz-Expires=/&X-Amz-Expires=99999}" @@ -2777,7 +2818,7 @@ test_s3c1101() { assert_aws_fails_with "304|NotModified" || return 1 # If-Unmodified-Since in future -> 200 local future - future="$(date -u -d '+1 day' '+%Y-%m-%dT%H:%M:%SZ')" + future="$(utc_after 24 '%Y-%m-%dT%H:%M:%SZ')" || return 1 aws_run s3api get-object --bucket "s3c1101-b1" --key f ${TEST_TMP}/s3c-dl --if-unmodified-since "${future}" assert_aws_ok || return 1 rm_bucket "s3c1101-b1" @@ -2805,16 +2846,24 @@ test_s3c1103() { test_s3c1104() { new_bucket "s3c1104-b1" || return 1 - make_test_file ${TEST_TMP}/s3c-v 1024 - local alg + make_test_file "${TEST_TMP}/s3c-v" 1024 || return 1 + local alg field checksum for alg in CRC32 CRC32C SHA1 SHA256 CRC64NVME; do - aws_run s3api put-object --bucket "s3c1104-b1" --key "f-${alg}" --body ${TEST_TMP}/s3c-v --checksum-algorithm "${alg}" - assert_aws_ok || { echo "checksum algorithm ${alg} failed: ${AWS_OUT}"; return 1; } + field="Checksum${alg}" + aws_run s3api put-object --bucket "s3c1104-b1" --key "f-${alg}" --body "${TEST_TMP}/s3c-v" --checksum-algorithm "${alg}" + assert_aws_ok "PUT with ${alg}" || return 1 + checksum="$(jq -er --arg field "${field}" '.[$field] | strings | select(length > 0)' <<< "${AWS_OUT}")" \ + || { echo "PUT omitted ${field}"; return 1; } + aws_run s3api head-object --bucket "s3c1104-b1" --key "f-${alg}" --checksum-mode ENABLED + assert_aws_ok "HEAD with checksum mode" || return 1 + jq -e --arg field "${field}" --arg checksum "${checksum}" \ + '.[$field] == $checksum' <<< "${AWS_OUT}" >/dev/null \ + || { echo "HEAD ${field} differs from the PUT checksum"; return 1; } + aws_run s3api get-object --bucket "s3c1104-b1" --key "f-${alg}" --checksum-mode ENABLED "${TEST_TMP}/s3c-checksum-dl" + assert_aws_ok "GET with checksum mode" || return 1 + cmp -s "${TEST_TMP}/s3c-v" "${TEST_TMP}/s3c-checksum-dl" \ + || { echo "GET payload mismatch for ${alg}"; return 1; } done - aws_run s3api head-object --bucket "s3c1104-b1" --key f-CRC64NVME - if ! printf '%s' "${AWS_OUT}" | jq -e '.ChecksumCRC64NVME != null' >/dev/null 2>&1; then - echo "note: checksum accepted but not echoed in head-object (server reporting gap)" - fi rm_bucket "s3c1104-b1" } @@ -2991,9 +3040,10 @@ test_s3c1302() { test_s3c1303() { new_bucket "s3c1303-b1" || return 1 + printf 's3 fixture\n' > "${TEST_TMP}/object-fixture" || return 1 local bigkey bigkey="$(printf 'k%.0s' $(seq 1 1100))" - aws_run s3api put-object --bucket "s3c1303-b1" --key "${bigkey}" --body /etc/hostname + aws_run s3api put-object --bucket "s3c1303-b1" --key "${bigkey}" --body "${TEST_TMP}/object-fixture" if [ "${AWS_CODE}" -eq 0 ]; then echo "note: server accepts a 1100-byte key (AWS returns KeyTooLongError)" aws_run s3api delete-object --bucket "s3c1303-b1" --key "${bigkey}" @@ -3037,7 +3087,7 @@ test_s3c1305() { [ "${fail}" -eq 0 ] || { echo "some concurrent writes failed (5xx)"; return 1; } aws_run s3api get-object --bucket "s3c1305-b1" --key f ${TEST_TMP}/s3c-dl assert_aws_ok || return 1 - [ "$(md5_of_file ${TEST_TMP}/s3c-dl)" = "$(md5_of_file ${TEST_TMP}/s3c-v)" ] || { echo "concurrent overwrite produced torn object"; return 1; } + cmp -s "${TEST_TMP}/s3c-dl" "${TEST_TMP}/s3c-v" || { echo "concurrent overwrite produced torn object"; return 1; } rm_bucket "s3c1305-b1" } @@ -3236,7 +3286,7 @@ PY aws_run s3api create-bucket --bucket "snw108-lk" --object-lock-enabled-for-bucket assert_aws_ok || return 1 local until - until="$(date -u -d '+1 day' +%Y-%m-%dT%H:%M:%SZ)" + until="$(utc_after 24 '%Y-%m-%dT%H:%M:%SZ')" || return 1 python3 - "${TEST_TMP}/snw108-lock.tar" "${until}" <<'PY' import io, sys, tarfile path, until = sys.argv[1], sys.argv[2] @@ -3341,7 +3391,7 @@ test_snw114() { new_bucket "snw114-b1" || return 1 snw_build_basic_tar "${TEST_TMP}/snw114.tar" "${TEST_TMP}/snw114-src" || return 1 local archive_md5 etag - archive_md5="$(md5_of_file "${TEST_TMP}/snw114.tar")" + archive_md5="$(md5_of_file "${TEST_TMP}/snw114.tar")" || return 1 aws_run s3api put-object --bucket "snw114-b1" --key "fixture.tar" --body "${TEST_TMP}/snw114.tar" \ --metadata '{"snowball-auto-extract":"true"}' assert_aws_ok || return 1 @@ -3523,6 +3573,7 @@ main() { need_cmd python3 "Python 3 (archive fixtures)" [ -f "${SCRIPT_DIR}/scripts/sse_contract_cases.py" ] || die "missing scripts/sse_contract_cases.py" need_cmd tar "tar archive tool" + need_cmd cmp "byte comparison tool" if [ "${DRY_RUN}" -eq 0 ] && [ -z "${VALIDATION_CASE}" ]; then case ",${SELECTED_CASES}," in ,,|*,S3C-213,*|*,S3C-214,*|*,S3C-1306,*|*,S3C-1307,*) diff --git a/rustfs-security-test.sh b/rustfs-security-test.sh index 0411f489..4f8b3062 100755 --- a/rustfs-security-test.sh +++ b/rustfs-security-test.sh @@ -497,6 +497,7 @@ assert_admin_ok() { local code code="$(admin_api_code)" [ "${code}" = "${expected}" ] || { + assertion_failed=1 echo "admin ${context}: expected HTTP ${expected}, got ${code}" >&2 return 1 } @@ -516,15 +517,29 @@ aws_run_as() { [ "${1:-}" = "--" ] && shift local env_args=(AWS_ACCESS_KEY_ID="${ak}" AWS_SECRET_ACCESS_KEY="${sk}" AWS_EC2_METADATA_DISABLED=true AWS_DEFAULT_REGION="${REGION}") if [ -n "${token}" ]; then env_args+=(AWS_SESSION_TOKEN="${token}"); fi - AWS_OUT="$(env "${env_args[@]}" aws --endpoint-url "${ENDPOINT}" --region "${REGION}" "$@" 2>&1)"; AWS_CODE=$? + AWS_OUT="$(env -u AWS_SESSION_TOKEN -u AWS_SECURITY_TOKEN "${env_args[@]}" aws --endpoint-url "${ENDPOINT}" --region "${REGION}" "$@" 2>&1)"; AWS_CODE=$? } assert_aws_ok() { - [ "${AWS_CODE}" -eq 0 ] || { echo "aws failed (exit ${AWS_CODE}): $*"; echo "${AWS_OUT}"; return 1; } + [ "${AWS_CODE}" -eq 0 ] || { assertion_failed=1; echo "aws failed (exit ${AWS_CODE}): $*"; echo "${AWS_OUT}"; return 1; } } -assert_aws_fails() { - [ "${AWS_CODE}" -ne 0 ] || { echo "aws unexpectedly succeeded (exit ${AWS_CODE}): $*"; return 1; } +aws_error_code() { + printf '%s\n' "${AWS_OUT}" | sed -n 's/^An error occurred (\([A-Za-z0-9]*\)) when calling .*/\1/p' +} + +assert_aws_denied() { + local context="$1" code expected + shift + code="$(aws_error_code)" + if [ "${AWS_CODE}" -ne 0 ]; then + for expected in "$@"; do + [ "${code}" != "${expected}" ] || return 0 + done + fi + assertion_failed=1 + echo "${context}: expected AWS error ($*), got exit ${AWS_CODE}, code ${code:-none}" >&2 + return 1 } new_bucket() { @@ -576,7 +591,7 @@ SKIP=0 run_test() { local id="$1" name="$2" fn="$3" local out="${TEST_TMP}/${id}.out" - local started_at + local started_at assertion_failed=0 if [ -n "${SELECTED_CASES:-}" ]; then case ",${SELECTED_CASES:-}," in *",${id},"*) ;; @@ -594,7 +609,7 @@ run_test() { "${CURRENT_TOPOLOGY}" "${started_at}" > "${STS_DIAGNOSTICS_FILE}" fi printf '\n--- %s %s ---\n' "${id}" "${name}" - if "${fn}" > "${out}" 2>&1; then + if "${fn}" > "${out}" 2>&1 && [ "${assertion_failed}" -eq 0 ]; then PASS=$((PASS+1)); printf '\033[1;32m[PASS]\033[0m %s %s\n' "${id}" "${name}" CASE_RESULTS+=("${id}|${name}|PASS") else @@ -665,7 +680,7 @@ case_iam_102_user_disable() { out="$(admin_user_add "${user}" "${secret}")"; assert_admin_ok 200 "add-user" aws_run_as "${user}" "${secret}" -- s3 ls; assert_aws_ok "enabled user works" out="$(admin_api PUT "/rustfs/admin/v3/set-user-status?accessKey=${user}&status=disabled")"; assert_admin_ok 200 "disable" - aws_run_as "${user}" "${secret}" -- s3 ls; assert_aws_fails "disabled user denied" + aws_run_as "${user}" "${secret}" -- s3 ls; assert_aws_denied "disabled user denied" InvalidAccessKeyId AccessDenied out="$(admin_api PUT "/rustfs/admin/v3/set-user-status?accessKey=${user}&status=enabled")"; assert_admin_ok 200 "enable" aws_run_as "${user}" "${secret}" -- s3 ls; assert_aws_ok "re-enabled user works" admin_user_remove "${user}" >/dev/null @@ -676,19 +691,52 @@ case_iam_103_delete_invalidates() { out="$(admin_user_add "${user}" "${secret}")"; assert_admin_ok 200 "add-user" aws_run_as "${user}" "${secret}" -- s3 ls; assert_aws_ok "user works before delete" out="$(admin_user_remove "${user}")"; assert_admin_ok 200 "remove-user" - aws_run_as "${user}" "${secret}" -- s3 ls; assert_aws_fails "deleted user denied" + aws_run_as "${user}" "${secret}" -- s3 ls; assert_aws_denied "deleted user denied" InvalidAccessKeyId AccessDenied } case_iam_105_readonly_boundary() { - local user="sec105u" secret="sec105secret" out - out="$(admin_user_add "${user}" "${secret}")"; assert_admin_ok 200 "add-user" - out="$(admin_policy_attach "${user}" readonly)"; assert_admin_ok 200 "attach readonly" - new_bucket sec105-bucket || return 1 - aws_run_as "${user}" "${secret}" -- s3 ls s3://sec105-bucket; assert_aws_ok "readonly can list bucket" - aws_run_as "${user}" "${secret}" -- s3api put-object --bucket sec105-bucket --key hello.txt --body /etc/hostname - assert_aws_fails "readonly cannot write" - rm_bucket sec105-bucket + local user="sec105u" secret="sec105secret" bucket="sec105-bucket" key="hello.txt" + local original="${TEST_TMP}/sec105-original" replacement="${TEST_TMP}/sec105-replacement" + local downloaded="${TEST_TMP}/sec105-download" + local result=0 bucket_created=0 + + admin_user_add "${user}" "${secret}" >/dev/null + assert_admin_ok 200 "add-user" || return 1 + if new_bucket "${bucket}"; then + bucket_created=1 + ( + admin_policy_attach "${user}" readonly >/dev/null + assert_admin_ok 200 "attach readonly" || exit 1 + printf 'original payload\n' > "${original}" || exit 1 + printf 'replacement payload\n' > "${replacement}" || exit 1 + aws_run s3api put-object --bucket "${bucket}" --key "${key}" --body "${original}" + assert_aws_ok "seed readonly object" || exit 1 + aws_run_as "${user}" "${secret}" -- s3api get-object --bucket "${bucket}" --key "${key}" "${downloaded}" + assert_aws_ok "readonly can get the object" || exit 1 + cmp "${original}" "${downloaded}" || exit 1 + + aws_run_as "${user}" "${secret}" -- s3api put-object --bucket "${bucket}" --key "${key}" --body "${replacement}" + assert_aws_denied "readonly cannot overwrite the object" AccessDenied || exit 1 + rm -f "${downloaded}" || exit 1 + aws_run s3api get-object --bucket "${bucket}" --key "${key}" "${downloaded}" + assert_aws_ok "denied overwrite preserved the object" || exit 1 + cmp "${original}" "${downloaded}" || exit 1 + + aws_run s3api put-object --bucket "${bucket}" --key "${key}" --body "${replacement}" + assert_aws_ok "administrator can send the same PUT" + ) || result=1 + else + result=1 + fi + if [ "${bucket_created}" -eq 1 ]; then + aws_run s3api delete-object --bucket "${bucket}" --key "${key}" + assert_aws_ok "cleanup readonly object" || result=1 + rm_bucket "${bucket}" + assert_aws_ok "cleanup readonly bucket" || result=1 + fi admin_user_remove "${user}" >/dev/null + assert_admin_ok 200 "cleanup readonly user" || result=1 + return "${result}" } case_iam_106_custom_policy_crud() { @@ -714,7 +762,7 @@ case_iam_107_attach_detach() { out="$(admin_policy_attach "${user}" sec107p)"; assert_admin_ok 200 "attach" aws_run_as "${user}" "${secret}" -- s3 ls s3://sec107-bucket; assert_aws_ok "policy grants list" out="$(admin_policy_detach "${user}" sec107p)"; assert_admin_ok 200 "detach" - aws_run_as "${user}" "${secret}" -- s3 ls s3://sec107-bucket; assert_aws_fails "detached user denied" + aws_run_as "${user}" "${secret}" -- s3 ls s3://sec107-bucket; assert_aws_denied "detached user denied" AccessDenied out="$(admin_policy_detach "${user}" sec107p)"; assert_admin_ok 200 "detach idempotent" rm_bucket sec107-bucket admin_user_remove "${user}" >/dev/null @@ -729,9 +777,12 @@ case_iam_109_deny_precedence() { out="$(admin_policy_add sec109-allow "${allow}")"; assert_admin_ok 200 "add allow" out="$(admin_policy_add sec109-deny "${deny}")"; assert_admin_ok 200 "add deny" new_bucket sec109-bucket || return 1 + out="$(admin_policy_attach "${user}" sec109-allow)"; assert_admin_ok 200 "attach allow" + aws_run_as "${user}" "${secret}" -- s3api list-objects-v2 --bucket sec109-bucket + assert_aws_ok "allow grants list before attaching deny" out="$(admin_api POST /rustfs/admin/v3/idp/builtin/policy/attach "" "{\"policies\":[\"sec109-allow\",\"sec109-deny\"],\"user\":\"${user}\"}")" assert_admin_ok 200 "attach allow+deny" - aws_run_as "${user}" "${secret}" -- s3 ls s3://sec109-bucket; assert_aws_fails "deny overrides allow" + aws_run_as "${user}" "${secret}" -- s3api list-objects-v2 --bucket sec109-bucket; assert_aws_denied "deny overrides allow" AccessDenied rm_bucket sec109-bucket admin_user_remove "${user}" >/dev/null } @@ -750,8 +801,7 @@ validation_iam_policy_body() { assert_aws_ok "allowed GET" || return 1 cmp "${TEST_TMP}/validation-iam-source.bin" "${TEST_TMP}/validation-iam-read.bin" || return 1 aws_run_as "${user}" "${secret}" -- s3api delete-object --bucket "${bucket}" --key object.bin - assert_aws_fails "explicit deny DELETE" || return 1 - [[ "${AWS_OUT}" == *AccessDenied* ]] || { echo "DELETE failure was not AccessDenied"; return 1; } + assert_aws_denied "explicit deny DELETE" AccessDenied || return 1 aws_run s3api get-object --bucket "${bucket}" --key object.bin "${TEST_TMP}/validation-iam-root-read.bin" assert_aws_ok "denied DELETE preserved object" || return 1 cmp "${TEST_TMP}/validation-iam-source.bin" "${TEST_TMP}/validation-iam-root-read.bin" || return 1 @@ -804,13 +854,13 @@ create_service_account() { [ -n "${policy}" ] && body="{\"targetUser\":\"${target}\",\"policy\":${policy}}" local out out="$(admin_api PUT /rustfs/admin/v3/add-service-accounts "" "${body}")" - assert_admin_ok 200 "add-service-accounts" + assert_admin_ok 200 "add-service-accounts" || return 1 printf '%s' "${out}" | jq -r '.credentials.accessKey + "\t" + .credentials.secretKey' } case_sa_101_create_and_use() { local sa - sa="$(create_service_account "${ACCESS_KEY}")" + sa="$(create_service_account "${ACCESS_KEY}")" || return 1 local sa_ak="${sa%%$'\t'*}" sa_sk="${sa#*$'\t'}" aws_run_as "${sa_ak}" "${sa_sk}" -- s3 ls; assert_aws_ok "service account can list buckets" admin_api DELETE "/rustfs/admin/v3/delete-service-account?accessKey=${sa_ak}" >/dev/null @@ -823,10 +873,11 @@ case_sa_103_parent_boundary() { out="$(admin_policy_attach "${user}" readonly)"; assert_admin_ok 200 "attach readonly" new_bucket sec103p-bucket || return 1 local sa - sa="$(create_service_account "${user}" "${policy}")" + sa="$(create_service_account "${user}" "${policy}")" || return 1 local sa_ak="${sa%%$'\t'*}" sa_sk="${sa#*$'\t'}" - aws_run_as "${sa_ak}" "${sa_sk}" -- s3api put-object --bucket sec103p-bucket --key hello.txt --body /etc/hostname - assert_aws_fails "service account cannot exceed readonly parent" + printf 'authorization fixture\n' > "${TEST_TMP}/sec103p-payload" || return 1 + aws_run_as "${sa_ak}" "${sa_sk}" -- s3api put-object --bucket sec103p-bucket --key hello.txt --body "${TEST_TMP}/sec103p-payload" + assert_aws_denied "service account cannot exceed readonly parent" AccessDenied admin_api DELETE "/rustfs/admin/v3/delete-service-account?accessKey=${sa_ak}" >/dev/null rm_bucket sec103p-bucket admin_user_remove "${user}" >/dev/null @@ -834,12 +885,12 @@ case_sa_103_parent_boundary() { case_sa_104_delete_invalidates() { local sa - sa="$(create_service_account "${ACCESS_KEY}")" + sa="$(create_service_account "${ACCESS_KEY}")" || return 1 local sa_ak="${sa%%$'\t'*}" sa_sk="${sa#*$'\t'}" aws_run_as "${sa_ak}" "${sa_sk}" -- s3 ls; assert_aws_ok "service account works" local out out="$(admin_api DELETE "/rustfs/admin/v3/delete-service-account?accessKey=${sa_ak}")"; assert_admin_ok 200 "delete-service-account" - aws_run_as "${sa_ak}" "${sa_sk}" -- s3 ls; assert_aws_fails "deleted service account denied" + aws_run_as "${sa_ak}" "${sa_sk}" -- s3 ls; assert_aws_denied "deleted service account denied" InvalidAccessKeyId AccessDenied } # ==================== STS ==================== @@ -891,8 +942,9 @@ case_sts_104_temp_boundary() { local sts_ak sts_sk sts_token sts_exp IFS=$'\t' read -r sts_ak sts_sk sts_token sts_exp <<<"${creds}" aws_run_as "${sts_ak}" "${sts_sk}" "${sts_token}" -- s3 ls s3://sec104-a-bucket; assert_aws_ok "STS creds can list allowed bucket" - aws_run_as "${sts_ak}" "${sts_sk}" "${sts_token}" -- s3api put-object --bucket sec104-b-bucket --key hello.txt --body /etc/hostname - assert_aws_fails "STS creds cannot exceed identity scope" + printf 'authorization fixture\n' > "${TEST_TMP}/sec104-payload" || return 1 + aws_run_as "${sts_ak}" "${sts_sk}" "${sts_token}" -- s3api put-object --bucket sec104-b-bucket --key hello.txt --body "${TEST_TMP}/sec104-payload" + assert_aws_denied "STS creds cannot exceed identity scope" AccessDenied rm_bucket sec104-a-bucket rm_bucket sec104-b-bucket admin_user_remove "${user}" >/dev/null @@ -914,15 +966,8 @@ case_sts_105_revoke() { printf 'STS-105 post-revoke: aws_exit=%s\n' "${AWS_CODE}" printf '%s\n' "${AWS_OUT}" } >> "${STS_DIAGNOSTICS_FILE}" - assert_aws_fails "STS creds invalid after revoke" || return 1 - local error_code - error_code="$(printf '%s\n' "${AWS_OUT}" | sed -n 's/.*An error occurred (\([A-Za-z]*\)) when calling.*/\1/p' | head -1)" - case "${error_code}" in - InvalidAccessKeyId|AccessDenied) - printf 'STS-105 post-revoke: aws_exit=%s error_code=%s\n' "${AWS_CODE}" "${error_code}" >> "${STS_DIAGNOSTICS_FILE}" - ;; - *) echo "STS request failed without the expected credential rejection" >&2; return 1 ;; - esac + assert_aws_denied "STS creds invalid after revoke" InvalidAccessKeyId AccessDenied || return 1 + printf 'STS-105 post-revoke: aws_exit=%s error_code=%s\n' "${AWS_CODE}" "$(aws_error_code)" >> "${STS_DIAGNOSTICS_FILE}" } # Issue #9279 uses an S3-scoped SigV4 POST, rather than the AWS CLI's STS @@ -997,8 +1042,7 @@ PY --role-session-name sec108 \ --duration-seconds 900 \ --web-identity-token "${expired_jwt}" - assert_aws_fails "expired/garbage web identity token" - printf '%s' "${AWS_OUT}" | grep -qiE 'AccessDenied' || { echo "expected AccessDenied, got: ${AWS_OUT}"; return 1; } + assert_aws_denied "expired/garbage web identity token" AccessDenied } case_oidc_103_keycloak_live() { @@ -1179,6 +1223,7 @@ main() { need_cmd openssl "openssl" need_cmd aws "aws cli" need_cmd jq "jq" + need_cmd cmp "cmp" need_cmd python3 "python3" if [ -n "${VALIDATION_CASE}" ]; then need_cmd rc "rc client provenance"; fi TEST_SCRIPT_REVISION="$(git -C "${SCRIPT_DIR}" rev-parse HEAD 2>/dev/null || printf unknown)" diff --git a/test_rustfs_replication.py b/test_rustfs_replication.py index 639ee978..67a62ac9 100644 --- a/test_rustfs_replication.py +++ b/test_rustfs_replication.py @@ -24,6 +24,7 @@ def run_case(self, mode): make_test_file() { :; } rm_bucket_force() { :; } aws_wait_ep() { [ "$1" = "$SITE2_ENDPOINT" ]; } +wait_for_delete_marker() { [ "$1" = "$SITE2_ENDPOINT" ]; } assert_aws_ok() { [ "$AWS_CODE" -eq 0 ]; } aws_run() { case "$2" in @@ -67,6 +68,27 @@ def test_rejects_failed_listing_even_with_empty_json(self): self.assertNotEqual(self.run_case("list_error").returncode, 0) +class ReplicationPollingTests(unittest.TestCase): + def test_exit_zero_with_false_response_cannot_satisfy_a_predicate(self): + source = (ROOT / "rustfs-replication-test.sh").read_text() + wait = source[source.index("aws_wait_ep() {"):source.index("\nwait_for_delete_marker() {")] + harness = r""" +CONVERGE_TIMEOUT=2 +CONVERGE_INTERVAL=1 +REGION=us-east-1 +timeout() { shift; "$@"; } +aws() { printf '%s\n' "$RESPONSE"; } +""" + for response, expected in (("False", 1), ("false", 1), ("", 1), ("True", 0), ("true", 0)): + with self.subTest(response=response): + result = subprocess.run( + ["bash", "-c", harness + wait + + '\naws_wait_ep http://target:19000 "predicate" --expect-true s3api fake'], + env={**os.environ, "RESPONSE": response}, capture_output=True, text=True, timeout=6, + ) + self.assertEqual(result.returncode, expected, result.stdout + result.stderr) + + class JqBatchCompatibilityTests(unittest.TestCase): def test_nwise_batches_without_jq_private_builtin(self): helper = ROOT / "scripts/lib/jq_nwise.jq" diff --git a/test_rustfs_s3_regressions.py b/test_rustfs_s3_regressions.py index f3e8b19e..c41c0fdd 100644 --- a/test_rustfs_s3_regressions.py +++ b/test_rustfs_s3_regressions.py @@ -22,6 +22,13 @@ done : > "${TEST_TMP}/curl.out" case "$CASE:$method:$path:$header" in + 106:PUT:*) + printf '%s' "$([ "$SCENARIO" = wrong-code ] && echo InvalidArgument || echo InvalidBucketName)" > "${TEST_TMP}/curl.out" + printf '400' + ;; + 1401:PUT:/s3c1401-dst/f:*) + printf '200' + ;; 101:PUT:/s3c101-b2:"x-amz-bucket-namespace: global") if [ "$SCENARIO" = rejects-global-ns ]; then printf 'InternalError' > "${TEST_TMP}/curl.out" @@ -154,6 +161,11 @@ esac ;; head-object) + if [ "$CASE" = 1401 ]; then + AWS_OUT='{"ContentType":"application/x-rustfs-src","Metadata":{"src":"1"}}' + [ "$SCENARIO" != copied-request-header ] || AWS_OUT='{"ContentType":"application/x-rustfs-src","Metadata":{"src":"1","request-only":"ignored"}}' + return 0 + fi AWS_OUT='{"ETag":"\"final-3\"","ContentLength":15728640}' case "$SCENARIO" in wrong-head-etag) AWS_OUT='{"ETag":"\"different-3\"","ContentLength":15728640}' ;; @@ -278,6 +290,14 @@ def test_valid_responses(self): with self.subTest(scenario=scenario): self.assert_case(103, scenario, True) + def test_create_bucket_requires_the_protocol_error_code(self): + self.assert_case(106, "success", True) + self.assert_case(106, "wrong-code", False) + + def test_copy_rejects_the_exact_request_only_metadata_key(self): + self.assert_case(1401, "success", True) + self.assert_case(1401, "copied-request-header", False) + def test_create_bucket_global_namespace_and_location(self): for scenario in ("missing-location", "rejects-global-ns", "head-global-ns-fails"): with self.subTest(scenario=scenario): diff --git a/test_rustfs_security.py b/test_rustfs_security.py index d9b07577..37ea0f23 100644 --- a/test_rustfs_security.py +++ b/test_rustfs_security.py @@ -32,7 +32,6 @@ def run_case(self, scenario, response='{"revoked":1}'): admin_api_code() { cat "$TEST_TMP/code"; } assert_admin_ok() { [ "$(admin_api_code)" = "$1" ]; } assert_aws_ok() { [ "$AWS_CODE" -eq 0 ]; } -assert_aws_fails() { [ "$AWS_CODE" -ne 0 ]; } aws_run_as() { AWS_CALLS=$((AWS_CALLS + 1)) echo "aws-${AWS_CALLS}" >> "$TEST_TMP/steps" @@ -50,7 +49,8 @@ def run_case(self, scenario, response='{"revoked":1}'): ''' with tempfile.TemporaryDirectory() as directory: result = subprocess.run( - ["bash", "-c", harness + shell_function("case_sts_105_revoke") + + ["bash", "-c", harness + "\n".join(shell_function(name) for name in + ("aws_error_code", "assert_aws_denied", "case_sts_105_revoke")) + "\nif case_sts_105_revoke; then exit 0; else exit 1; fi"], env={**os.environ, "TEST_TMP": directory, "SCENARIO": scenario, "TEST_RESPONSE": response, "STS_DIAGNOSTICS_FILE": str(Path(directory) / "diagnostics")}, @@ -82,6 +82,65 @@ def test_successful_access_and_network_failures_do_not_pass(self): self.assertNotEqual(self.run_case(scenario)[0].returncode, 0) +class ReadonlyPolicyTest(unittest.TestCase): + def test_preserves_failures_after_cleanup_and_requires_the_exact_denial(self): + harness = r""" +set -Eeu -o pipefail +admin_user_add() { :; } +admin_user_remove() { echo user-cleanup >> "$TEST_TMP/steps"; } +admin_policy_attach() { :; } +admin_api_code() { echo 200; } +new_bucket() { :; } +rm_bucket() { echo bucket-cleanup >> "$TEST_TMP/steps"; } +aws_run() { + AWS_CODE=0 AWS_OUT="" + case "$2" in + put-object) cp "${@: -1}" "$TEST_TMP/object" ;; + get-object) + cp "$TEST_TMP/object" "${@: -1}" + if [ "$SCENARIO" = wrong-bytes ]; then echo corrupt > "${@: -1}"; fi + ;; + delete-object) rm -f "$TEST_TMP/object" ;; + *) return 99 ;; + esac +} +aws_run_as() { + shift 3 + AWS_CODE=0 AWS_OUT="" + case "$2" in + get-object) + if [ "$SCENARIO" = allowed-read-fails ]; then AWS_CODE=254; return; fi + cp "$TEST_TMP/object" "${@: -1}" + ;; + put-object) + case "$SCENARIO" in + unexpected-write) cp "${@: -1}" "$TEST_TMP/object" ;; + missing-fixture) AWS_CODE=255; AWS_OUT="Unable to read file AccessDenied" ;; + wrong-error) AWS_CODE=254; AWS_OUT="An error occurred (NoSuchBucket) when calling the PutObject operation: AccessDenied" ;; + *) AWS_CODE=254; AWS_OUT="An error occurred (AccessDenied) when calling the PutObject operation: denied" ;; + esac + ;; + *) return 99 ;; + esac + return 0 +} +""" + helpers = "\n".join(shell_function(name) for name in ( + "assert_admin_ok", "assert_aws_ok", "aws_error_code", "assert_aws_denied", + "case_iam_105_readonly_boundary", + )) + for scenario in ("expected", "unexpected-write", "allowed-read-fails", "missing-fixture", + "wrong-error", "wrong-bytes"): + with self.subTest(scenario=scenario), tempfile.TemporaryDirectory() as directory: + result = subprocess.run( + ["bash", "-c", harness + helpers + "\nif case_iam_105_readonly_boundary; then exit 0; else exit 1; fi"], + env={**os.environ, "TEST_TMP": directory, "SCENARIO": scenario}, + capture_output=True, text=True, timeout=10, + ) + self.assertEqual(result.returncode, int(scenario != "expected"), result.stdout + result.stderr) + self.assertEqual((Path(directory) / "steps").read_text().splitlines(), ["bucket-cleanup", "user-cleanup"]) + + class AdminResponseDiagnosticsTest(unittest.TestCase): def test_preserves_json_xml_and_proxy_response_evidence(self): responses = [('{"Code":"AccessDenied","RequestId":"body-request"}', ""), From 027d82b3ddb8fc786bc4e33195c50e6bb6f5ce12 Mon Sep 17 00:00:00 2001 From: loverustfs Date: Sat, 28 Nov 2026 22:10:25 +0800 Subject: [PATCH 2/8] Gate performance budgets and sample upgrade I/O against verified candidates --- .github/workflows/rustfs-performance-test.yml | 13 +++ .github/workflows/rustfs-upgrade-test.yml | 21 ++++ README.md | 25 ++++ rustfs-upgrade-test.sh | 110 ++++++++++++++++-- rustfs_performance_test.sh | 32 ++++- rustfs_performance_testing.sh | 72 +++++++++--- scripts/lib/package_candidate.sh | 23 ++++ scripts/performance_budget.py | 67 +++++++++++ test_rustfs_performance_testing.py | 29 +++++ test_rustfs_upgrade.py | 88 ++++++++++++++ 10 files changed, 452 insertions(+), 28 deletions(-) create mode 100644 scripts/lib/package_candidate.sh create mode 100644 scripts/performance_budget.py diff --git a/.github/workflows/rustfs-performance-test.yml b/.github/workflows/rustfs-performance-test.yml index 8d3eec8d..5f0a47fa 100644 --- a/.github/workflows/rustfs-performance-test.yml +++ b/.github/workflows/rustfs-performance-test.yml @@ -20,6 +20,10 @@ on: description: 'Direct .deb URL (nightly/R2). Defaults to the latest nightly deb.' required: false type: string + package_sha256: + description: SHA-256 of the candidate Debian package + required: false + type: string test_method: description: 'Benchmark method(s) to run (manual runs only; "all" = GET+PUT+MIXED)' type: choice @@ -111,6 +115,7 @@ jobs: runs-on: pf-testing timeout-minutes: 900 env: + RUSTFS_PACKAGE_SHA256: ${{ inputs.package_sha256 }} RUSTFS_BENCH_SCRIPT: ${{ github.workspace }}/rustfs_performance_testing.sh RUSTFS_WARP_METHODS: ${{ inputs.test_method }} RUSTFS_WARP_SIZES: ${{ inputs.object_size }} @@ -194,7 +199,13 @@ jobs: - name: Run benchmark (GET/PUT/MIXED) id: benchmark + env: + PERFORMANCE_BUDGET_JSON: ${{ vars.RUSTFS_WARP_BUDGET_JSON }} run: | + if [ -n "${PERFORMANCE_BUDGET_JSON}" ]; then + export RUSTFS_WARP_BUDGET_FILE="${FUNCTIONAL_ARTIFACTS_DIR}/performance-budget.json" + printf '%s\n' "${PERFORMANCE_BUDGET_JSON}" > "${RUSTFS_WARP_BUDGET_FILE}" + fi ./rustfs_performance_test.sh \ --step 5 -y \ --log-file "${LOG_FILE}" @@ -321,6 +332,8 @@ jobs: ${{ env.FUNCTIONAL_ARTIFACTS_DIR }}/report.md ${{ env.FUNCTIONAL_ARTIFACTS_DIR }}/suite.log ${{ env.FUNCTIONAL_ARTIFACTS_DIR }}/version.txt + ${{ env.FUNCTIONAL_ARTIFACTS_DIR }}/results/performance-budget*.json + ${{ env.FUNCTIONAL_ARTIFACTS_DIR }}/results/candidate-*.tsv ${{ env.FUNCTIONAL_ARTIFACTS_DIR }}/results/master.log ${{ env.FUNCTIONAL_ARTIFACTS_DIR }}/results/summary.md ${{ env.FUNCTIONAL_ARTIFACTS_DIR }}/results/summary.tsv diff --git a/.github/workflows/rustfs-upgrade-test.yml b/.github/workflows/rustfs-upgrade-test.yml index 4dc8f2f6..61330315 100644 --- a/.github/workflows/rustfs-upgrade-test.yml +++ b/.github/workflows/rustfs-upgrade-test.yml @@ -38,6 +38,14 @@ on: description: 'NEW .deb URL. Overrides to_version / nightly default.' required: false type: string + to_sha256: + description: SHA-256 of the candidate Debian package + required: false + type: string + require_upgrade_availability: + description: Require successful sampled I/O and verify each running candidate + type: boolean + default: false topology: description: 'Topology to run (all = SNSD, SNMD, MNMD)' type: choice @@ -164,6 +172,8 @@ jobs: # Collect reports and backlog evidence before the final suite verdict. continue-on-error: true env: + INPUT_TO_SHA256: ${{ inputs.to_sha256 }} + REQUIRE_UPGRADE_AVAILABILITY: ${{ inputs.require_upgrade_availability }} GH_TOKEN: ${{ secrets.PF_TESTING_GH_TOKEN }} run: | set -euo pipefail @@ -175,6 +185,12 @@ jobs: TOPOLOGY='${{ inputs.topology }}' BACKENDS='${{ inputs.backends }}' ARGS=(-y --log-file "${LOG_FILE}" --artifacts-dir "${FUNCTIONAL_ARTIFACTS_DIR}/upgrade") + if [ -n "${INPUT_TO_SHA256}" ]; then + ARGS+=(--sha256-to "${INPUT_TO_SHA256}") + fi + if [ "${REQUIRE_UPGRADE_AVAILABILITY}" = true ]; then + ARGS+=(--require-upgrade-availability) + fi if [ "${TOPOLOGY}" = "all" ] || [ -z "${TOPOLOGY}" ] || [ "${TOPOLOGY}" = "null" ]; then ARGS+=(--all-topologies) else @@ -285,6 +301,11 @@ jobs: cat "${MATRIX_TABLE}" echo "" fi + echo "## Sampled install-window I/O" + echo '~~~text' + grep -E '^\[UPG-AVAILABILITY\]' "${LOG_FILE}" || echo "No install-window observations recorded." + echo '~~~' + echo "" if [ -s "${CASE_TABLE}" ]; then cat "${CASE_TABLE}" echo "" diff --git a/README.md b/README.md index 50d3abec..6f1100c8 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,31 @@ per-key failures, request ids, GET results and residue before/after cleanup. Cleanup runs in `finally`; an incomplete cleanup aborts the remaining cases. The caller must hold the environment's test lock throughout this probe. +Set `WARP_BUDGET_FILE` to compare measured throughput and p99 latency against +limits approved for a candidate workload. Supply an entry for each selected +`method/size`. Each entry requires `min_obj_per_s` and the relevant +`max_get_p99_ms` or `max_put_p99_ms`. Mixed rounds require both p99 limits. +Mixed output includes separate GET and PUT p50, p90 and p99. A missing or +exceeded budget fails the affected run. The runner retains the supplied budget +with its artifacts and reuses it for `--parse-only`. An invocation without a +budget reports execution and captures metrics. Run the fleet wrapper +`rustfs_performance_test.sh` with `RUSTFS_WARP_BUDGET_FILE` and a package +SHA-256 to verify every running service before and after measurement. The +performance workflow reads the budget from the `RUSTFS_WARP_BUDGET_JSON` +repository variable and retains both candidate receipts. + +### In-place upgrade observation + +`rustfs-upgrade-test.sh` records sampled baseline reads and write/readbacks +during package installation and service restart in `upgrade-observations.tsv`. +Use `--require-upgrade-availability --sha256-to ` to require successful +samples and compare the binary of each running service with its verified +candidate package. The strict check requires at least two complete samples. Set +`RUSTFS_UPGRADE_PROBE_TIMEOUT_SECONDS` to adjust the per-request deadline +(default 15 seconds). +A pass covers sampled I/O during this installation. Mixed-version compatibility, +uninterrupted availability between samples and rollback need dedicated runs. + ## UploadPart client-read timeout Run the `upload-part-client-read-timeout` case with `python3 scripts/s3_upload_part_timeout.py --rustfs-bin /absolute/path/to/rustfs` with Python 3 and `boto3>=1.36,<2`. The runner starts one RustFS process on loopback with a temporary volume and a two-second request-body idle timeout. A signed UploadPart sends a prefix and keeps the connection open until the server answers HTTP 400 with S3 code `RequestTimeout`. A complete HTTP request carrying fewer S3 bytes than declared must return HTTP 400 with `IncompleteBody`. ListParts checks that the timeout left the slot empty and the short overwrite preserved the retry's ETag and size. Completing the upload and reading the object verifies the retry bytes. diff --git a/rustfs-upgrade-test.sh b/rustfs-upgrade-test.sh index c36b85cf..8b9a953e 100755 --- a/rustfs-upgrade-test.sh +++ b/rustfs-upgrade-test.sh @@ -78,6 +78,10 @@ PACKAGES_DIR="/home/rustfs/packages" PACKAGE_FILE="rustfs.deb" FROM_SHA256="${FROM_SHA256:-}" TO_SHA256="${TO_SHA256:-}" +REQUIRE_UPGRADE_AVAILABILITY=0 +UPGRADE_PROBE_PID="" +UPGRADE_PROBE_STOP="" +UPGRADE_PROBE_TIMEOUT_SECONDS="${RUSTFS_UPGRADE_PROBE_TIMEOUT_SECONDS:-15}" TO_NIGHTLY_URL="${TO_NIGHTLY_URL:-https://dl.rustfs.com/artifacts/rustfs/packages/nightly/rustfs-nightly-latest.deb}" ACCESS_KEY="${RUSTFS_ACCESS_KEY:-rustfs@test}" @@ -634,17 +638,94 @@ env_setup_old() { fi } +monitor_upgrade_io() { + local ledger="$1" stop="$2" fixture="$3" count=0 read_rc write_rc start + local upload="${TEST_TMP}/upgrade-probe-body" download="${TEST_TMP}/upgrade-probe-read" + local request_timeout="${UPGRADE_PROBE_TIMEOUT_SECONDS:-15}" + local -a command=(aws --endpoint-url "${ENDPOINT}" --region "${REGION}" s3api) + while [ ! -e "${stop}" ]; do + count=$((count + 1)) + start="$(date -u +%Y-%m-%dT%H:%M:%SZ)" + read_rc=0 write_rc=0 + rm -f "${download}" || return 1 + AWS_MAX_ATTEMPTS=1 timeout --kill-after=2 "${request_timeout}" "${command[@]}" get-object \ + --bucket upg-plain --key plain "${download}" >/dev/null 2>&1 || read_rc=$? + if [ "${read_rc}" -eq 0 ] && ! cmp -s "${fixture}" "${download}"; then read_rc=1; fi + + printf 'upgrade observation %d\n' "${count}" > "${upload}" || return 1 + AWS_MAX_ATTEMPTS=1 timeout --kill-after=2 "${request_timeout}" "${command[@]}" put-object \ + --bucket upg-plain --key upgrade-probe --body "${upload}" >/dev/null 2>&1 || write_rc=$? + if [ "${write_rc}" -eq 0 ]; then + rm -f "${download}" || return 1 + AWS_MAX_ATTEMPTS=1 timeout --kill-after=2 "${request_timeout}" "${command[@]}" get-object \ + --bucket upg-plain --key upgrade-probe "${download}" >/dev/null 2>&1 || write_rc=$? + if [ "${write_rc}" -eq 0 ] && ! cmp -s "${upload}" "${download}"; then write_rc=1; fi + fi + printf '%s\t%s\t%d\t%d\t%d\n' "${start}" "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \ + "${count}" "${read_rc}" "${write_rc}" >> "${ledger}" || return 1 + [ -e "${stop}" ] || sleep 1 + done +} + +stop_upgrade_observation() { + [ -n "${UPGRADE_PROBE_PID}" ] || return 0 + touch "${UPGRADE_PROBE_STOP}" || { + kill "${UPGRADE_PROBE_PID}" 2>/dev/null || true + } + local result=0 + wait "${UPGRADE_PROBE_PID}" || result=$? + UPGRADE_PROBE_PID="" + return "${result}" +} + +upgrade_observation_status() { + awk -F '\t' ' + NR == 1 { next } + NF != 5 || $3 != NR - 1 || $4 != "0" || $5 != "0" { failed = 1 } + END { print failed ? "FAIL" : (NR < 3 ? "UNVERIFIED" : "SAMPLED") } + ' "$1" +} + upgrade_in_place() { local topo="$1" read -r -a nodes <<<"$(topology_nodes "${topo}")" local to_url to_url="$(resolve_to_url)" log "upgrading in place to ${to_url} on ${nodes[*]} (keeping /data and ${RUSTFS_CONFIG_FILE})" + local ledger="${GROUP_DIR}/upgrade-observations.tsv" node coverage=UNVERIFIED + printf 'start_utc\tfinish_utc\tsample\tbaseline_read_exit\twrite_and_readback_exit\n' > "${ledger}" + UPGRADE_PROBE_STOP="${TEST_TMP}/upgrade-probe-stop" + rm -f "${UPGRADE_PROBE_STOP}" + monitor_upgrade_io "${ledger}" "${UPGRADE_PROBE_STOP}" "${TEST_TMP}/plain.bin" & + UPGRADE_PROBE_PID=$! install_deb_on_nodes "${to_url}" "${TO_SHA256}" "${nodes[@]}" # dpkg postinst usually restarts the service; make sure it is up and healthy. start_and_wait_nodes "${nodes[@]}" wait_cluster_ready "${nodes[@]}" || die "NEW cluster ${ENDPOINT} not ready after upgrade" + if stop_upgrade_observation; then + coverage="$(upgrade_observation_status "${ledger}")" + fi + aws_run s3api delete-object --bucket upg-plain --key upgrade-probe + assert_aws_ok "cleanup upgrade observation object" || die "could not clean up upgrade observation" + if [ "${REQUIRE_UPGRADE_AVAILABILITY}" -eq 1 ]; then + source "${SCRIPT_DIR}/scripts/lib/package_candidate.sh" + printf 'node\texpected_package_sha256\trunning_binary_sha256\tservice_pid\n' > "${GROUP_DIR}/upgrade-candidate.tsv" + for node in "${nodes[@]}"; do + if ! verify_running_package_candidate "${node}" "${PACKAGES_DIR}/${PACKAGE_FILE}" "${TO_SHA256}" >> "${GROUP_DIR}/upgrade-candidate.tsv"; then + evidence_line "[UPG-AVAILABILITY] ${topo} ${KMS_BACKEND} UNVERIFIED running candidate on ${node}" + die "running candidate binary not verified on ${node}" + fi + done + if [ "${coverage}" != SAMPLED ]; then + evidence_line "[UPG-AVAILABILITY] ${topo} ${KMS_BACKEND} ${coverage} see upgrade-observations.tsv" + die "upgrade did not pass the sampled read/write check" + fi + evidence_line "[UPG-AVAILABILITY] ${topo} ${KMS_BACKEND} PASS sampled install-window I/O; running candidate verified" + else + evidence_line "[UPG-AVAILABILITY] ${topo} ${KMS_BACKEND} ${coverage} see upgrade-observations.tsv" + fi + NEW_VERSION_ACTUAL="$(node_rustfs_version "${nodes[0]}")" log "NEW version in place: ${NEW_VERSION_ACTUAL}" if [ "${OLD_VERSION_ACTUAL}" = "${NEW_VERSION_ACTUAL}" ]; then @@ -770,6 +851,7 @@ upgrade_exit() { local rc="$1" index group topo backend trap - EXIT INT TERM set +e + stop_upgrade_observation || rc=1 if [ "${ARTIFACTS_READY}" -eq 1 ]; then if [ "${GROUP_ACTIVE}" -eq 1 ]; then if [ "${rc}" -eq 130 ] || [ "${rc}" -eq 143 ]; then CURRENT_RESULT=INTERRUPTED; fi @@ -977,7 +1059,6 @@ make_test_file() { if [ "${size}" -eq 0 ]; then : > "${path}"; else head -c "${size}" /dev/urandom > "${path}"; fi } -md5_of_file() { md5sum "$1" 2>/dev/null | awk '{print $1}'; } golden_set() { # golden_set KEY VALUE @@ -1282,7 +1363,7 @@ run_test() { verify_plain() { aws_run s3api get-object --bucket upg-plain --key plain "${TEST_TMP}/plain-dl.bin" assert_aws_ok || return 1 - [ "$(md5_of_file "${TEST_TMP}/plain-dl.bin")" = "$(md5_of_file "${TEST_TMP}/plain.bin")" ] || { echo "plain object mismatch after upgrade"; return 1; } + cmp -s "${TEST_TMP}/plain-dl.bin" "${TEST_TMP}/plain.bin" || { echo "plain object mismatch after upgrade"; return 1; } } verify_versioned() { @@ -1291,22 +1372,22 @@ verify_versioned() { vid1="${versions%%|*}"; vid2="${versions#*|}" aws_run s3api get-object --bucket upg-versioned --key obj --version-id "${vid1}" "${TEST_TMP}/v1-dl.bin" assert_aws_ok || return 1 - [ "$(md5_of_file "${TEST_TMP}/v1-dl.bin")" = "$(md5_of_file "${TEST_TMP}/v1.bin")" ] || { echo "version v1 mismatch"; return 1; } + cmp -s "${TEST_TMP}/v1-dl.bin" "${TEST_TMP}/v1.bin" || { echo "version v1 mismatch"; return 1; } aws_run s3api get-object --bucket upg-versioned --key obj --version-id "${vid2}" "${TEST_TMP}/v2-dl.bin" assert_aws_ok || return 1 - [ "$(md5_of_file "${TEST_TMP}/v2-dl.bin")" = "$(md5_of_file "${TEST_TMP}/v2.bin")" ] || { echo "version v2 mismatch"; return 1; } + cmp -s "${TEST_TMP}/v2-dl.bin" "${TEST_TMP}/v2.bin" || { echo "version v2 mismatch"; return 1; } } verify_multipart() { aws_run s3api get-object --bucket upg-mp --key mp "${TEST_TMP}/mp-dl.bin" assert_aws_ok || return 1 - [ "$(md5_of_file "${TEST_TMP}/mp-dl.bin")" = "$(md5_of_file "${TEST_TMP}/mp.bin")" ] || { echo "multipart object mismatch"; return 1; } + cmp -s "${TEST_TMP}/mp-dl.bin" "${TEST_TMP}/mp.bin" || { echo "multipart object mismatch"; return 1; } } verify_large() { aws_run s3api get-object --bucket upg-large --key large "${TEST_TMP}/large-dl.bin" assert_aws_ok || return 1 - [ "$(md5_of_file "${TEST_TMP}/large-dl.bin")" = "$(md5_of_file "${TEST_TMP}/large.bin")" ] || { echo "large object mismatch"; return 1; } + cmp -s "${TEST_TMP}/large-dl.bin" "${TEST_TMP}/large.bin" || { echo "large object mismatch"; return 1; } } verify_sse_s3() { @@ -1315,7 +1396,7 @@ verify_sse_s3() { printf '%s' "${AWS_OUT}" | grep -q '"ServerSideEncryption": "AES256"' || { echo "SSE-S3 header lost: ${AWS_OUT}"; return 1; } aws_run s3api get-object --bucket upg-sse --key sse3 "${TEST_TMP}/sse3-dl.bin" assert_aws_ok || return 1 - [ "$(md5_of_file "${TEST_TMP}/sse3-dl.bin")" = "$(md5_of_file "${TEST_TMP}/sse3.bin")" ] || { echo "SSE-S3 object mismatch"; return 1; } + cmp -s "${TEST_TMP}/sse3-dl.bin" "${TEST_TMP}/sse3.bin" || { echo "SSE-S3 object mismatch"; return 1; } } verify_sse_kms() { @@ -1323,7 +1404,7 @@ verify_sse_kms() { kid="$(golden_get "kms:upg-key")" aws_run s3api get-object --bucket upg-kms --key ssek "${TEST_TMP}/ssek-dl.bin" assert_aws_ok || return 1 - [ "$(md5_of_file "${TEST_TMP}/ssek-dl.bin")" = "$(md5_of_file "${TEST_TMP}/ssek.bin")" ] || { echo "SSE-KMS object mismatch"; return 1; } + cmp -s "${TEST_TMP}/ssek-dl.bin" "${TEST_TMP}/ssek.bin" || { echo "SSE-KMS object mismatch"; return 1; } # key still usable for new writes after upgrade. aws_run s3api put-object --bucket upg-kms --key new --body "${TEST_TMP}/ssek.bin" \ --server-side-encryption aws:kms --ssekms-key-id "${kid}" @@ -1333,7 +1414,7 @@ verify_sse_kms() { verify_context() { aws_run s3api get-object --bucket upg-ctx --key ctx "${TEST_TMP}/ctx-dl.bin" assert_aws_ok || return 1 - [ "$(md5_of_file "${TEST_TMP}/ctx-dl.bin")" = "$(md5_of_file "${TEST_TMP}/ssek.bin")" ] || { echo "context object mismatch"; return 1; } + cmp -s "${TEST_TMP}/ctx-dl.bin" "${TEST_TMP}/ssek.bin" || { echo "context object mismatch"; return 1; } } verify_identity_user() { @@ -1413,7 +1494,7 @@ verify_smoke_crud() { assert_aws_ok || { echo "post-upgrade put failed"; rm_bucket upg-smoke; return 1; } aws_run s3api get-object --bucket upg-smoke --key hello.txt "${TEST_TMP}/smoke-dl.bin" assert_aws_ok || { echo "post-upgrade get failed"; rm_bucket upg-smoke; return 1; } - [ "$(md5_of_file "${TEST_TMP}/smoke-dl.bin")" = "$(md5_of_file "${TEST_TMP}/plain.bin")" ] || { echo "post-upgrade CRUD mismatch"; rm_bucket upg-smoke; return 1; } + cmp -s "${TEST_TMP}/smoke-dl.bin" "${TEST_TMP}/plain.bin" || { echo "post-upgrade CRUD mismatch"; rm_bucket upg-smoke; return 1; } rm_bucket upg-smoke } @@ -1588,6 +1669,7 @@ Usage: (default: local,vault-kv2) --from-version OLD RustFS release tag (default: 1.0.0-rc.3; must ship a .deb asset) --from-url OLD .deb URL (overrides --from-version) + --require-upgrade-availability Fail on missed/failed install-window reads or writes; requires --sha256-to. --to-version NEW RustFS release tag (overrides --to-url default) --to-url NEW .deb URL (default: latest nightly deb) --sha256-from Verify OLD .deb checksum @@ -1617,6 +1699,7 @@ main() { --to-url) TO_URL="$1"; shift ;; --sha256-from) FROM_SHA256="$1"; shift ;; --sha256-to) TO_SHA256="$1"; shift ;; + --require-upgrade-availability) REQUIRE_UPGRADE_AVAILABILITY=1 ;; --keep-env) KEEP_ENV=1 ;; --ssh-user) SSH_USER="$1"; shift ;; --log-file) LOG_FILE="$1"; shift ;; @@ -1695,6 +1778,12 @@ main() { evidence_line "[UPG-PLAN-END] ${#UPGRADE_GROUPS[@]}" fi + [[ "${UPGRADE_PROBE_TIMEOUT_SECONDS}" =~ ^[1-9][0-9]*$ ]] \ + || die "RUSTFS_UPGRADE_PROBE_TIMEOUT_SECONDS must be a positive integer" + if [ "${REQUIRE_UPGRADE_AVAILABILITY}" -eq 1 ] && ! [[ "${TO_SHA256}" =~ ^[0-9A-Fa-f]{64}$ ]]; then + die "--require-upgrade-availability requires a candidate package SHA-256 (--sha256-to)" + fi + local _p for _p in /root/.local/bin /home/*/.local/bin /usr/local/bin; do if [ -d "${_p}" ] && [[ ":${PATH}:" != *":${_p}:"* ]]; then PATH="${_p}:${PATH}"; fi @@ -1703,6 +1792,7 @@ main() { need_cmd ssh "SSH client" need_cmd rc "RustFS client CLI" need_cmd aws "AWS CLI (s3api channel)" + need_cmd cmp "byte comparison" need_cmd warp "warp benchmark tool (mixed-size data seeding)" need_cmd jq "JSON processor" need_cmd curl "HTTP client" diff --git a/rustfs_performance_test.sh b/rustfs_performance_test.sh index 0e6b5e30..9e10feda 100755 --- a/rustfs_performance_test.sh +++ b/rustfs_performance_test.sh @@ -57,7 +57,7 @@ PACKAGE_URL="${RUSTFS_PACKAGE_URL:-}" ARCH="${RUSTFS_ARCH:-amd64}" PACKAGES_DIR="/home/rustfs/packages" PACKAGE_FILE="rustfs.deb" -PACKAGE_SHA256="${RUSTFS_PACKAGE_SHA256:-}" +PACKAGE_SHA256="${RUSTFS_PACKAGE_SHA256:-${PACKAGE_SHA256:-}}" # 4x4 topology: 4 nodes x 4 drives each, same expression on every node DRIVES_PER_NODE="${RUSTFS_DRIVES_PER_NODE:-4}" @@ -98,6 +98,7 @@ WARP_HOST="${RUSTFS_WARP_HOST:-rustfs-node1:9000,rustfs-node2:9000,rustfs-node3: WARP_BUCKET="${RUSTFS_WARP_BUCKET:-warp-benchmark-bucket}" WARP_CLEANUP_TIMEOUT="${RUSTFS_WARP_CLEANUP_TIMEOUT:-180}" WARP_CLEANUP_ATTEMPTS="${RUSTFS_WARP_CLEANUP_ATTEMPTS:-3}" +WARP_BUDGET_FILE="${RUSTFS_WARP_BUDGET_FILE:-${WARP_BUDGET_FILE:-}}" WARP_CONCURRENCY="${RUSTFS_WARP_CONCURRENCY:-64}" WARP_DURATION="${RUSTFS_WARP_DURATION:-5m}" WARP_GET_OBJECTS="${RUSTFS_WARP_GET_OBJECTS:-2500}" @@ -473,6 +474,15 @@ step4_configure_start() { log "step 4 complete" } +record_performance_candidate() { + local path="$1" node + printf 'node\texpected_package_sha256\trunning_binary_sha256\tservice_pid\n' > "${path}" + for node in "${NODES[@]}"; do + verify_running_package_candidate "${node}" "${PACKAGES_DIR}/${PACKAGE_FILE}" "${PACKAGE_SHA256}" \ + >> "${path}" || die "benchmark candidate could not be verified on ${node}" + done +} + step5_benchmark() { log "step 5: run the benchmark (${BENCH_SCRIPT})" need_cmd warp "warp benchmark tool" @@ -481,6 +491,16 @@ step5_benchmark() { log "DRY-RUN: WARP_HOST=${WARP_HOST} WARP_RESULT_DIR=${RESULT_DIR} bash ${BENCH_SCRIPT}" return 0 fi + local benchmark_rc=0 + if [ -n "${WARP_BUDGET_FILE}" ]; then + [[ "${PACKAGE_SHA256}" =~ ^[0-9A-Fa-f]{64}$ ]] || die "a performance budget requires the candidate package SHA-256" + [[ "${BENCH_SCRIPT}" -ef "${_SCRIPT_DIR}/rustfs_performance_testing.sh" ]] \ + || die "a performance budget requires the repository benchmark script" + source "${_SCRIPT_DIR}/scripts/lib/package_candidate.sh" + [ ! -e "${RESULT_DIR}/master.log" ] || die "performance budget requires a fresh result directory" + mkdir -p "${RESULT_DIR}" + record_performance_candidate "${RESULT_DIR}/candidate-before.tsv" + fi WARP_HOST="${WARP_HOST}" \ WARP_ACCESS_KEY="${ACCESS_KEY}" \ WARP_SECRET_KEY="${SECRET_KEY}" \ @@ -492,11 +512,19 @@ step5_benchmark() { WARP_ROUND_TIMEOUT="${WARP_ROUND_TIMEOUT}" \ WARP_MAX_CONSECUTIVE_FAILURES="${WARP_MAX_CONSECUTIVE_FAILURES}" \ WARP_CLEANUP_TIMEOUT="${WARP_CLEANUP_TIMEOUT}" \ + WARP_BUDGET_FILE="${WARP_BUDGET_FILE}" \ WARP_CLEANUP_ATTEMPTS="${WARP_CLEANUP_ATTEMPTS}" \ WARP_METHODS="${WARP_METHODS}" \ WARP_SIZES="${WARP_SIZES}" \ WARP_RESULT_DIR="${RESULT_DIR}" \ - bash "${BENCH_SCRIPT}" + bash "${BENCH_SCRIPT}" || benchmark_rc=$? + if [ -n "${WARP_BUDGET_FILE}" ]; then + record_performance_candidate "${RESULT_DIR}/candidate-after.tsv" + cmp -s "${RESULT_DIR}/candidate-before.tsv" "${RESULT_DIR}/candidate-after.tsv" \ + || die "running candidate changed during the benchmark" + log "candidate package, running binaries and service processes match before and after the benchmark" + fi + [ "${benchmark_rc}" -eq 0 ] || return "${benchmark_rc}" log "step 5 complete (results in ${RESULT_DIR})" } diff --git a/rustfs_performance_testing.sh b/rustfs_performance_testing.sh index 1dae7d4f..aafeac5d 100755 --- a/rustfs_performance_testing.sh +++ b/rustfs_performance_testing.sh @@ -40,6 +40,8 @@ CLEANUP_ATTEMPTS="${WARP_CLEANUP_ATTEMPTS:-3}" RESULT_DIR="${WARP_RESULT_DIR:-$(pwd)/warp-bench-results-$(date +%Y%m%d-%H%M%S)}" SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" S3_HELPER="${SCRIPT_DIR}/scripts/performance_s3.py" +BUDGET_HELPER="${SCRIPT_DIR}/scripts/performance_budget.py" +BUDGET_FILE="${WARP_BUDGET_FILE:-}" S3_ENDPOINT="${HOST%%,*}" [[ "${S3_ENDPOINT}" == *://* ]] || S3_ENDPOINT="http://${S3_ENDPOINT}" export WARP_ACCESS_KEY="${ACCESS_KEY}" WARP_SECRET_KEY="${SECRET_KEY}" @@ -71,6 +73,9 @@ fi if [[ "${1:-}" == "--parse-only" ]]; then # Reanalysis must not rewrite the execution's abort states, timings or reports. OUTPUT_TAG=".reparsed" + if [[ -z "${BUDGET_FILE}" && -f "${RESULT_DIR}/performance-budget.json" ]]; then + BUDGET_FILE="${RESULT_DIR}/performance-budget.json" + fi fi LOG_FILE="${RESULT_DIR}/master${OUTPUT_TAG}.log" @@ -196,27 +201,34 @@ parse_round() { return 1 fi fi - local line + local line objects get_p99="" put_p99="" if [[ "${method}" == "mixed" ]]; then local total get put total=$(section_lines "$file" Total) get=$(section_lines "$file" GET) put=$(section_lines "$file" PUT) - line=$(printf 'mixed\t%s\t%s\t%s\t%s\t%s' \ - "$size" \ - "$(field "${total}" tp)" \ - "$(field "${total}" objs)" \ - "$(field "${get}" avg)" \ - "$(field "${put}" avg)") + objects=$(field "${total}" objs) + get_p99=$(field "${get}" p99) + put_p99=$(field "${put}" p99) + line=$(printf 'mixed\t%s\t%s\t%s\t%s\t%s\t\t\t\t\t\t%s\t%s\t%s\t%s\t%s\t%s' \ + "$size" "$(field "${total}" tp)" "${objects}" "$(field "${get}" avg)" "$(field "${put}" avg)" \ + "$(field "${get}" p50)" "$(field "${get}" p90)" "${get_p99}" \ + "$(field "${put}" p50)" "$(field "${put}" p90)" "${put_p99}") else local sec sec=$(printf '%s' "${method}" | tr '[:lower:]' '[:upper:]') local stats stats=$(section_lines "$file" "${sec}") + objects=$(field "${stats}" objs) + if [[ "${method}" == get ]]; then + get_p99=$(field "${stats}" p99) + else + put_p99=$(field "${stats}" p99) + fi line=$(printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s' \ "${method}" "${size}" \ "$(field "${stats}" tp)" \ - "$(field "${stats}" objs)" \ + "${objects}" \ "$(field "${stats}" avg)" \ "$(field "${stats}" p50)" \ "$(field "${stats}" p90)" \ @@ -224,16 +236,24 @@ parse_round() { "$(field "${stats}" ttfb_avg)" \ "$(field "${stats}" ttfb_p99)" \ "$(field "${stats}" ttfb_worst)") + line+=$'\t\t\t\t\t\t' fi # TTFB is optional in warp; throughput and request statistics define a result. if ! printf '%s\n' "${line}" | awk -F '\t' ' { last = $1 == "mixed" ? 6 : 8 - for (i = 3; i <= last; i++) if ($i !~ /[^[:space:]]/) exit 1 } + for (i = 3; i <= last; i++) if ($i !~ /[^[:space:]]/) exit 1 + if ($1 == "mixed") for (i = 12; i <= 17; i++) if ($i !~ /[^[:space:]]/) exit 1 } '; then PARSE_FAILURE_REASON=missing_required_metrics log "PARSE_FAILED method=${method} size=${size} reason=missing_required_metrics file=${file}" return 1 fi + if [[ -n "${BUDGET_FILE}" ]] && ! python3 "${BUDGET_HELPER}" check "${BUDGET_FILE}" \ + "${method}/${size}" "${objects}" "${get_p99}" "${put_p99}" >> "${LOG_FILE}" 2>&1; then + PARSE_FAILURE_REASON=performance_budget_failed + log "PARSE_FAILED method=${method} size=${size} reason=${PARSE_FAILURE_REASON}; see ${LOG_FILE}" + return 1 + fi printf '%s\n' "${line}" >> "${SUMMARY_TSV}" } @@ -247,6 +267,11 @@ gen_summary_md() { echo "- Concurrency: ${CONCURRENCY}; duration: ${DURATION}; sleep: ${SLEEP_BETWEEN_ROUNDS}s; GET objects: ${GET_OBJECTS}" echo "- Methods: ${METHODS[*]-}; sizes: ${SIZES[*]-}" echo "- Rounds: selected=${TOTAL_ROUNDS}; parsed=${PARSED_ROUNDS}; failed=${FAILED_ROUNDS}" + if [[ -n "${BUDGET_FILE}" ]]; then + echo "- Candidate budget: $(basename "${BUDGET_FILE}"); see master log and round verdicts." + else + echo "- Candidate budget: not configured; results certify execution and metric capture." + fi if [[ -n "${OUTPUT_TAG}" ]]; then echo "- Reparsed raw outputs: elapsed time is unknown; configuration above is from this parser invocation. See the original rounds.tsv, master.log and summary files for execution evidence." fi @@ -279,13 +304,13 @@ gen_summary_md() { { echo "## MIXED Results (Total)" echo "" - echo "| Object Size | Total Avg Throughput | Total Avg obj/s | MIXED GET Avg | MIXED PUT Avg |" - echo "|-------------|----------------------|-----------------|---------------|---------------|" + echo "| Object Size | Total Avg Throughput | Total Avg obj/s | GET Avg | PUT Avg | GET P50 | GET P90 | GET P99 | PUT P50 | PUT P90 | PUT P99 |" + echo "|-------------|----------------------|-----------------|---------|---------|---------|---------|---------|---------|---------|---------|" } >> "${SUMMARY_MD}" - while IFS=$'\t' read -r method size tp objs gavg pavg rest; do - [[ "${method}" == "mixed" ]] && \ - echo "| ${size} | ${tp} | ${objs} | ${gavg} | ${pavg} |" >> "${SUMMARY_MD}" - done < "${SUMMARY_TSV}" + awk -F '\t' '$1 == "mixed" { + printf "| %s | %s | %s | %s | %s | %s | %s | %s | %s | %s | %s |\n", + $2, $3, $4, $5, $6, $12, $13, $14, $15, $16, $17 + }' "${SUMMARY_TSV}" >> "${SUMMARY_MD}" echo "" >> "${SUMMARY_MD}" } @@ -293,7 +318,7 @@ gen_summary_md() { mkdir -p "${RESULT_DIR}" || exit 1 log "CONFIG host=${HOST} bucket=${BUCKET} concurrency=${CONCURRENCY} duration=${DURATION} get_objects=${GET_OBJECTS} sleep_between_rounds=${SLEEP_BETWEEN_ROUNDS}s" || exit 1 -printf 'method\tsize\tthroughput\tobj_per_s\treq_avg\treq_p50\treq_p90\treq_p99\tttfb_avg\tttfb_p99\tttfb_worst\n' > "${SUMMARY_TSV}" || exit 1 +printf 'method\tsize\tthroughput\tobj_per_s\treq_avg\treq_p50\treq_p90\treq_p99\tttfb_avg\tttfb_p99\tttfb_worst\tmixed_get_p50\tmixed_get_p90\tmixed_get_p99\tmixed_put_p50\tmixed_put_p90\tmixed_put_p99\n' > "${SUMMARY_TSV}" || exit 1 printf 'method\tsize\tverdict\treason\twarp_exit\tcapture_exit\telapsed_seconds\treport_present\terror_lines\tbucket\tprepare\tcleanup\tcleanup_error_entries\tremaining_objects\tcleanup_http_503_attempts\tcleanup_request_failures\tcleanup_had_errors\n' > "${ROUNDS_TSV}" || exit 1 if [[ ${TOTAL_ROUNDS} -eq 0 ]]; then @@ -302,6 +327,21 @@ if [[ ${TOTAL_ROUNDS} -eq 0 ]]; then exit 1 fi +if [[ -n "${BUDGET_FILE}" ]]; then + budgets=() + for method in "${METHODS[@]}"; do + for size in "${SIZES[@]}"; do + budgets+=("${method}/${size}") + done + done + python3 "${BUDGET_HELPER}" validate "${BUDGET_FILE}" "${budgets[@]}" || exit 1 + retained_budget="${RESULT_DIR}/performance-budget${OUTPUT_TAG}.json" + if [[ ! "${BUDGET_FILE}" -ef "${retained_budget}" ]]; then + cp "${BUDGET_FILE}" "${retained_budget}" || exit 1 + fi + BUDGET_FILE="${retained_budget}" +fi + if [[ "${1:-}" == "--parse-only" ]]; then for method in "${METHODS[@]}"; do for size in "${SIZES[@]}"; do diff --git a/scripts/lib/package_candidate.sh b/scripts/lib/package_candidate.sh new file mode 100644 index 00000000..d5b04c29 --- /dev/null +++ b/scripts/lib/package_candidate.sh @@ -0,0 +1,23 @@ +# Verify the running systemd service against an explicitly identified Debian package. +# Caller provides run_remote for access to the owned fleet. +verify_running_package_candidate() { + local node="$1" package="$2" expected_sha="$3" receipt binary_sha pid + [[ "${expected_sha}" =~ ^[0-9A-Fa-f]{64}$ ]] || return 1 + receipt="$({ + printf 'set -euo pipefail\n' + printf 'SUDO=""; [ "$(id -u)" -eq 0 ] || SUDO="sudo -n"\n' + printf 'pkg="%s"\n' "${package}" + printf 'printf "%%s %%s\\n" "%s" "$pkg" | sha256sum --check --status\n' "${expected_sha,,}" + cat <<'REMOTE' +candidate="$(dpkg-deb --fsys-tarfile "$pkg" | tar -xOf - ./usr/bin/rustfs | sha256sum)" +pid="$(systemctl show --property=MainPID --value rustfs)" +[[ "$pid" =~ ^[1-9][0-9]*$ ]] +running="$(${SUDO} sha256sum "/proc/${pid}/exe")" +[[ "${candidate%% *}" == "${running%% *}" ]] +printf '%s\t%s\n' "${running%% *}" "${pid}" +REMOTE + } | run_remote "${node}")" || return 1 + IFS=$'\t' read -r binary_sha pid <<< "${receipt}" + [[ "${binary_sha}" =~ ^[0-9a-f]{64}$ && "${pid}" =~ ^[1-9][0-9]*$ ]] || return 1 + printf '%s\t%s\t%s\t%s\n' "${node}" "${expected_sha,,}" "${binary_sha}" "${pid}" +} diff --git a/scripts/performance_budget.py b/scripts/performance_budget.py new file mode 100644 index 00000000..493cddd4 --- /dev/null +++ b/scripts/performance_budget.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python3 +"""Check measured Warp rates and tail latencies against an operator's budget.""" +import argparse +import json +import math +import re +from pathlib import Path + +UNITS_MS = {"ns": 1e-6, "us": 1e-3, "µs": 1e-3, "μs": 1e-3, + "ms": 1, "s": 1000, "m": 60_000, "h": 3_600_000} +DURATION_PART = re.compile(r"([0-9]+(?:\.[0-9]+)?)(ns|us|µs|μs|ms|s|m|h)") +LATENCY_FIELDS = {"get": ("max_get_p99_ms",), "put": ("max_put_p99_ms",), + "mixed": ("max_get_p99_ms", "max_put_p99_ms")} + + +def duration_ms(value): + parts = DURATION_PART.findall(value) + if not parts or "".join(number + unit for number, unit in parts) != value: + raise ValueError(f"invalid Warp duration: {value!r}") + return sum(float(number) * UNITS_MS[unit] for number, unit in parts) + + +def limits_for(budgets, round_id): + method, _, _ = round_id.partition("/") + if method not in LATENCY_FIELDS: + raise ValueError(f"unsupported budget round: {round_id}") + fields = ("min_obj_per_s", *LATENCY_FIELDS[method]) + limits = budgets.get(round_id) + if not isinstance(limits, dict) or set(limits) != set(fields): + raise ValueError(f"{round_id} budget requires {', '.join(fields)}") + for field, value in limits.items(): + if type(value) not in (float, int) or not math.isfinite(value) or value <= 0: + raise ValueError(f"{round_id} {field} must be a finite positive number") + return limits + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("command", choices=("validate", "check")) + parser.add_argument("budget", type=Path) + parser.add_argument("values", nargs="+") + args = parser.parse_args() + try: + budgets = json.loads(args.budget.read_text(encoding="utf-8")) + if not isinstance(budgets, dict): + raise ValueError("budget must be an object keyed by method/size") + if args.command == "validate": + for round_id in args.values: + limits_for(budgets, round_id) + return 0 + round_id, rate, get_p99, put_p99 = args.values + limits = limits_for(budgets, round_id) + measured_rate = float(rate) + if not math.isfinite(measured_rate) or measured_rate < limits["min_obj_per_s"]: + raise ValueError(f"{round_id} throughput {rate} obj/s below {limits['min_obj_per_s']} obj/s") + for field, measurement in (("max_get_p99_ms", get_p99), ("max_put_p99_ms", put_p99)): + if field in limits: + latency = duration_ms(measurement) + if latency > limits[field]: + raise ValueError(f"{round_id} {field}: measured {latency:g} ms exceeds {limits[field]} ms") + return 0 + except (OSError, ValueError, OverflowError) as exc: + parser.exit(1, f"performance budget: {exc}\n") + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/test_rustfs_performance_testing.py b/test_rustfs_performance_testing.py index 656a9b52..1407bdb4 100644 --- a/test_rustfs_performance_testing.py +++ b/test_rustfs_performance_testing.py @@ -138,6 +138,35 @@ def test_success_keeps_selected_matrix_and_optional_ttfb(self): for row in self.round_evidence())) self.assertNotIn("test-secret", "".join(path.read_text() for path in self.results.iterdir())) + def test_mixed_percentiles_and_an_explicit_budget_gate(self): + budget = self.root / "budget.json" + scope = dict(WARP_METHODS="mixed", WARP_SIZES="1KiB", WARP_BUDGET_FILE=str(budget)) + for rate, latency, accepted in ((1280, 2.1, True), (1281, 2.1, False), (1280, 2.0, False)): + with self.subTest(rate=rate, latency=latency): + budget.write_text(json.dumps({"mixed/1KiB": { + "min_obj_per_s": rate, "max_get_p99_ms": latency, "max_put_p99_ms": 2.1, + }})) + result, rows = self.run_benchmark(**scope) + self.assertEqual(result.returncode == 0, accepted, result.stdout + result.stderr) + self.assertEqual((self.results / "performance-budget.json").read_text(), budget.read_text()) + if accepted: + self.assertEqual(rows[0]["mixed_get_p50"], "1.1ms") + self.assertEqual(rows[0]["mixed_get_p99"], "2.1ms") + self.assertEqual(rows[0]["mixed_put_p90"], "1.5ms") + self.assertEqual(rows[0]["mixed_put_p99"], "2.1ms") + else: + self.assertEqual(rows, []) + self.assertEqual(self.round_evidence()[0]["reason"], "performance_budget_failed") + + def test_missing_budget_for_selected_round_fails_before_warp(self): + budget = self.root / "missing-budget.json" + budget.write_text("{}") + result, rows = self.run_benchmark(WARP_METHODS="mixed", WARP_SIZES="1KiB", WARP_BUDGET_FILE=str(budget)) + self.assertNotEqual(result.returncode, 0) + self.assertFalse(self.calls.exists()) + self.assertEqual(rows, []) + self.assertIn("mixed/1KiB budget requires", result.stderr) + def test_all_failed_rounds_return_failure_after_collecting_every_round(self): result, rows = self.run_benchmark("fail") self.assertNotEqual(result.returncode, 0) diff --git a/test_rustfs_upgrade.py b/test_rustfs_upgrade.py index 545850ba..53886259 100644 --- a/test_rustfs_upgrade.py +++ b/test_rustfs_upgrade.py @@ -117,6 +117,94 @@ def test_large_seed_is_bounded_and_does_not_call_warp_or_delete(self): self.assertIn("warp:upg-warp-100mib 2", calls) self.assertNotIn("delete-objects", calls) + def test_install_window_io_requires_successful_reads_and_write_readbacks(self): + harness = r""" +set -Eeuo pipefail +TEST_TMP="$TEST_DIRECTORY" +ENDPOINT=http://localhost:1 +REGION=us-east-1 +printf baseline > "$TEST_TMP/source" +printf 'header\n' > "$TEST_TMP/ledger" +timeout() { + shift 2 + "$@" +} +aws() { + test "$AWS_MAX_ATTEMPTS" = 1 || return 99 + case "$6:${10}" in + get-object:*) + case "${10}" in + plain) cp "$TEST_TMP/source" "${11}" ;; + upgrade-probe) + cp "$TEST_TMP/fake-object" "${11}" + if [ "$MODE" = corrupt ]; then printf corrupt > "${11}"; fi + ;; + esac + ;; + put-object:*) + [ "$MODE" != unavailable ] || return 124 + cp "${12}" "$TEST_TMP/fake-object" + ;; + *) return 92 ;; + esac +} +sleep() { + if [ "$(awk 'END {print NR}' "$TEST_TMP/ledger")" -ge "$STOP_AT" ]; then touch "$TEST_TMP/stop"; fi +} +monitor_upgrade_io "$TEST_TMP/ledger" "$TEST_TMP/stop" "$TEST_TMP/source" +upgrade_observation_status "$TEST_TMP/ledger" +""" + functions = function("monitor_upgrade_io") + "\n" + function("upgrade_observation_status") + for mode, stop, verdict in (("ok", "3", "SAMPLED"), ("corrupt", "3", "FAIL"), + ("unavailable", "3", "FAIL"), ("ok", "2", "UNVERIFIED")): + with self.subTest(mode=mode, stop=stop): + (self.directory / "stop").unlink(missing_ok=True) + result = self.bash(functions + "\n" + harness, TEST_DIRECTORY=str(self.directory), + MODE=mode, STOP_AT=stop) + self.assertEqual(result.returncode, 0, result.stderr) + self.assertEqual(result.stdout.strip(), verdict) + self.assertEqual(len((self.directory / "ledger").read_text().splitlines()), int(stop)) + + def test_running_package_gate_requires_the_verified_package_and_service_process(self): + harness = r""" +set -Eeuo pipefail +source "$HELPER" +id() { echo 0; } +dpkg-deb() { printf package-binary; } +tar() { cat; } +systemctl() { + if [ "$MODE" = stopped ]; then echo 0; else echo 42; fi +} +sha256sum() { + case "${1:-}" in + --check) + read -r hash _ || return 1 + [ "$MODE" != wrong-package ] && [ "$hash" = "$PACKAGE_DIGEST" ] + ;; + /proc/42/exe) + if [ "$MODE" = wrong-process ]; then + printf '%064d -\\n' 1 + else + printf '%064d -\\n' 2 + fi + ;; + "") cat >/dev/null; printf '%064d -\\n' 2 ;; + *) return 99 ;; + esac +} +export -f id dpkg-deb tar systemctl sha256sum +run_remote() { bash -s; } +verify_running_package_candidate fixture /path/candidate.deb "$PACKAGE_DIGEST" +""" + digest = "a" * 64 + helper = ROOT / "scripts" / "lib" / "package_candidate.sh" + for mode in ("ok", "wrong-package", "wrong-process", "stopped"): + with self.subTest(mode=mode): + result = self.bash(harness, HELPER=str(helper), MODE=mode, PACKAGE_DIGEST=digest) + self.assertEqual(result.returncode == 0, mode == "ok", result.stdout + result.stderr) + if mode == "ok": + self.assertEqual(result.stdout.strip().split("\t"), ["fixture", digest, f"{2:064d}", "42"]) + def lifecycle(self, mode="pass", extra=()): artifacts = self.directory / "artifacts" # Source all real lifecycle/report functions; every external boundary From ce647ece141582fee2d5eb5afb289eab09894041 Mon Sep 17 00:00:00 2001 From: loverustfs Date: Sat, 28 Nov 2026 22:14:55 +0800 Subject: [PATCH 3/8] Bind measured performance endpoints to verified fleet nodes --- README.md | 3 +- rustfs_performance_test.sh | 26 +++++++++++++---- test_rustfs_performance_testing.py | 46 ++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 6f1100c8..0ea3a117 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,8 @@ exceeded budget fails the affected run. The runner retains the supplied budget with its artifacts and reuses it for `--parse-only`. An invocation without a budget reports execution and captures metrics. Run the fleet wrapper `rustfs_performance_test.sh` with `RUSTFS_WARP_BUDGET_FILE` and a package -SHA-256 to verify every running service before and after measurement. The +SHA-256 to verify the direct Warp targets and running services before and +after measurement. The performance workflow reads the budget from the `RUSTFS_WARP_BUDGET_JSON` repository variable and retains both candidate receipts. diff --git a/rustfs_performance_test.sh b/rustfs_performance_test.sh index 9e10feda..774631f4 100755 --- a/rustfs_performance_test.sh +++ b/rustfs_performance_test.sh @@ -475,11 +475,27 @@ step4_configure_start() { } record_performance_candidate() { - local path="$1" node - printf 'node\texpected_package_sha256\trunning_binary_sha256\tservice_pid\n' > "${path}" - for node in "${NODES[@]}"; do - verify_running_package_candidate "${node}" "${PACKAGES_DIR}/${PACKAGE_FILE}" "${PACKAGE_SHA256}" \ - >> "${path}" || die "benchmark candidate could not be verified on ${node}" + local path="$1" node index target address node_addresses receipt + local -a targets + local -A seen_addresses=() + IFS=',' read -r -a targets <<< "${WARP_HOST}" + [ "${#targets[@]}" -eq "${#NODES[@]}" ] || die "candidate budget requires one Warp target per node" + printf 'warp_target\taddress\tnode\texpected_package_sha256\trunning_binary_sha256\tservice_pid\n' > "${path}" + for index in "${!NODES[@]}"; do + node="${NODES[index]}" + target="${targets[index]}" + [[ "${target}" =~ ^[[:alnum:]][[:alnum:].-]*:9000$ ]] \ + || die "candidate budget requires a direct Warp target at port 9000: ${target}" + address="$(getent ahosts "${target%:9000}" | awk '$2 == "STREAM" {print $1}' | sort -u)" + [[ "${address}" =~ ^[0-9.]+$ ]] || die "Warp target must resolve to a single IPv4 address: ${target}" + [ -z "${seen_addresses[${address}]:-}" ] || die "Warp targets share an address: ${address}" + seen_addresses[${address}]=1 + node_addresses="$(run_remote "${node}" <<< 'hostname -I')" + [[ " ${node_addresses} " == *" ${address} "* ]] \ + || die "Warp target ${target} does not resolve to candidate node ${node}" + receipt="$(verify_running_package_candidate "${node}" "${PACKAGES_DIR}/${PACKAGE_FILE}" "${PACKAGE_SHA256}")" \ + || die "benchmark candidate could not be verified on ${node}" + printf '%s\t%s\t%s\n' "${target}" "${address}" "${receipt}" >> "${path}" done } diff --git a/test_rustfs_performance_testing.py b/test_rustfs_performance_testing.py index 1407bdb4..2dbad277 100644 --- a/test_rustfs_performance_testing.py +++ b/test_rustfs_performance_testing.py @@ -483,6 +483,52 @@ def test_parse_only_cannot_certify_failed_or_unverified_metrics(self): self.assertIn("failed=1", (self.results / "summary.reparsed.md").read_text()) +class PerformanceCandidateTests(unittest.TestCase): + def test_budget_targets_must_bind_to_each_verified_node(self): + script = Path(__file__).with_name("rustfs_performance_test.sh").read_text() + verify = script[script.index("record_performance_candidate() {"):script.index("\nstep5_benchmark() {")] + harness = r""" +set -Eeuo pipefail +NODES=(first second) +PACKAGES_DIR=/fixture +PACKAGE_FILE=candidate.deb +PACKAGE_SHA256=fixture +getent() { + case "$2" in + assigned-one) echo '192.0.2.1 STREAM assigned-one' ;; + assigned-two) echo '192.0.2.2 STREAM assigned-two' ;; + wrong-target) echo '192.0.2.3 STREAM wrong-target' ;; + esac +} +run_remote() { + cat >/dev/null + case "$1" in + first) echo '192.0.2.1' ;; + second) echo '192.0.2.2' ;; + esac +} +verify_running_package_candidate() { printf '%s\tfixture\tfixture\t42\n' "$1"; } +die() { echo "$*" >&2; exit 1; } +record_performance_candidate "$RECEIPT" +""" + for targets, accepted in ( + ("assigned-one:9000,assigned-two:9000", True), + ("assigned-one:9000,wrong-target:9000", False), + ("assigned-one:9000,assigned-one:9000", False), + ("assigned-one:9001,assigned-two:9000", False), + ): + with self.subTest(targets=targets), tempfile.TemporaryDirectory() as directory: + receipt = Path(directory) / "candidate.tsv" + result = subprocess.run( + ["bash", "-c", verify + "\n" + harness], + env={**os.environ, "WARP_HOST": targets, "RECEIPT": str(receipt)}, + capture_output=True, text=True, timeout=10, + ) + self.assertEqual(result.returncode == 0, accepted, result.stdout + result.stderr) + if accepted: + self.assertIn("assigned-two:9000\t192.0.2.2\tsecond\t", receipt.read_text()) + + class PerformanceEnvironmentTests(unittest.TestCase): def test_help_does_not_require_home(self): environment = dict(os.environ) From 268734f9a57f47622746311808ee35d888dd385d Mon Sep 17 00:00:00 2001 From: loverustfs Date: Sat, 28 Nov 2026 22:28:51 +0800 Subject: [PATCH 4/8] Exercise the strict AWS denial helper in redaction tests Signed-off-by: loverustfs --- test_sensitive_diagnostics.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/test_sensitive_diagnostics.py b/test_sensitive_diagnostics.py index 84d3c458..ad0b3ecd 100644 --- a/test_sensitive_diagnostics.py +++ b/test_sensitive_diagnostics.py @@ -19,7 +19,7 @@ class SensitiveDiagnosticsTests(unittest.TestCase): def setUp(self): self.functions = {} for name, script in (("test_kms106", "rustfs-kms-test.sh"), ("verify_config_persisted", "rustfs-upgrade-test.sh"), - ("assert_aws_fails", "rustfs-security-test.sh")): + ("aws_error_code", "rustfs-security-test.sh"), ("assert_aws_denied", "rustfs-security-test.sh")): source = (ROOT / script).read_text() function = re.search(rf"(?ms)^{name}\(\) \{{.*?^\}}", source) self.assertIsNotNone(function, f"the real {name} function must be tested") @@ -30,7 +30,7 @@ def setUp(self): self.valid = {"backend": "VaultKV2", "cache_enabled": True} def run_case(self, body, http, expected, context, function="test_kms106", secret=CANARY): - command = self.functions[function] + ''' + command = (self.functions["aws_error_code"] + "\n" if function == "assert_aws_denied" else "") + self.functions[function] + ''' admin_api() { printf '%s' "$TEST_RESPONSE"; } admin_api_code() { printf '%s' "$TEST_HTTP"; } ssh() { printf '%s' "$TEST_RESPONSE"; } @@ -43,7 +43,7 @@ def run_case(self, body, http, expected, context, function="test_kms106", secret AWS_CODE="$TEST_HTTP" AWS_OUT="$TEST_RESPONSE" exec > >(tee "$TEST_LOG") 2>&1 -''' + function + " 'expired/garbage web identity token'\n" +''' + function + " 'expired/garbage web identity token' AccessDenied\n" result = subprocess.run(["bash", "--noprofile", "--norc", "-uo", "pipefail", "-c", command], env={**os.environ, "TEST_RESPONSE": json.dumps(body) if isinstance(body, dict) else body, "TEST_HTTP": str(http), "TEST_SECRET": secret, "TEST_LOG": str(self.public_log)}, text=True, capture_output=True, timeout=10) @@ -74,8 +74,12 @@ def test_upgrade_config_failures_do_not_print_secret_key(self): def test_unexpected_sts_success_does_not_print_credentials(self): credentials = {"Credentials": {"AccessKeyId": "fixture", "SecretAccessKey": CANARY, "SessionToken": CANARY}} - self.run_case(credentials, 0, 1, "aws unexpectedly succeeded (exit 0): expired/garbage web identity token", "assert_aws_fails") - self.run_case(credentials, 42, 0, "", "assert_aws_fails") + context = "expired/garbage web identity token" + self.run_case(credentials, 0, 1, context, "assert_aws_denied") + self.run_case(credentials, 42, 1, context, "assert_aws_denied") + for code, expected_status in (("AccessDenied", 0), ("ServiceUnavailable", 1)): + body = f"An error occurred ({code}) when calling the AssumeRoleWithWebIdentity operation: {CANARY}" + self.run_case(body, 254, expected_status, "" if expected_status == 0 else context, "assert_aws_denied") def test_valid_sanitized_response_still_passes(self): self.run_case(self.valid, 200, 0, "") From f2848b12cafb96663cf558efa4183a0dd03ec200 Mon Sep 17 00:00:00 2001 From: loverustfs Date: Sat, 28 Nov 2026 22:30:18 +0800 Subject: [PATCH 5/8] Run multipart size and strict denial regressions in script CI Signed-off-by: loverustfs --- .github/workflows/s3-script-tests.yml | 4 +++- test_sensitive_diagnostics.py | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/s3-script-tests.yml b/.github/workflows/s3-script-tests.yml index 3e77a6d8..4b8a9367 100644 --- a/.github/workflows/s3-script-tests.yml +++ b/.github/workflows/s3-script-tests.yml @@ -8,6 +8,7 @@ on: - test_rustfs_s3_usage.py - test_rustfs_s3_signing.py - test_rustfs_s3_regressions.py + - test_rustfs_s3c305.py - scripts/s3_bulk_delete_regressions.py - scripts/s3_bulk_delete_keys.py - scripts/performance_s3.py @@ -36,6 +37,7 @@ on: - test_rustfs_s3_usage.py - test_rustfs_s3_signing.py - test_rustfs_s3_regressions.py + - test_rustfs_s3c305.py - scripts/s3_bulk_delete_regressions.py - scripts/s3_bulk_delete_keys.py - scripts/performance_s3.py @@ -73,7 +75,7 @@ jobs: - name: Install independent SigV4 verifier run: python3 -m pip install botocore==1.43.19 'boto3>=1.43.19,<1.43.20' - name: Test S3 cases and signatures without a cluster - run: python3 -B -m unittest test_rustfs_s3_usage.py test_rustfs_s3_signing.py test_rustfs_s3_regressions.py test_rustfs_worm_object_lock.py test_s3_bulk_delete_regressions.py test_s3_bulk_delete_keys.py test_s3_bulk_delete_observations.py test_sse_contract_cases.py + run: python3 -B -m unittest test_rustfs_s3_usage.py test_rustfs_s3_signing.py test_rustfs_s3_regressions.py test_rustfs_s3c305.py test_rustfs_worm_object_lock.py test_s3_bulk_delete_regressions.py test_s3_bulk_delete_keys.py test_s3_bulk_delete_observations.py test_sse_contract_cases.py - name: Test standalone S3 probe oracles run: python3 -B -m unittest test_mrf_long_root_refresh.py test_s3_request_id_parity.py test_s3_upload_part_timeout.py test_s3_veeam_sosapi_capacity.py - name: Test validation S3 round trip without a cluster diff --git a/test_sensitive_diagnostics.py b/test_sensitive_diagnostics.py index ad0b3ecd..fdc0fd5b 100644 --- a/test_sensitive_diagnostics.py +++ b/test_sensitive_diagnostics.py @@ -30,7 +30,12 @@ def setUp(self): self.valid = {"backend": "VaultKV2", "cache_enabled": True} def run_case(self, body, http, expected, context, function="test_kms106", secret=CANARY): - command = (self.functions["aws_error_code"] + "\n" if function == "assert_aws_denied" else "") + self.functions[function] + ''' + definitions = self.functions[function] + invocation = function + if function == "assert_aws_denied": + definitions = self.functions["aws_error_code"] + "\n" + definitions + invocation += " 'expired/garbage web identity token' AccessDenied" + command = definitions + ''' admin_api() { printf '%s' "$TEST_RESPONSE"; } admin_api_code() { printf '%s' "$TEST_HTTP"; } ssh() { printf '%s' "$TEST_RESPONSE"; } @@ -43,7 +48,7 @@ def run_case(self, body, http, expected, context, function="test_kms106", secret AWS_CODE="$TEST_HTTP" AWS_OUT="$TEST_RESPONSE" exec > >(tee "$TEST_LOG") 2>&1 -''' + function + " 'expired/garbage web identity token' AccessDenied\n" +''' + invocation + "\n" result = subprocess.run(["bash", "--noprofile", "--norc", "-uo", "pipefail", "-c", command], env={**os.environ, "TEST_RESPONSE": json.dumps(body) if isinstance(body, dict) else body, "TEST_HTTP": str(http), "TEST_SECRET": secret, "TEST_LOG": str(self.public_log)}, text=True, capture_output=True, timeout=10) From 6fa2e9a6d5cc35a45a9a92f39832c7393bfb8c3b Mon Sep 17 00:00:00 2001 From: loverustfs Date: Sat, 28 Nov 2026 22:32:27 +0800 Subject: [PATCH 6/8] Enforce multipart completion requirements in S3C-305 Check wire status and exact errors for malformed completion manifests. Verify the assembled bytes for a valid short final part and a single short part. --- rustfs-s3-compat-test.sh | 120 +++++++++++++++++++--------- test_rustfs_s3c305.py | 166 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 249 insertions(+), 37 deletions(-) create mode 100644 test_rustfs_s3c305.py diff --git a/rustfs-s3-compat-test.sh b/rustfs-s3-compat-test.sh index 3b43b69c..0b5f1ffc 100755 --- a/rustfs-s3-compat-test.sh +++ b/rustfs-s3-compat-test.sh @@ -1729,45 +1729,91 @@ test_s3c304() { } test_s3c305() { - new_bucket "s3c305-b1" || return 1 - make_test_file ${TEST_TMP}/s3c-p1 5242880 - make_test_file ${TEST_TMP}/s3c-p2 5242880 - local upload_id etag1 etag2 etag3 + local bucket="s3c305-b1" scenario key first second expected rc=0 + make_test_file "${TEST_TMP}/s3c305-large" 5242880 || return 1 + make_test_file "${TEST_TMP}/s3c305-small" 1048576 || return 1 + new_bucket "${bucket}" || return 1 - # Case 1: wrong order (2 before 1) -> AWS returns InvalidPart - aws_run s3api create-multipart-upload --bucket "s3c305-b1" --key mp - upload_id="$(printf '%s' "${AWS_OUT}" | jq -r '.UploadId')" - aws_run s3api upload-part --bucket "s3c305-b1" --key mp --upload-id "${upload_id}" --part-number 1 --body ${TEST_TMP}/s3c-p1 - etag1="$(printf '%s' "${AWS_OUT}" | jq -r '.ETag')" - aws_run s3api upload-part --bucket "s3c305-b1" --key mp --upload-id "${upload_id}" --part-number 2 --body ${TEST_TMP}/s3c-p2 - etag2="$(printf '%s' "${AWS_OUT}" | jq -r '.ETag')" - aws_run s3api complete-multipart-upload --bucket "s3c305-b1" --key mp --upload-id "${upload_id}" \ - --multipart-upload "{\"Parts\":[{\"ETag\":${etag2},\"PartNumber\":2},{\"ETag\":${etag1},\"PartNumber\":1}]}" - if [ "${AWS_CODE}" -eq 0 ]; then - echo "note: server accepts out-of-order parts (AWS returns InvalidPart)" - else - assert_aws_fails_with "InvalidPart" || return 1 - aws_run s3api abort-multipart-upload --bucket "s3c305-b1" --key mp --upload-id "${upload_id}" - fi + for scenario in 'out-of-order:large:large:InvalidPartOrder' 'small-non-final:small:large:EntityTooSmall' 'small-final:large:small:' 'small-only:small::' + do + IFS=: read -r key first second expected <<< "${scenario}" + ( + upload_id="" + trap ' + if [ -n "${upload_id}" ]; then + aws_run s3api abort-multipart-upload --bucket "${bucket}" --key "${key}" --upload-id "${upload_id}" + fi + aws_run s3api delete-object --bucket "${bucket}" --key "${key}" + ' EXIT + aws_run s3api create-multipart-upload --bucket "${bucket}" --key "${key}" + assert_aws_ok || exit 1 + upload_id="$(jq -er '.UploadId | strings | select(length > 0)' <<< "${AWS_OUT}")" || exit 1 + encoded_upload_id="$(jq -rn --arg id "${upload_id}" '$id | @uri')" || exit 1 + + part_files=("${TEST_TMP}/s3c305-${first}") + if [ -n "${second}" ]; then part_files+=("${TEST_TMP}/s3c305-${second}"); fi + manifest=() + for i in "${!part_files[@]}"; do + number=$((i + 1)) + aws_run s3api upload-part --bucket "${bucket}" --key "${key}" --upload-id "${upload_id}" --part-number "${number}" --body "${part_files[i]}" + assert_aws_ok || exit 1 + etag="$(jq -er '.ETag | strings | select(length > 0)' <<< "${AWS_OUT}")" || exit 1 + manifest+=("${number}" "${etag}") + done + if [ "${key}" = "out-of-order" ]; then + manifest=("${manifest[@]:2:2}" "${manifest[@]:0:2}") + fi - # Case 2: non-last part smaller than 5 MiB -> AWS returns EntityTooSmall - make_test_file ${TEST_TMP}/s3c-small 1048576 - aws_run s3api create-multipart-upload --bucket "s3c305-b1" --key mp - upload_id="$(printf '%s' "${AWS_OUT}" | jq -r '.UploadId')" - aws_run s3api upload-part --bucket "s3c305-b1" --key mp --upload-id "${upload_id}" --part-number 1 --body ${TEST_TMP}/s3c-p1 - etag1="$(printf '%s' "${AWS_OUT}" | jq -r '.ETag')" - aws_run s3api upload-part --bucket "s3c305-b1" --key mp --upload-id "${upload_id}" --part-number 2 --body ${TEST_TMP}/s3c-p2 - etag2="$(printf '%s' "${AWS_OUT}" | jq -r '.ETag')" - aws_run s3api upload-part --bucket "s3c305-b1" --key mp --upload-id "${upload_id}" --part-number 3 --body ${TEST_TMP}/s3c-small - etag3="$(printf '%s' "${AWS_OUT}" | jq -r '.ETag')" - aws_run s3api complete-multipart-upload --bucket "s3c305-b1" --key mp --upload-id "${upload_id}" \ - --multipart-upload "{\"Parts\":[{\"ETag\":${etag1},\"PartNumber\":1},{\"ETag\":${etag2},\"PartNumber\":2},{\"ETag\":${etag3},\"PartNumber\":3}]}" - if [ "${AWS_CODE}" -eq 0 ]; then - echo "note: server accepts a non-last part smaller than 5 MiB (AWS returns EntityTooSmall)" - else - assert_aws_fails_with "EntityTooSmall" || return 1 - fi - rm_bucket "s3c305-b1" + python3 - "${TEST_TMP}/s3c305-complete.xml" "${manifest[@]}" <<'PY_MANIFEST' || exit 1 +import sys +from xml.etree import ElementTree + +root = ElementTree.Element("CompleteMultipartUpload", xmlns="http://s3.amazonaws.com/doc/2006-03-01/") +for number, etag in zip(sys.argv[2::2], sys.argv[3::2]): + part = ElementTree.SubElement(root, "Part") + ElementTree.SubElement(part, "PartNumber").text = number + ElementTree.SubElement(part, "ETag").text = etag +ElementTree.ElementTree(root).write(sys.argv[1], encoding="utf-8") +PY_MANIFEST + + status="$(s3_signed_curl POST "/${bucket}/${key}?uploadId=${encoded_upload_id}" -H "Content-Type: application/xml" --data "${TEST_TMP}/s3c305-complete.xml")" || exit 1 + python3 - "${TEST_TMP}/curl.out" "${status}" "${expected}" "${key}" <<'PY_RESULT' || exit 1 +import sys +from xml.etree import ElementTree + +path, status, expected, key = sys.argv[1:] +try: + response = ElementTree.parse(path).getroot() +except ElementTree.ParseError as error: + raise SystemExit(f"{key}: HTTP {status} returned malformed completion XML: {error}") +kind = response.tag.rsplit("}", 1)[-1] +code = response.findtext("{*}Code") +print(f"{key}: HTTP {status} {kind}" + (f" {code}" if code else ""), flush=True) +if expected: + if (status, kind, code) != ("400", "Error", expected): + raise SystemExit(f"{key}: expected HTTP 400 with S3 error {expected}") +elif (status != "200" or kind != "CompleteMultipartUploadResult" + or response.findtext("{*}Key") != key or not response.findtext("{*}ETag")): + raise SystemExit(f"{key}: expected HTTP 200 with a successful completion result for this key") +PY_RESULT + + if [ -n "${expected}" ]; then + aws_run s3api head-object --bucket "${bucket}" --key "${key}" + assert_aws_fails_with '[(]404[)]' "rejected completion must not publish the object" || exit 1 + aws_run s3api abort-multipart-upload --bucket "${bucket}" --key "${key}" --upload-id "${upload_id}" + assert_aws_ok || exit 1 + else + aws_run s3api get-object --bucket "${bucket}" --key "${key}" "${TEST_TMP}/s3c305-download" + assert_aws_ok || exit 1 + cat "${part_files[@]}" > "${TEST_TMP}/s3c305-expected" || exit 1 + cmp -s "${TEST_TMP}/s3c305-expected" "${TEST_TMP}/s3c305-download" || { echo "${key}: assembled object differs from its parts"; exit 1; } + echo "${key}: assembled bytes match" + fi + upload_id="" + ) || rc=1 + done + rm_bucket "${bucket}" + return "${rc}" } # ---------- 4. Listing ---------- diff --git a/test_rustfs_s3c305.py b/test_rustfs_s3c305.py new file mode 100644 index 00000000..70321001 --- /dev/null +++ b/test_rustfs_s3c305.py @@ -0,0 +1,166 @@ +#!/usr/bin/env python3 +"""Exercise S3C-305 against deterministic multipart wire responses.""" + +import json +import os +from pathlib import Path +import shutil +import subprocess +import sys +import tempfile +import unittest + +RUNNER = Path(__file__).with_name("rustfs-s3-compat-test.sh") +MIB = 1024 * 1024 +FAKE_ENDPOINT = r''' +from pathlib import Path +import json +import sys +from xml.etree import ElementTree + +fixture, endpoint_trace, mutation, method, path, header_flag, header, data_flag, data = sys.argv[1:] +assert (method, header_flag, header, data_flag) == ("POST", "-H", "Content-Type: application/xml", "--data") +request = ElementTree.parse(data).getroot() +assert request.tag.rsplit("}", 1)[-1] == "CompleteMultipartUpload" +key = path.split("?")[0].rsplit("/", 1)[-1] +assert path.endswith(f"?uploadId={key}") +directory = Path(fixture) +numbers, sizes, sources = [], [], [] +for part in request.findall("{*}Part"): + number = int(part.findtext("{*}PartNumber")) + assert part.findtext("{*}ETag") == f'"{key}-{number}"' + source = directory / f"{key}-{number}" + numbers.append(number) + sizes.append(source.stat().st_size) + sources.append(source) +assert numbers + +status, code = 200, None +if numbers != sorted(numbers): + status, code = 400, "InvalidPartOrder" +elif any(size < 5 * 1024 * 1024 for size in sizes[:-1]): + status, code = 400, "EntityTooSmall" + if mutation == "accept-non-final": + status, code = 200, None + elif mutation == "wrong-status": + status = 500 + elif mutation == "wrong-code": + code = "InvalidPart" +elif key == "small-final" and mutation == "embedded-error": + code = "InternalError" + +if code: + body = ElementTree.Element("Error") + ElementTree.SubElement(body, "Code").text = code + ElementTree.SubElement(body, "Message").text = "EntityTooSmall" +else: + body = ElementTree.Element("CompleteMultipartUploadResult") + ElementTree.SubElement(body, "Key").text = key + ElementTree.SubElement(body, "ETag").text = '"assembled"' + with (directory / (key + ".object")).open("wb") as assembled: + for source in sources: + assembled.write(source.read_bytes()) + if key == "small-only" and mutation == "corrupt-control": + assembled.write(b"!") +ElementTree.ElementTree(body).write(directory / "curl.out") +with open(endpoint_trace, "a", encoding="utf-8") as log: + log.write(json.dumps({"key": key, "parts": numbers, "sizes": sizes, "status": status, "code": code}) + "\n") +print(status, end="") +''' + +HARNESS = r''' +source "$RUNNER" +make_test_file() { + "$PYTHON" - "$1" "$2" <<'FIXTURE' +from pathlib import Path +import sys +path, size = sys.argv[1:] +Path(path).write_bytes((b"L" if path.endswith("-large") else b"S") * int(size)) +FIXTURE +} +aws_run() { + local operation="$2" key="" number="" body="" previous="" argument + for argument in "$@"; do + case "${previous}" in + --key) key="$argument" ;; + --part-number) number="$argument" ;; + --body) body="$argument" ;; + esac + previous="$argument" + done + AWS_CODE=0 + AWS_OUT='{}' + case "${operation}" in + create-bucket|delete-bucket|delete-object|abort-multipart-upload) ;; + create-multipart-upload) AWS_OUT="{\"UploadId\":\"${key}\"}" ;; + upload-part) + cp "$body" "$TEST_TMP/${key}-${number}" + AWS_OUT="{\"ETag\":\"\\\"${key}-${number}\\\"\"}" + ;; + head-object) + if [ ! -f "$TEST_TMP/${key}.object" ]; then + AWS_CODE=254 + AWS_OUT='An error occurred (404) when calling the HeadObject operation: Not Found' + fi + ;; + get-object) cp "$TEST_TMP/${key}.object" "${@: -1}" ;; + *) echo "unexpected AWS operation: ${operation}"; return 1 ;; + esac +} +s3_signed_curl() { + "$PYTHON" "$FAKE_ENDPOINT" "$TEST_TMP" "$ENDPOINT_TRACE" "$MUTATION" "$@" +} +test_s3c305 +''' + + +@unittest.skipUnless(shutil.which("bash") and shutil.which("jq"), "requires Bash and jq") +class TestMultipartCompletionContract(unittest.TestCase): + def run_case(self, mutation="none"): + with tempfile.TemporaryDirectory() as directory: + root = Path(directory) + endpoint = root / "endpoint.py" + trace = root / "requests.jsonl" + endpoint.write_text(FAKE_ENDPOINT) + env = dict(os.environ, RUNNER=str(RUNNER), PYTHON=sys.executable, + FAKE_ENDPOINT=str(endpoint), ENDPOINT_TRACE=str(trace), + MUTATION=mutation, TMPDIR=directory) + result = subprocess.run(["bash", "-c", HARNESS], env=env, capture_output=True, text=True, timeout=30) + requests = [json.loads(line) for line in trace.read_text().splitlines()] if trace.exists() else [] + return result, requests + + def test_ineligible_and_eligible_manifests(self): + result, requests = self.run_case() + self.assertEqual(result.returncode, 0, result.stdout + result.stderr) + self.assertEqual( + [(request["key"], request["parts"], request["sizes"], request["status"], request["code"]) + for request in requests], + [("out-of-order", [2, 1], [5 * MIB, 5 * MIB], 400, "InvalidPartOrder"), + ("small-non-final", [1, 2], [MIB, 5 * MIB], 400, "EntityTooSmall"), + ("small-final", [1, 2], [5 * MIB, MIB], 200, None), + ("small-only", [1], [MIB], 200, None)], + ) + self.assertIn("small-final: assembled bytes match", result.stdout) + self.assertIn("small-only: assembled bytes match", result.stdout) + + def test_non_final_small_part_requires_exact_http_and_error_code(self): + for mutation in ("accept-non-final", "wrong-status", "wrong-code"): + with self.subTest(mutation=mutation): + result, requests = self.run_case(mutation) + self.assertEqual(result.returncode, 1, result.stdout + result.stderr) + self.assertIn("small-non-final: expected HTTP 400 with S3 error EntityTooSmall", result.stderr) + self.assertEqual(len(requests), 4) + + def test_http_200_with_an_embedded_error_is_not_success(self): + result, _ = self.run_case("embedded-error") + self.assertEqual(result.returncode, 1, result.stdout + result.stderr) + self.assertIn("small-final: HTTP 200 Error InternalError", result.stdout) + + def test_single_small_part_requires_the_original_bytes(self): + result, _ = self.run_case("corrupt-control") + self.assertEqual(result.returncode, 1, result.stdout + result.stderr) + self.assertIn("small-only: assembled object differs from its parts", result.stdout) + + +if __name__ == "__main__": + unittest.main() From 1aa285fd8f6edffaecc3e1388d737422feda0e9f Mon Sep 17 00:00:00 2001 From: loverustfs Date: Sat, 28 Nov 2026 22:33:48 +0800 Subject: [PATCH 7/8] Refresh reviewed suite digests after S3, IAM and upgrade oracle changes Signed-off-by: loverustfs --- validation-migration-review.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/validation-migration-review.json b/validation-migration-review.json index 6949134f..dfbd3383 100644 --- a/validation-migration-review.json +++ b/validation-migration-review.json @@ -1,11 +1,11 @@ { "schema_version": 1, - "as_of": "2026-11-25", + "as_of": "2026-11-28", "source_commit": "524eb5b32c3236497fdd8a9271df0494fa3d9974", "source_sha256": "463fdd02dee43e42fef4f3aacf7506709ce87af535e1a53d91c521bc2e361cad", - "reviewed_testing_commit": "5e76033d7ccad414aad1f7edb9867de6462eee43", + "reviewed_testing_commit": "6fa2e9a6d5cc35a45a9a92f39832c7393bfb8c3b", "scope": "Test implementation migration and candidate live acceptance are independent. This review does not rewrite original results, change migration_status semantics or relax the canonical gate. Environment procedures remain disabled by default under the accepted delivery scope.", - "evidence_basis": "20261026-canonical-migration-ledger-7094.json plus later G01/G02 attempts and source review on 2026-10-28; historical result bytes and audit reports remain in the separate evidence store. 2026-11-10: a scoped re-review of the Rebalance activity fixture, capacity admission, Started non-zero progress, and the early-completion diagnosis; this local regression adds no product live acceptance. 2026-11-22: reviewed the replication inventory pagination, Heal census completeness, expected-manifest comparison, ILM control survival, and exact marker oracles after automated review findings. Reviewed the 10-version NewerNoncurrentVersions retention procedure and source/target version-purge convergence evidence for this change. 2026-11-22: indexed the source-audit inventory and added individually dispatchable local compatibility and source-suite procedure entries with selector and candidate-admission checks. 2026-11-22: added table-catalog and upgrade procedure selectors with shared validation artifact wiring; dry-run selectors cover all 25 newly indexed procedures. 2026-11-22: clarified that source-native tests are used as assertion and boundary-value references; one-to-one native ports are outside the migration scope. 2026-11-24: re-reviewed the ILM scanner-readiness preflight after a 4-node VM run (auto-testing 644b935, RustFS 2d90297) blocked all 14 ILM cases because followers report effective_interval_available=false with a zero effective interval by design; the effective-interval comparison now runs only on the leader. This is a test-oracle correction and adds no product live acceptance. 2026-11-24: refreshed the reviewed digest for rustfs-s3-compat-test.sh to match current main (a3a9e83 and 6feeeec changed that script without updating this ledger); this PR does not modify the script, and the same digest mismatch reproduces on a clean origin/main checkout. 2026-11-24: refreshed the reviewed digest again for rustfs-s3-compat-test.sh after 90b4fe1 changed that script without updating this ledger; the main push of ba6051d failed the contract-tests job. This follow-up does not modify the script. 2026-11-24: accepted the product last_cycle_partial_reason=unknown sentinel in the ILM scanner-readiness preflight after a healthy leader was still blocked; this is a test-oracle correction and adds no product live acceptance. 2026-11-24: reviewed the new STOR-135 DeepKeyListingResilience case in rustfs-storage-test.sh (backlog#3293): a 301-segment key PUT followed by a recursive ListObjectsV2 must either return the key or fail with a controlled error while the server stays alive, and GET must return the same bytes. This is a test-oracle addition guarding the scan_dir recursion-depth fix; it adds no product live acceptance. 2026-11-25: fixed the S3C-206 fixture to send the single encoded metadata value it expects; the previous fixture sent two encoded words and the product preserved them exactly, so the case falsely failed. 2026-11-23: added strict SSE contract procedures ENC-201..ENC-210 (S3 compatibility suite) and KMS-601..KMS-609 (KMS suite), executed by scripts/sse_contract_cases.py and individually dispatchable; they were exercised against local single-process servers started with each suite's environment, which is no fleet live acceptance. 2026-11-26: indexed STOR-136 for disk-compressed Range GET on a single-node single-disk deployment, with exact response bytes and a positive bounded process read-byte delta. 2026-11-26: re-reviewed the shared scanner cycle oracle after four-node USAGE-01/20 retests. An explicitly incomplete empty response without a scan identity remains eligible for polling, published epochs use integer identifiers, and exact convergence, monotonicity, and cleanup assertions remain required. The existing migration and live acceptance states are unchanged. 2026-11-28: reviewed STOR-137 and its four-node selector, request-correlated quota lock oracle, concurrent response evidence, and hard-cap assertion. The dry-run and positive and negative mocked checks add no live fleet evidence.", + "evidence_basis": "20261026-canonical-migration-ledger-7094.json plus later G01/G02 attempts and source review on 2026-10-28; historical result bytes and audit reports remain in the separate evidence store. 2026-11-10: a scoped re-review of the Rebalance activity fixture, capacity admission, Started non-zero progress, and the early-completion diagnosis; this local regression adds no product live acceptance. 2026-11-22: reviewed the replication inventory pagination, Heal census completeness, expected-manifest comparison, ILM control survival, and exact marker oracles after automated review findings. Reviewed the 10-version NewerNoncurrentVersions retention procedure and source/target version-purge convergence evidence for this change. 2026-11-22: indexed the source-audit inventory and added individually dispatchable local compatibility and source-suite procedure entries with selector and candidate-admission checks. 2026-11-22: added table-catalog and upgrade procedure selectors with shared validation artifact wiring; dry-run selectors cover all 25 newly indexed procedures. 2026-11-22: clarified that source-native tests are used as assertion and boundary-value references; one-to-one native ports are outside the migration scope. 2026-11-24: re-reviewed the ILM scanner-readiness preflight after a 4-node VM run (auto-testing 644b935, RustFS 2d90297) blocked all 14 ILM cases because followers report effective_interval_available=false with a zero effective interval by design; the effective-interval comparison now runs only on the leader. This is a test-oracle correction and adds no product live acceptance. 2026-11-24: refreshed the reviewed digest for rustfs-s3-compat-test.sh to match current main (a3a9e83 and 6feeeec changed that script without updating this ledger); this PR does not modify the script, and the same digest mismatch reproduces on a clean origin/main checkout. 2026-11-24: refreshed the reviewed digest again for rustfs-s3-compat-test.sh after 90b4fe1 changed that script without updating this ledger; the main push of ba6051d failed the contract-tests job. This follow-up does not modify the script. 2026-11-24: accepted the product last_cycle_partial_reason=unknown sentinel in the ILM scanner-readiness preflight after a healthy leader was still blocked; this is a test-oracle correction and adds no product live acceptance. 2026-11-24: reviewed the new STOR-135 DeepKeyListingResilience case in rustfs-storage-test.sh (backlog#3293): a 301-segment key PUT followed by a recursive ListObjectsV2 must either return the key or fail with a controlled error while the server stays alive, and GET must return the same bytes. This is a test-oracle addition guarding the scan_dir recursion-depth fix; it adds no product live acceptance. 2026-11-25: fixed the S3C-206 fixture to send the single encoded metadata value it expects; the previous fixture sent two encoded words and the product preserved them exactly, so the case falsely failed. 2026-11-23: added strict SSE contract procedures ENC-201..ENC-210 (S3 compatibility suite) and KMS-601..KMS-609 (KMS suite), executed by scripts/sse_contract_cases.py and individually dispatchable; they were exercised against local single-process servers started with each suite's environment, which is no fleet live acceptance. 2026-11-26: indexed STOR-136 for disk-compressed Range GET on a single-node single-disk deployment, with exact response bytes and a positive bounded process read-byte delta. 2026-11-26: re-reviewed the shared scanner cycle oracle after four-node USAGE-01/20 retests. An explicitly incomplete empty response without a scan identity remains eligible for polling, published epochs use integer identifiers, and exact convergence, monotonicity, and cleanup assertions remain required. The existing migration and live acceptance states are unchanged. 2026-11-28: reviewed STOR-137 and its four-node selector, request-correlated quota lock oracle, concurrent response evidence, and hard-cap assertion. The dry-run and positive and negative mocked checks add no live fleet evidence. 2026-11-28: re-reviewed the S3 and IAM canonical selectors, strict negative responses, multipart part-size fixtures and upgrade observation windows at the reviewed testing commit. Existing migration acceptance records retain their original provenance.", "reviewed_files": { "scripts/run_validation_case.sh": "58e0eb2fb007b28fb16b0fd4a25ac2f997cc9f01a4a3700c01fe7c9a6dd1a683", "scripts/validation_heal/authority.py": "8f2225f184427674de1f45aff4c4976c812f9d70fd4bc927ce460726a4ff74a0", @@ -121,8 +121,8 @@ "test_validation_ilm.py": "f4d361850f278a5be965f05ff8950d91347907be2253bfa31a1864ae5b2a730c", "test_validation_replication.py": "83e1b532e8a6a352c5e38de48799356157e1fad4f1f314ea8ad256fdecf942c5", "test_validation_scanner_usage.py": "e549bab36f5896844ff70ab6bf1d6b1825747e5cc5e9a5003a8336d70e8b8173", - "rustfs-s3-compat-test.sh": "31f986f574484da43f36fcc1ee74b0a088d83574202a91945a3473b49cab82aa", - "rustfs-security-test.sh": "02cddd15636df1e74210c172ee898dba9b3adf83943da45d874d6c827583d9d2", + "rustfs-s3-compat-test.sh": "d983a6b1aea1bb4c073d505c9a0ec61a96edec64f32ded49e04ede258e283687", + "rustfs-security-test.sh": "9f4e6ca7409a08f0b84d286d29c9c107d32f109b046cf9199e8ba7495a74eb3b", "rustfs-tier-test.sh": "3b37a6b26a4af862d7f2d178872900f314c8328ffd3db6a3e769928a5d1b3964", "rustfs-storage-test.sh": "978e15585e373e763f9f1d6e9f70d4cd308c5b986a43ee53acc46cdfb0dcc829", "rustfs-kms-test.sh": "4a20d95a04287fa4d84d1ce58e074725cd0507163eaeb6e27e0ea7fc098c3bb0", @@ -133,7 +133,7 @@ "test_source_procedure_catalog.py": "ed50ad0e8a0aeef2e947b9f090ffcfd00420fe5f1ef85157b4fc8deb2280e5c7", "test_validation_s3_compatibility.py": "c1978bc5eaec91c07d65ebc2460644b81f73c48b63fe382d79508d45a5b573bb", "rustfs-table-test.sh": "79ab30545c7b532c6bc189907e83d45d41b1b4968e616e319009d29394124ce5", - "rustfs-upgrade-test.sh": "cf6f49d60ffcefd0cbd0134866a2c07286436fa6b933c5981179d5a05218f648", + "rustfs-upgrade-test.sh": "11e3011360672ca26fdb7cf82147727d5e14222512220bbdaf358e34e1fec590", "scripts/validation_catalog.py": "70ceb89b9739b09bce7db42673087da39087087c20f5b661b6d29ad34428a028" }, "cases": [ From 147107c8c74ac81cdb81306776449c82463e5a3f Mon Sep 17 00:00:00 2001 From: loverustfs Date: Mon, 30 Nov 2026 16:44:34 +0800 Subject: [PATCH 8/8] Fix candidate verification and release validation edge cases --- .github/workflows/rustfs-performance-test.yml | 6 ++- README.md | 7 +-- rustfs-replication-test.sh | 5 +- rustfs-security-test.sh | 10 +++- rustfs-upgrade-test.sh | 2 +- rustfs_performance_test.sh | 6 ++- scripts/lib/package_candidate.sh | 7 ++- test_rustfs_performance_testing.py | 20 ++++---- test_rustfs_replication.py | 29 +++++++++++ test_rustfs_security.py | 9 ++-- test_rustfs_upgrade.py | 48 ++++++++++--------- validation-migration-review.json | 8 ++-- 12 files changed, 106 insertions(+), 51 deletions(-) diff --git a/.github/workflows/rustfs-performance-test.yml b/.github/workflows/rustfs-performance-test.yml index 5f0a47fa..501c64c5 100644 --- a/.github/workflows/rustfs-performance-test.yml +++ b/.github/workflows/rustfs-performance-test.yml @@ -21,7 +21,7 @@ on: required: false type: string package_sha256: - description: SHA-256 of the candidate Debian package + description: SHA-256 of the candidate Debian package (enables the configured performance budget) required: false type: string test_method: @@ -202,9 +202,11 @@ jobs: env: PERFORMANCE_BUDGET_JSON: ${{ vars.RUSTFS_WARP_BUDGET_JSON }} run: | - if [ -n "${PERFORMANCE_BUDGET_JSON}" ]; then + if [ -n "${PERFORMANCE_BUDGET_JSON}" ] && [ -n "${RUSTFS_PACKAGE_SHA256:-${PACKAGE_SHA256:-}}" ]; then export RUSTFS_WARP_BUDGET_FILE="${FUNCTIONAL_ARTIFACTS_DIR}/performance-budget.json" printf '%s\n' "${PERFORMANCE_BUDGET_JSON}" > "${RUSTFS_WARP_BUDGET_FILE}" + elif [ -n "${PERFORMANCE_BUDGET_JSON}" ]; then + echo "::notice::Collecting metrics without a budget because no candidate package SHA-256 was supplied." fi ./rustfs_performance_test.sh \ --step 5 -y \ diff --git a/README.md b/README.md index 4a21288b..e9ef1430 100644 --- a/README.md +++ b/README.md @@ -96,9 +96,10 @@ with its artifacts and reuses it for `--parse-only`. An invocation without a budget reports execution and captures metrics. Run the fleet wrapper `rustfs_performance_test.sh` with `RUSTFS_WARP_BUDGET_FILE` and a package SHA-256 to verify the direct Warp targets and running services before and -after measurement. The -performance workflow reads the budget from the `RUSTFS_WARP_BUDGET_JSON` -repository variable and retains both candidate receipts. +after measurement. When a dispatch input or chain manifest supplies the package +SHA-256, the performance workflow applies the `RUSTFS_WARP_BUDGET_JSON` +repository variable and retains both candidate receipts. Runs without a +package SHA-256 report metrics only. ### In-place upgrade observation diff --git a/rustfs-replication-test.sh b/rustfs-replication-test.sh index 07828da8..c3dd540e 100755 --- a/rustfs-replication-test.sh +++ b/rustfs-replication-test.sh @@ -1084,6 +1084,7 @@ run_all_site_tests() { test_site101() { local body + local valid_sites='.enabled == true and (.sites | length == 2) and ([.sites[].deploymentID | strings | select(length > 0)] | unique | length == 2)' [ "${API_ENDPOINT%/}" != "${SITE2_ENDPOINT%/}" ] || { echo "site replication requires different endpoints"; return 1; } # The add request must reach a node directly (not the LB): the server # derives the local site's endpoint from the request Host header, and with @@ -1098,12 +1099,12 @@ test_site101() { || { echo "site add not successful: ${body}"; return 1; } body="$(admin_api GET "/rustfs/admin/v3/site-replication/info")" [ "$(signed_code)" = "200" ] || { echo "site-replication/info HTTP $(signed_code): ${body}"; return 1; } - printf '%s' "${body}" | jq -e '.enabled == true and ([.sites[].deploymentID | strings | select(length > 0)] | length == 2 and (unique | length == 2))' >/dev/null 2>&1 \ + printf '%s' "${body}" | jq -e "${valid_sites}" >/dev/null 2>&1 \ || { echo "site info does not show 2 distinct enabled deployments: ${body}"; return 1; } # The peer entry must be visible from site2 as well. body="$(site2_admin_api GET "/rustfs/admin/v3/site-replication/info")" [ "$(signed_code)" = "200" ] || { echo "site2 info HTTP $(signed_code): ${body}"; return 1; } - printf '%s' "${body}" | jq -e '.enabled == true and ([.sites[].deploymentID | strings | select(length > 0)] | length == 2 and (unique | length == 2))' >/dev/null 2>&1 \ + printf '%s' "${body}" | jq -e "${valid_sites}" >/dev/null 2>&1 \ || { echo "site2 does not show 2 distinct enabled deployments: ${body}"; return 1; } } diff --git a/rustfs-security-test.sh b/rustfs-security-test.sh index 4f8b3062..1a93161e 100755 --- a/rustfs-security-test.sh +++ b/rustfs-security-test.sh @@ -525,7 +525,13 @@ assert_aws_ok() { } aws_error_code() { - printf '%s\n' "${AWS_OUT}" | sed -n 's/^An error occurred (\([A-Za-z0-9]*\)) when calling .*/\1/p' + local line pattern='An error occurred \(([A-Za-z0-9]+)\) when calling ' + while IFS= read -r line; do + if [[ "${line}" =~ ${pattern} ]]; then + printf '%s\n' "${BASH_REMATCH[1]}" + return 0 + fi + done <<< "${AWS_OUT}" } assert_aws_denied() { @@ -731,7 +737,7 @@ case_iam_105_readonly_boundary() { if [ "${bucket_created}" -eq 1 ]; then aws_run s3api delete-object --bucket "${bucket}" --key "${key}" assert_aws_ok "cleanup readonly object" || result=1 - rm_bucket "${bucket}" + aws_run s3api delete-bucket --bucket "${bucket}" assert_aws_ok "cleanup readonly bucket" || result=1 fi admin_user_remove "${user}" >/dev/null diff --git a/rustfs-upgrade-test.sh b/rustfs-upgrade-test.sh index 8b9a953e..0742d894 100755 --- a/rustfs-upgrade-test.sh +++ b/rustfs-upgrade-test.sh @@ -668,7 +668,7 @@ monitor_upgrade_io() { } stop_upgrade_observation() { - [ -n "${UPGRADE_PROBE_PID}" ] || return 0 + [ -n "${UPGRADE_PROBE_PID:-}" ] || return 0 touch "${UPGRADE_PROBE_STOP}" || { kill "${UPGRADE_PROBE_PID}" 2>/dev/null || true } diff --git a/rustfs_performance_test.sh b/rustfs_performance_test.sh index 774631f4..56a27728 100755 --- a/rustfs_performance_test.sh +++ b/rustfs_performance_test.sh @@ -151,7 +151,7 @@ run_remote() { printf '%s\n' "${script}" | sed 's/^/ | /' return 0 fi - log "==> ${node}: executing remote script" + log "==> ${node}: executing remote script" >&2 ( ssh "${SSH_OPTS[@]}" "${SSH_USER}@${node}" 'bash -s' <<<"${script}" ) } @@ -486,7 +486,7 @@ record_performance_candidate() { target="${targets[index]}" [[ "${target}" =~ ^[[:alnum:]][[:alnum:].-]*:9000$ ]] \ || die "candidate budget requires a direct Warp target at port 9000: ${target}" - address="$(getent ahosts "${target%:9000}" | awk '$2 == "STREAM" {print $1}' | sort -u)" + address="$(getent ahostsv4 "${target%:9000}" | awk '$2 == "STREAM" {print $1}' | sort -u)" [[ "${address}" =~ ^[0-9.]+$ ]] || die "Warp target must resolve to a single IPv4 address: ${target}" [ -z "${seen_addresses[${address}]:-}" ] || die "Warp targets share an address: ${address}" seen_addresses[${address}]=1 @@ -509,6 +509,8 @@ step5_benchmark() { fi local benchmark_rc=0 if [ -n "${WARP_BUDGET_FILE}" ]; then + need_cmd getent "resolve direct Warp targets" + need_cmd cmp "compare candidate receipts" [[ "${PACKAGE_SHA256}" =~ ^[0-9A-Fa-f]{64}$ ]] || die "a performance budget requires the candidate package SHA-256" [[ "${BENCH_SCRIPT}" -ef "${_SCRIPT_DIR}/rustfs_performance_testing.sh" ]] \ || die "a performance budget requires the repository benchmark script" diff --git a/scripts/lib/package_candidate.sh b/scripts/lib/package_candidate.sh index d5b04c29..2819069a 100644 --- a/scripts/lib/package_candidate.sh +++ b/scripts/lib/package_candidate.sh @@ -6,10 +6,13 @@ verify_running_package_candidate() { receipt="$({ printf 'set -euo pipefail\n' printf 'SUDO=""; [ "$(id -u)" -eq 0 ] || SUDO="sudo -n"\n' - printf 'pkg="%s"\n' "${package}" - printf 'printf "%%s %%s\\n" "%s" "$pkg" | sha256sum --check --status\n' "${expected_sha,,}" + printf 'pkg=%q\n' "${package}" + printf 'expected=%q\n' "${expected_sha,,}" cat <<'REMOTE' +package_hash="$(sha256sum < "$pkg")" +[[ "${package_hash%% *}" == "$expected" ]] candidate="$(dpkg-deb --fsys-tarfile "$pkg" | tar -xOf - ./usr/bin/rustfs | sha256sum)" +[[ "$(systemctl show --property=ActiveState --value rustfs)" == active ]] pid="$(systemctl show --property=MainPID --value rustfs)" [[ "$pid" =~ ^[1-9][0-9]*$ ]] running="$(${SUDO} sha256sum "/proc/${pid}/exe")" diff --git a/test_rustfs_performance_testing.py b/test_rustfs_performance_testing.py index 2dbad277..09892fd8 100644 --- a/test_rustfs_performance_testing.py +++ b/test_rustfs_performance_testing.py @@ -485,26 +485,30 @@ def test_parse_only_cannot_certify_failed_or_unverified_metrics(self): class PerformanceCandidateTests(unittest.TestCase): def test_budget_targets_must_bind_to_each_verified_node(self): - script = Path(__file__).with_name("rustfs_performance_test.sh").read_text() - verify = script[script.index("record_performance_candidate() {"):script.index("\nstep5_benchmark() {")] harness = r""" set -Eeuo pipefail +RUSTFS_PERF_SCRIPT_SOURCE_ONLY=1 source "$1" NODES=(first second) PACKAGES_DIR=/fixture PACKAGE_FILE=candidate.deb PACKAGE_SHA256=fixture getent() { + case "$1" in + ahosts) echo "2001:db8::1 STREAM $2" ;; + ahostsv4) : ;; + *) return 1 ;; + esac case "$2" in assigned-one) echo '192.0.2.1 STREAM assigned-one' ;; assigned-two) echo '192.0.2.2 STREAM assigned-two' ;; wrong-target) echo '192.0.2.3 STREAM wrong-target' ;; esac } -run_remote() { +ssh() { cat >/dev/null - case "$1" in - first) echo '192.0.2.1' ;; - second) echo '192.0.2.2' ;; + case "${@: -2:1}" in + *@first) echo '192.0.2.1' ;; + *@second) echo '192.0.2.2' ;; esac } verify_running_package_candidate() { printf '%s\tfixture\tfixture\t42\n' "$1"; } @@ -520,8 +524,8 @@ def test_budget_targets_must_bind_to_each_verified_node(self): with self.subTest(targets=targets), tempfile.TemporaryDirectory() as directory: receipt = Path(directory) / "candidate.tsv" result = subprocess.run( - ["bash", "-c", verify + "\n" + harness], - env={**os.environ, "WARP_HOST": targets, "RECEIPT": str(receipt)}, + ["bash", "-c", harness, "bash", str(ROOT / "rustfs_performance_test.sh")], + env={**os.environ, "RUSTFS_WARP_HOST": targets, "RECEIPT": str(receipt)}, capture_output=True, text=True, timeout=10, ) self.assertEqual(result.returncode == 0, accepted, result.stdout + result.stderr) diff --git a/test_rustfs_replication.py b/test_rustfs_replication.py index 67a62ac9..41796428 100644 --- a/test_rustfs_replication.py +++ b/test_rustfs_replication.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 """Run the real replicated-delete case without a cluster.""" +import json import os import subprocess import unittest @@ -68,6 +69,34 @@ def test_rejects_failed_listing_even_with_empty_json(self): self.assertNotEqual(self.run_case("list_error").returncode, 0) +class SiteReplicationTests(unittest.TestCase): + def test_both_sites_report_exactly_two_distinct_deployments(self): + source = (ROOT / "rustfs-replication-test.sh").read_text() + case = source[source.index("test_site101() {"):source.index("\n# admin_wait_user")] + harness = r""" +API_ENDPOINT=http://first +SITE2_ENDPOINT=http://second +endpoint_host_prefix() { echo site; } +site_add_payload() { echo '{}'; } +signed_request() { echo '{"success":true}'; } +signed_code() { echo 200; } +admin_api() { echo "$FIRST"; } +site2_admin_api() { echo "$SECOND"; } +""" + def info(ids): + return json.dumps({"enabled": True, "sites": [{"deploymentID": value} for value in ids]}) + + valid = ["a", "b"] + for first, second in ((valid, valid), (valid + [""], valid), (valid, valid + [""]), (valid, ["a", "a"])): + with self.subTest(first=first, second=second): + result = subprocess.run( + ["bash", "-c", harness + case + "\ntest_site101"], + env={**os.environ, "FIRST": info(first), "SECOND": info(second)}, + capture_output=True, text=True, timeout=10, + ) + self.assertEqual(result.returncode == 0, first == second == valid, result.stdout + result.stderr) + + class ReplicationPollingTests(unittest.TestCase): def test_exit_zero_with_false_response_cannot_satisfy_a_predicate(self): source = (ROOT / "rustfs-replication-test.sh").read_text() diff --git a/test_rustfs_security.py b/test_rustfs_security.py index 37ea0f23..51d1a79e 100644 --- a/test_rustfs_security.py +++ b/test_rustfs_security.py @@ -91,7 +91,6 @@ def test_preserves_failures_after_cleanup_and_requires_the_exact_denial(self): admin_policy_attach() { :; } admin_api_code() { echo 200; } new_bucket() { :; } -rm_bucket() { echo bucket-cleanup >> "$TEST_TMP/steps"; } aws_run() { AWS_CODE=0 AWS_OUT="" case "$2" in @@ -101,6 +100,10 @@ def test_preserves_failures_after_cleanup_and_requires_the_exact_denial(self): if [ "$SCENARIO" = wrong-bytes ]; then echo corrupt > "${@: -1}"; fi ;; delete-object) rm -f "$TEST_TMP/object" ;; + delete-bucket) + echo bucket-cleanup >> "$TEST_TMP/steps" + if [ "$SCENARIO" = bucket-cleanup-fails ]; then AWS_CODE=254; fi + ;; *) return 99 ;; esac } @@ -117,7 +120,7 @@ def test_preserves_failures_after_cleanup_and_requires_the_exact_denial(self): unexpected-write) cp "${@: -1}" "$TEST_TMP/object" ;; missing-fixture) AWS_CODE=255; AWS_OUT="Unable to read file AccessDenied" ;; wrong-error) AWS_CODE=254; AWS_OUT="An error occurred (NoSuchBucket) when calling the PutObject operation: AccessDenied" ;; - *) AWS_CODE=254; AWS_OUT="An error occurred (AccessDenied) when calling the PutObject operation: denied" ;; + *) AWS_CODE=254; AWS_OUT=$'fatal error: An error occurred (AccessDenied) when calling the PutObject operation: denied\nAn error occurred (OtherError) when calling the Retry operation' ;; esac ;; *) return 99 ;; @@ -130,7 +133,7 @@ def test_preserves_failures_after_cleanup_and_requires_the_exact_denial(self): "case_iam_105_readonly_boundary", )) for scenario in ("expected", "unexpected-write", "allowed-read-fails", "missing-fixture", - "wrong-error", "wrong-bytes"): + "wrong-error", "wrong-bytes", "bucket-cleanup-fails"): with self.subTest(scenario=scenario), tempfile.TemporaryDirectory() as directory: result = subprocess.run( ["bash", "-c", harness + helpers + "\nif case_iam_105_readonly_boundary; then exit 0; else exit 1; fi"], diff --git a/test_rustfs_upgrade.py b/test_rustfs_upgrade.py index 53886259..168b71b2 100644 --- a/test_rustfs_upgrade.py +++ b/test_rustfs_upgrade.py @@ -1,5 +1,6 @@ """Upgrade harness regression tests; no SSH, Docker or RustFS is contacted.""" +import hashlib import json import os from pathlib import Path @@ -170,40 +171,43 @@ def test_running_package_gate_requires_the_verified_package_and_service_process( set -Eeuo pipefail source "$HELPER" id() { echo 0; } -dpkg-deb() { printf package-binary; } +dpkg-deb() { [[ "$2" == "$PACKAGE_PATH" ]] && printf package-binary; } tar() { cat; } systemctl() { - if [ "$MODE" = stopped ]; then echo 0; else echo 42; fi + case "$2" in + --property=ActiveState) + case "$MODE" in + activating|deactivating) echo "$MODE" ;; + *) echo active ;; + esac ;; + --property=MainPID) + if [ "$MODE" = stopped ]; then echo 0; else echo 42; fi ;; + *) return 1 ;; + esac } sha256sum() { - case "${1:-}" in - --check) - read -r hash _ || return 1 - [ "$MODE" != wrong-package ] && [ "$hash" = "$PACKAGE_DIGEST" ] - ;; - /proc/42/exe) - if [ "$MODE" = wrong-process ]; then - printf '%064d -\\n' 1 - else - printf '%064d -\\n' 2 - fi - ;; - "") cat >/dev/null; printf '%064d -\\n' 2 ;; - *) return 99 ;; - esac + if [[ "${1:-}" == /proc/42/exe ]]; then + if [[ "$MODE" == wrong-process ]]; then printf other; else printf package-binary; fi | command sha256sum + else + command sha256sum "$@" + fi } export -f id dpkg-deb tar systemctl sha256sum run_remote() { bash -s; } -verify_running_package_candidate fixture /path/candidate.deb "$PACKAGE_DIGEST" +verify_running_package_candidate fixture "$PACKAGE_PATH" "$PACKAGE_DIGEST" """ - digest = "a" * 64 + package = self.directory / 'candidate "$build" package.deb' + package.write_bytes(b"package fixture") + digest = hashlib.sha256(package.read_bytes()).hexdigest() + binary_digest = hashlib.sha256(b"package-binary").hexdigest() helper = ROOT / "scripts" / "lib" / "package_candidate.sh" - for mode in ("ok", "wrong-package", "wrong-process", "stopped"): + for mode in ("ok", "wrong-package", "wrong-process", "stopped", "activating", "deactivating"): with self.subTest(mode=mode): - result = self.bash(harness, HELPER=str(helper), MODE=mode, PACKAGE_DIGEST=digest) + result = self.bash(harness, HELPER=str(helper), MODE=mode, PACKAGE_PATH=str(package), + PACKAGE_DIGEST="0" * 64 if mode == "wrong-package" else digest) self.assertEqual(result.returncode == 0, mode == "ok", result.stdout + result.stderr) if mode == "ok": - self.assertEqual(result.stdout.strip().split("\t"), ["fixture", digest, f"{2:064d}", "42"]) + self.assertEqual(result.stdout.strip().split("\t"), ["fixture", digest, binary_digest, "42"]) def lifecycle(self, mode="pass", extra=()): artifacts = self.directory / "artifacts" diff --git a/validation-migration-review.json b/validation-migration-review.json index 90032254..fc7d23e0 100644 --- a/validation-migration-review.json +++ b/validation-migration-review.json @@ -1,11 +1,11 @@ { "schema_version": 1, - "as_of": "2026-11-29", + "as_of": "2026-11-30", "source_commit": "524eb5b32c3236497fdd8a9271df0494fa3d9974", "source_sha256": "463fdd02dee43e42fef4f3aacf7506709ce87af535e1a53d91c521bc2e361cad", "reviewed_testing_commit": "6fa2e9a6d5cc35a45a9a92f39832c7393bfb8c3b", "scope": "Test implementation migration and candidate live acceptance are independent. This review does not rewrite original results, change migration_status semantics or relax the canonical gate. Environment procedures remain disabled by default under the accepted delivery scope.", - "evidence_basis": "20261026-canonical-migration-ledger-7094.json plus later G01/G02 attempts and source review on 2026-10-28; historical result bytes and audit reports remain in the separate evidence store. 2026-11-10: a scoped re-review of the Rebalance activity fixture, capacity admission, Started non-zero progress, and the early-completion diagnosis; this local regression adds no product live acceptance. 2026-11-22: reviewed the replication inventory pagination, Heal census completeness, expected-manifest comparison, ILM control survival, and exact marker oracles after automated review findings. Reviewed the 10-version NewerNoncurrentVersions retention procedure and source/target version-purge convergence evidence for this change. 2026-11-22: indexed the source-audit inventory and added individually dispatchable local compatibility and source-suite procedure entries with selector and candidate-admission checks. 2026-11-22: added table-catalog and upgrade procedure selectors with shared validation artifact wiring; dry-run selectors cover all 25 newly indexed procedures. 2026-11-22: clarified that source-native tests are used as assertion and boundary-value references; one-to-one native ports are outside the migration scope. 2026-11-24: re-reviewed the ILM scanner-readiness preflight after a 4-node VM run (auto-testing 644b935, RustFS 2d90297) blocked all 14 ILM cases because followers report effective_interval_available=false with a zero effective interval by design; the effective-interval comparison now runs only on the leader. This is a test-oracle correction and adds no product live acceptance. 2026-11-24: refreshed the reviewed digest for rustfs-s3-compat-test.sh to match current main (a3a9e83 and 6feeeec changed that script without updating this ledger); this PR does not modify the script, and the same digest mismatch reproduces on a clean origin/main checkout. 2026-11-24: refreshed the reviewed digest again for rustfs-s3-compat-test.sh after 90b4fe1 changed that script without updating this ledger; the main push of ba6051d failed the contract-tests job. This follow-up does not modify the script. 2026-11-24: accepted the product last_cycle_partial_reason=unknown sentinel in the ILM scanner-readiness preflight after a healthy leader was still blocked; this is a test-oracle correction and adds no product live acceptance. 2026-11-24: reviewed the new STOR-135 DeepKeyListingResilience case in rustfs-storage-test.sh (backlog#3293): a 301-segment key PUT followed by a recursive ListObjectsV2 must either return the key or fail with a controlled error while the server stays alive, and GET must return the same bytes. This is a test-oracle addition guarding the scan_dir recursion-depth fix; it adds no product live acceptance. 2026-11-25: fixed the S3C-206 fixture to send the single encoded metadata value it expects; the previous fixture sent two encoded words and the product preserved them exactly, so the case falsely failed. 2026-11-23: added strict SSE contract procedures ENC-201..ENC-210 (S3 compatibility suite) and KMS-601..KMS-609 (KMS suite), executed by scripts/sse_contract_cases.py and individually dispatchable; they were exercised against local single-process servers started with each suite's environment, which is no fleet live acceptance. 2026-11-26: indexed STOR-136 for disk-compressed Range GET on a single-node single-disk deployment, with exact response bytes and a positive bounded process read-byte delta. 2026-11-26: re-reviewed the shared scanner cycle oracle after four-node USAGE-01/20 retests. An explicitly incomplete empty response without a scan identity remains eligible for polling, published epochs use integer identifiers, and exact convergence, monotonicity, and cleanup assertions remain required. The existing migration and live acceptance states are unchanged. 2026-11-28: reviewed STOR-137 and its four-node selector, request-correlated quota lock oracle, concurrent response evidence, and hard-cap assertion. The dry-run and positive and negative mocked checks add no live fleet evidence. 2026-11-28: re-reviewed the S3 and IAM canonical selectors, strict negative responses, multipart part-size fixtures and upgrade observation windows at the reviewed testing commit. Existing migration acceptance records retain their original provenance. 2026-11-29: added local module pool-hot-reload-regressions (pool.hot-reload-expand, pool.hot-reload-decommission, pool.hot-reload-negative-guards) in validation-cases.json, wired case_plan.py and pool_behavior.py hot-reload assertions, and extended test_validation_pool.py; existing immutable source snapshot counts and live acceptance states are unchanged. 2026-11-29: re-reviewed EVT-106 queue-file identification, permission cleanup, independent healthy deliveries, and recovery without a new write. The procedure failed on baseline and passed on the fix in local non-root Docker; canonical live results retain their historical evidence.", + "evidence_basis": "20261026-canonical-migration-ledger-7094.json plus later G01/G02 attempts and source review on 2026-10-28; historical result bytes and audit reports remain in the separate evidence store. 2026-11-10: a scoped re-review of the Rebalance activity fixture, capacity admission, Started non-zero progress, and the early-completion diagnosis; this local regression adds no product live acceptance. 2026-11-22: reviewed the replication inventory pagination, Heal census completeness, expected-manifest comparison, ILM control survival, and exact marker oracles after automated review findings. Reviewed the 10-version NewerNoncurrentVersions retention procedure and source/target version-purge convergence evidence for this change. 2026-11-22: indexed the source-audit inventory and added individually dispatchable local compatibility and source-suite procedure entries with selector and candidate-admission checks. 2026-11-22: added table-catalog and upgrade procedure selectors with shared validation artifact wiring; dry-run selectors cover all 25 newly indexed procedures. 2026-11-22: clarified that source-native tests are used as assertion and boundary-value references; one-to-one native ports are outside the migration scope. 2026-11-24: re-reviewed the ILM scanner-readiness preflight after a 4-node VM run (auto-testing 644b935, RustFS 2d90297) blocked all 14 ILM cases because followers report effective_interval_available=false with a zero effective interval by design; the effective-interval comparison now runs only on the leader. This is a test-oracle correction and adds no product live acceptance. 2026-11-24: refreshed the reviewed digest for rustfs-s3-compat-test.sh to match current main (a3a9e83 and 6feeeec changed that script without updating this ledger); this PR does not modify the script, and the same digest mismatch reproduces on a clean origin/main checkout. 2026-11-24: refreshed the reviewed digest again for rustfs-s3-compat-test.sh after 90b4fe1 changed that script without updating this ledger; the main push of ba6051d failed the contract-tests job. This follow-up does not modify the script. 2026-11-24: accepted the product last_cycle_partial_reason=unknown sentinel in the ILM scanner-readiness preflight after a healthy leader was still blocked; this is a test-oracle correction and adds no product live acceptance. 2026-11-24: reviewed the new STOR-135 DeepKeyListingResilience case in rustfs-storage-test.sh (backlog#3293): a 301-segment key PUT followed by a recursive ListObjectsV2 must either return the key or fail with a controlled error while the server stays alive, and GET must return the same bytes. This is a test-oracle addition guarding the scan_dir recursion-depth fix; it adds no product live acceptance. 2026-11-25: fixed the S3C-206 fixture to send the single encoded metadata value it expects; the previous fixture sent two encoded words and the product preserved them exactly, so the case falsely failed. 2026-11-23: added strict SSE contract procedures ENC-201..ENC-210 (S3 compatibility suite) and KMS-601..KMS-609 (KMS suite), executed by scripts/sse_contract_cases.py and individually dispatchable; they were exercised against local single-process servers started with each suite's environment, which is no fleet live acceptance. 2026-11-26: indexed STOR-136 for disk-compressed Range GET on a single-node single-disk deployment, with exact response bytes and a positive bounded process read-byte delta. 2026-11-26: re-reviewed the shared scanner cycle oracle after four-node USAGE-01/20 retests. An explicitly incomplete empty response without a scan identity remains eligible for polling, published epochs use integer identifiers, and exact convergence, monotonicity, and cleanup assertions remain required. The existing migration and live acceptance states are unchanged. 2026-11-28: reviewed STOR-137 and its four-node selector, request-correlated quota lock oracle, concurrent response evidence, and hard-cap assertion. The dry-run and positive and negative mocked checks add no live fleet evidence. 2026-11-28: re-reviewed the S3 and IAM canonical selectors, strict negative responses, multipart part-size fixtures and upgrade observation windows at the reviewed testing commit. Existing migration acceptance records retain their original provenance. 2026-11-29: added local module pool-hot-reload-regressions (pool.hot-reload-expand, pool.hot-reload-decommission, pool.hot-reload-negative-guards) in validation-cases.json, wired case_plan.py and pool_behavior.py hot-reload assertions, and extended test_validation_pool.py; existing immutable source snapshot counts and live acceptance states are unchanged. 2026-11-29: re-reviewed EVT-106 queue-file identification, permission cleanup, independent healthy deliveries, and recovery without a new write. The procedure failed on baseline and passed on the fix in local non-root Docker; canonical live results retain their historical evidence. 2026-11-30: reviewed IAM-105 bucket cleanup and prefixed AWS CLI error handling using local fixtures.", "reviewed_files": { "scripts/run_validation_case.sh": "58e0eb2fb007b28fb16b0fd4a25ac2f997cc9f01a4a3700c01fe7c9a6dd1a683", "scripts/validation_heal/authority.py": "8f2225f184427674de1f45aff4c4976c812f9d70fd4bc927ce460726a4ff74a0", @@ -122,7 +122,7 @@ "test_validation_replication.py": "83e1b532e8a6a352c5e38de48799356157e1fad4f1f314ea8ad256fdecf942c5", "test_validation_scanner_usage.py": "e549bab36f5896844ff70ab6bf1d6b1825747e5cc5e9a5003a8336d70e8b8173", "rustfs-s3-compat-test.sh": "d983a6b1aea1bb4c073d505c9a0ec61a96edec64f32ded49e04ede258e283687", - "rustfs-security-test.sh": "9f4e6ca7409a08f0b84d286d29c9c107d32f109b046cf9199e8ba7495a74eb3b", + "rustfs-security-test.sh": "2eee9be184c728e5dc8213f8450d8dc668de5885b573c0191ffa83e3c59efffc", "rustfs-tier-test.sh": "37884ee8ce090430fe1b8a3d187a2c968aab99f8fa5847ec0d8747cdfa94c9c2", "rustfs-storage-test.sh": "978e15585e373e763f9f1d6e9f70d4cd308c5b986a43ee53acc46cdfb0dcc829", "rustfs-kms-test.sh": "4a20d95a04287fa4d84d1ce58e074725cd0507163eaeb6e27e0ea7fc098c3bb0", @@ -133,7 +133,7 @@ "test_source_procedure_catalog.py": "ed50ad0e8a0aeef2e947b9f090ffcfd00420fe5f1ef85157b4fc8deb2280e5c7", "test_validation_s3_compatibility.py": "c1978bc5eaec91c07d65ebc2460644b81f73c48b63fe382d79508d45a5b573bb", "rustfs-table-test.sh": "79ab30545c7b532c6bc189907e83d45d41b1b4968e616e319009d29394124ce5", - "rustfs-upgrade-test.sh": "11e3011360672ca26fdb7cf82147727d5e14222512220bbdaf358e34e1fec590", + "rustfs-upgrade-test.sh": "6a4d60d82146606aff89a32a063278d93cfc03a8f785e90e748f0e69108a8ce9", "scripts/validation_catalog.py": "70ceb89b9739b09bce7db42673087da39087087c20f5b661b6d29ad34428a028" }, "cases": [