diff --git a/.github/workflows/validation-catalog-tests.yml b/.github/workflows/validation-catalog-tests.yml index 2b404a8..715613b 100644 --- a/.github/workflows/validation-catalog-tests.yml +++ b/.github/workflows/validation-catalog-tests.yml @@ -79,6 +79,7 @@ on: - test_validation_scanner_usage.py - rustfs-scanner-usage-test.sh - scripts/validation_scanner_usage/** + - testdata/scanner-usage/** - docs/scanner-usage-validation.md - .github/workflows/validation-catalog-tests.yml push: @@ -160,6 +161,7 @@ on: - test_validation_scanner_usage.py - rustfs-scanner-usage-test.sh - scripts/validation_scanner_usage/** + - testdata/scanner-usage/** - docs/scanner-usage-validation.md - .github/workflows/validation-catalog-tests.yml diff --git a/README.md b/README.md index 50d3abe..0bdccf4 100644 --- a/README.md +++ b/README.md @@ -166,10 +166,7 @@ cases use single-disk deployment. The scanner case uses the storage suite's single-node four-disk deployment, waits for a post-upload successful scanner cycle, and requires a complete usage snapshot with exactly 20 objects and 20,690 logical bytes. -The separate `scanner-usage-regressions` module adds USAGE-01 through USAGE-20 -without changing that strict smoke test or the 158 source catalog cases. -Run it explicitly with `rustfs-scanner-usage-test.sh` against existing endpoints; -see [the usage regression contracts and evidence requirements](docs/scanner-usage-validation.md). +The `scanner-usage-regressions` module includes endpoint probes, native scanner tests and USAGE-22, which checks Helm checkpoint recovery in a disposable Kubernetes namespace. Select a case with `rustfs-scanner-usage-test.sh`. [Scanner usage cases and prerequisites](docs/scanner-usage-validation.md). Public observations cannot prove internal ACK ordering or cross-cycle races, so missing candidate-native hooks remain BLOCKED or UNSUPPORTED. The endpoint-only usage runner records operator-supplied candidate and binary diff --git a/docs/scanner-usage-validation.md b/docs/scanner-usage-validation.md index bef220d..ea55b46 100644 --- a/docs/scanner-usage-validation.md +++ b/docs/scanner-usage-validation.md @@ -1,10 +1,8 @@ # Scanner usage regression suite -This suite registers the twenty USAGE acceptance contracts from backlog issue #3178 and the local-drive retirement regression from rustfs/rustfs#9469. It implements public probes and a strict adapter for candidate-native tests. Registration alone is not test implementation or acceptance: each native assertion needs an executable, reviewed candidate binding before the complete case is available. -It runs against **explicitly configured endpoints**. It never installs RustFS, -changes scanner settings, restarts a node, acquires a VM deployment lock, or -deletes system metadata. It creates random `usage--*` buckets and deletes -only buckets that this invocation successfully created. `owned-buckets.json` +This suite registers the twenty USAGE acceptance contracts from backlog issue #3178, the local-drive retirement regression from rustfs/rustfs#9469 and the Helm checkpoint restore regression from rustfs/rustfs#9672. Native assertions require an executable candidate binding. USAGE-22 runs in its own Kubernetes namespace. + +The public S3 probes run against **explicitly configured endpoints**. They leave the deployment, scanner settings, nodes, VM locks and system metadata alone. They create random `usage--*` buckets and delete only buckets that this invocation successfully created. `owned-buckets.json` retains the exact names and create intents if cleanup fails. A separate `acknowledged-requests.jsonl` appends each acknowledged PUT and DELETE without rewriting previous requests. An unacknowledged create remains in `unconfirmed_creates` and forces @@ -91,6 +89,22 @@ duration and error. That duration includes AWS CLI startup. It is **not** a saturation benchmark or a matched A/B throughput claim; its comparison/native assertion remains blocked without the corresponding evidence. +## Helm checkpoint restore (USAGE-22) + +Run this case with Helm, kubectl, `rc`, a packaged RustFS chart and an explicitly selected disposable Kubernetes context. The chart's image must match the candidate manifest. The runner checks the SHA-256 of the running binary. + +```bash +bash rustfs-scanner-usage-test.sh \ + --cases USAGE-22 --helm-chart ./rustfs-1.0.7.tgz --kube-context kind-usage \ + --candidate-manifest ./candidate.json --artifacts-dir ./usage-22-results +``` + +For the four-argument canonical runner, select `scanner.usage-22-helm-checkpoint-restore` and export `RUSTFS_USAGE_HELM_CHART` and `RUSTFS_USAGE_KUBE_CONTEXT`. + +The case starts the standalone chart's pod spec in a new namespace. An init container seeds its data volume with a 2,085,052-byte paged checkpoint and one 16-byte object. The checkpoint describes 4,096 old entries and the disk has no published usage snapshot. The RustFS process runs as non-root with a read-only root and the chart's own temporary mounts. The case passes when the Admin API publishes a complete, converged snapshot with exactly one object and 16 bytes at both bucket and cluster level. The runner deletes the test namespace on exit. + +The [seed archive](../testdata/scanner-usage/paged-checkpoint-1.0.7.tgz) was written by RustFS 1.0.7. To rebuild it, append the [fixture generator](../testdata/scanner-usage/generate_checkpoint.rs) to `crates/scanner/src/scanner/tests/paged_checkpoint.rs` in a scratch checkout of that tag. Set `USAGE_22_OUTPUT` to a new directory and run `cargo test --locked -p rustfs-scanner --lib -- scanner::tests::paged_checkpoint::seed_helm_checkpoint_restore --exact --nocapture`. From `$USAGE_22_OUTPUT/pool0/disk0`, archive only `.rustfs.sys/format.json`, `.rustfs.sys/pool.bin`, `.rustfs.sys/pool.bin.identity`, `.rustfs.sys/buckets/bucket` and `bucket/item`. Each new fixture has its own disk and bucket identities. When replacing the archive, update its SHA-256 in `scripts/validation_scanner_usage/helm_checkpoint.py` and rerun both charts. + ## Native capability adapter Public APIs cannot prove a scanned frontier, a budget-stop reason, an epoch @@ -169,7 +183,7 @@ covers only A01; A02 through A08 still need their own reviewed tests and markers ## Acceptance mapping -The public-probe column identifies executable probes in this repository. The additional-evidence column states the remaining contract, not a claim that a native test already implements it. USAGE-01 and USAGE-20 have complete public probes; every other case requires candidate-native implementation and bindings for all of its native assertions. A missing binding is an implementation/integration gap even when the report correctly records BLOCKED or UNSUPPORTED. +The public-probe column identifies executable probes in this repository. USAGE-01 and USAGE-20 have complete endpoint probes. USAGE-22 uses a disposable Kubernetes context. The other cases need candidate-native bindings for their native assertions. A missing binding leaves the case BLOCKED or UNSUPPORTED. | Design case | Public probe | Additional native or controlled-fleet evidence | | --- | --- | --- | @@ -194,6 +208,7 @@ The public-probe column identifies executable probes in this repository. The add | USAGE-19 | None | Quota v1/v2 and legacy fallback decisions | | USAGE-20 | Object/prefix collision, versions, markers and payloads | Marker-only keys remain an explicit follow-up fixture | | USAGE-21 | None | Local wrapper identity at distributed startup, recovery after retirement and exact durable totals | +| USAGE-22 | Read the first converged usage after a large checkpoint restore | Standalone Helm pod, read-only root and a seeded data volume | Bind `USAGE-21-A01` to `scanner_io::tests::local_drive_recovery::issue_9469_recovers_retired_wrapper_before_first_object` in the candidate's `rustfs-scanner` test binary. The test replaces the retired wrapper with one that has the same persisted format identity. It requires two total attempts, reloads a completed bucket cache with three objects and 21 logical bytes, and emits the cleanup milestone after removing its temporary data. diff --git a/scripts/validation_scanner_usage/contracts.py b/scripts/validation_scanner_usage/contracts.py index b37dc6a..4d0d64c 100644 --- a/scripts/validation_scanner_usage/contracts.py +++ b/scripts/validation_scanner_usage/contracts.py @@ -107,6 +107,8 @@ def design_id(self): Case(21, "retired-local-drive", "Recover a local drive retired before the first object", None, ( ("native", "After the local wrapper retires before the first object, the scanner retries once on the current wrapper with the same format identity and persists a complete cache with exact object and byte totals."), ("native", "Distributed erasure startup keeps the registered local drive's scan token active and retires only a distinct input wrapper that it replaces."))), + Case(22, "helm-checkpoint-restore", "Publish usage after a large checkpoint restore with a read-only root", None, ( + ("helm", "The chart's non-root container restores a paged checkpoint larger than 1 MiB and publishes a fresh snapshot matching the fixture's one object and 16 logical bytes."),)), ) @@ -131,7 +133,7 @@ def catalog_module() -> dict: "target_environments": ["configured-endpoint", "native-test"], "required_capabilities": ["explicit-endpoint", "candidate-provenance"], "cases": [{"id": case.id, "source_status": "procedure-ready", "priority": "P1", - "channels": ["admin-api", "s3-api", "native-test"], + "channels": ["admin-api", "kubernetes"] if case.number == 22 else ["admin-api", "s3-api", "native-test"], "assertions": [text for _, text in case.assertions], "probes": {"designCode": case.design_id, "procedure": "docs/scanner-usage-validation.md", diff --git a/scripts/validation_scanner_usage/helm_checkpoint.py b/scripts/validation_scanner_usage/helm_checkpoint.py new file mode 100644 index 0000000..4d8222d --- /dev/null +++ b/scripts/validation_scanner_usage/helm_checkpoint.py @@ -0,0 +1,134 @@ +"""Exercise #9672 in a RustFS pod rendered from the chart under test.""" + +import json +from pathlib import Path +import secrets +import tempfile +import time + +from .client import ProbeError, bucket_view, integer, run_command, sha256 + + +FIXTURE = Path(__file__).resolve().parents[2] / "testdata/scanner-usage/paged-checkpoint-1.0.7.tgz" +FIXTURE_SHA256 = "ed05a2399315ae1dfc0b27d93b412f61ebd0bcedf33e869dc8bf4bd40dc2dca6" + + +def command(args, timeout=30): + result = run_command(args, timeout) + if result["timed_out"]: + raise ProbeError(f"{args[0]} timed out after {timeout}s") + if result["exit_code"] != 0: + raise ProbeError(f"{args[0]} failed: {result['stderr'][-1000:]}") + return result["stdout"] + + +def check_snapshot(snapshot): + if not isinstance(snapshot, dict): + raise ProbeError("Admin returned an invalid data usage snapshot", "FAIL") + bucket = bucket_view(snapshot, "bucket") + totals = (snapshot.get("objects_total_count"), snapshot.get("objects_total_size")) + return (bool(snapshot.get("last_update")) and integer(snapshot.get("scanner_cycle")) + and bucket["converged"] and (bucket["count"], bucket["size"]) == (1, 16) + and all(integer(value) for value in totals) and totals == (1, 16)) + + +def run(options, provenance, evidence, cleanup): + if options.execution == "native" or not options.helm_chart or not options.kube_context: + raise ProbeError("USAGE-22 requires --helm-chart and --kube-context for a disposable Kubernetes cluster", "BLOCKED") + chart = options.helm_chart.resolve(strict=True) + if not chart.is_file(): + raise ProbeError("--helm-chart must name a packaged RustFS chart") + if sha256(FIXTURE) != FIXTURE_SHA256: + raise ProbeError("The seed archive differs from the verified 2,085,052-byte checkpoint fixture") + namespace = "usage-22-" + secrets.token_hex(10) + kube = ["kubectl", "--context", options.kube_context] + namespaced = [*kube, "--namespace", namespace] + evidence.save("fixture-inputs", { + "namespace": namespace, "context": options.kube_context, "chart_sha256": sha256(chart), + "seed_sha256": FIXTURE_SHA256, "checkpoint_bytes": 2085052, + }) + cleanup.update(status="FAIL", namespace=namespace, context=options.kube_context, creation_confirmed=False) + command([*kube, "create", "namespace", namespace]) + cleanup["creation_confirmed"] = True + try: + with tempfile.TemporaryDirectory() as scratch: + install_pod(namespaced, chart, namespace, Path(scratch)) + command([*namespaced, "wait", "--for=condition=Ready", "pod/rustfs", "--timeout=180s"], 190) + pod = json.loads(command([*namespaced, "get", "pod", "rustfs", "-o", "json"])) + app = rustfs_container(pod["spec"]) + execute = [*namespaced, "exec", "rustfs", "-c", "rustfs", "--"] + uid = int(command([*execute, "id", "-u"]).strip()) + if app.get("securityContext", {}).get("readOnlyRootFilesystem") is not True or uid <= 0: + raise ProbeError("The RustFS container must run as non-root with a read-only root filesystem", "FAIL") + binary = command([*execute, "sha256sum", "/usr/bin/rustfs"]).partition(" ")[0] + if binary != provenance["binary_sha256"]: + raise ProbeError("The running RustFS binary differs from the candidate manifest") + request = ('exec curl --noproxy "*" -fsS --max-time 10 --aws-sigv4 aws:amz:us-east-1:s3 ' + '--user "$RUSTFS_ACCESS_KEY:$RUSTFS_SECRET_KEY" http://127.0.0.1:9000/rustfs/admin/v3/datausageinfo') + deadline = time.monotonic() + options.convergence_timeout + while True: + snapshot = json.loads(command([*execute, "sh", "-ec", request])) + logs = command([*namespaced, "logs", "rustfs", "-c", "rustfs", "--tail=150"]) + for line in logs.splitlines(): + if "Read-only file system" in line and "cache" in line.lower() and "scanner" in line.lower(): + evidence.save("restore-error", {"message": line, "snapshot": snapshot}) + raise ProbeError("Scanner cache restore failed with a read-only filesystem", "FAIL") + if check_snapshot(snapshot): + return evidence.save("published-usage", { + "image": app["image"], "binary_sha256": binary, "uid": uid, + "read_only_root": True, "snapshot": snapshot, + }) + remaining = deadline - time.monotonic() + if remaining <= 0: + evidence.save("last-usage", snapshot) + raise ProbeError("Scanner did not publish the fixture's exact object and byte totals", "FAIL") + time.sleep(min(options.poll_interval, remaining)) + finally: + try: + command([*kube, "delete", "namespace", namespace, "--timeout=120s"], 130) + except (OSError, ProbeError) as exc: + raise ProbeError(f"Could not remove fixture namespace {namespace}: {exc}", cleanup_status="FAIL") from exc + cleanup["status"] = "PASS" + + +def rustfs_container(spec): + for container in spec.get("containers", []): + if container.get("name") == "rustfs": + return container + raise ProbeError("The rendered workload is missing the RustFS container") + + +def install_pod(kube, chart, namespace, scratch): + # Keep the chart's RustFS command, security context and /tmp wiring. Only + # /data is seeded, before the server starts and before any usage snapshot exists. + data_mount = {"name": "fixture-data", "mountPath": "/data"} + values = { + "mode": {"standalone": {"enabled": True}, "distributed": {"enabled": False}}, + "config": {"rustfs": { + "obs_log_directory": "", + "scanner": {"speed": "fastest", "cycle_secs": "2", "start_delay_secs": "1"}, + }}, + "storageclass": {"dataStorageSize": ""}, + "serviceAccount": {"create": False}, + "secret": {"rustfs": {"access_key": "usage-fixture", "secret_key": secrets.token_hex(24)}}, + "extraVolumes": [{"name": "fixture-data", "emptyDir": {}}], + "extraVolumeMounts": [data_mount], + } + values_file = scratch / "values.json" + values_file.write_text(json.dumps(values)) + render = ["helm", "template", "rustfs", str(chart), "--namespace", namespace, "-f", str(values_file)] + manifest = scratch / "rendered.yaml" + manifest.write_text(command([*render, "-s", "templates/configmap.yaml", "-s", "templates/secret.yaml"])) + command([*kube, "create", "-f", str(manifest)]) + command([*kube, "create", "configmap", "checkpoint", f"--from-file=disk.tgz={FIXTURE}"]) + manifest.write_text(command([*render, "-s", "templates/deployment.yaml"])) + deployment = json.loads(command([*kube, "create", "--dry-run=client", "-f", str(manifest), "-o", "json"])) + spec = deployment["spec"]["template"]["spec"] + app = rustfs_container(spec) + spec["volumes"].append({"name": "checkpoint", "configMap": {"name": "checkpoint"}}) + spec.setdefault("initContainers", []).append({ + "name": "seed-checkpoint", "image": app["image"], "securityContext": app.get("securityContext", {}), + "command": ["tar", "--no-same-owner", "-xzf", "/seed/disk.tgz", "-C", "/data"], + "volumeMounts": [data_mount, {"name": "checkpoint", "mountPath": "/seed", "readOnly": True}]}) + manifest.write_text(json.dumps({"apiVersion": "v1", "kind": "Pod", "metadata": {"name": "rustfs"}, "spec": spec})) + command([*kube, "create", "-f", str(manifest)]) diff --git a/scripts/validation_scanner_usage/runner.py b/scripts/validation_scanner_usage/runner.py index 425b623..eed699c 100644 --- a/scripts/validation_scanner_usage/runner.py +++ b/scripts/validation_scanner_usage/runner.py @@ -19,6 +19,7 @@ from .client import Client, Evidence, ProbeError, bucket_view, endpoint_url, integer, run_command, sha256, utc_now from .contracts import CASES, assertion_id, select_cases from .cycle import CycleTracker +from . import helm_checkpoint from .native import run_native ROOT = Path(__file__).resolve().parents[2] @@ -412,7 +413,19 @@ def execute_case(case, directory, options, provenance, native_manifest=None, cli "verdict": "RUNNING", "started_at": utc_now(), "cleanup_status": "PENDING", "provenance": provenance, "assertions": [], "capabilities": {}, "hit_count": 0} records, errors = {}, [] + helm_cleanup = {} try: + if case.assertions[0][0] == "helm": + identifier = assertion_id(case, 0) + try: + path = helm_checkpoint.run(options, provenance, evidence, helm_cleanup) + except (OSError, ValueError, KeyError, ProbeError) as exc: + failure = exc if isinstance(exc, ProbeError) else ProbeError(str(exc)) + path = evidence.save("helm-checkpoint-error", {"reason": str(failure)}) + records[identifier] = {"status": failure.verdict, "reason": str(failure), "evidence": [path]} + raise failure + records[identifier] = {"status": "PASS", "evidence": [path]} + result["provenance"] = {**provenance, "binary_identity_source": "SHA-256 verified inside the RustFS pod"} if case.scenario and options.execution != "native": require(options.endpoints, "Explicit --endpoint is required for public probes", "BLOCKED") client = client_factory(options.endpoints, options.admin_endpoints, evidence, @@ -467,13 +480,16 @@ def execute_case(case, directory, options, provenance, native_manifest=None, cli finally: if fixture: cleanup, cleanup_path = fixture.cleanup() + elif helm_cleanup: + cleanup = helm_cleanup["status"] + cleanup_path = evidence.save("namespace-cleanup", helm_cleanup) else: cleanup = "PASS" cleanup_path = evidence.save("cleanup", {"status": "PASS", "owned_buckets": [], "reason": "no public fixture created"}) result["cleanup_status"] = cleanup if any(error.cleanup_status == "FAIL" for error in errors): result["cleanup_status"] = "FAIL" - if cleanup != "PASS": + if fixture and cleanup != "PASS": errors.append(ProbeError("Fixture cleanup failed; retain owned-buckets.json for scoped recovery")) for index, (_, text) in enumerate(case.assertions): identifier = assertion_id(case, index) @@ -525,6 +541,8 @@ def main(argv=None): parser.add_argument("--validation-case", help="one canonical validation ID") parser.add_argument("--endpoint", action="append", default=[]) parser.add_argument("--admin-endpoint", action="append", default=[]) + parser.add_argument("--helm-chart", type=Path, default=os.environ.get("RUSTFS_USAGE_HELM_CHART"), help="Packaged RustFS chart for USAGE-22") + parser.add_argument("--kube-context", default=os.environ.get("RUSTFS_USAGE_KUBE_CONTEXT"), help="Disposable Kubernetes context for USAGE-22") parser.add_argument("--artifacts-dir", "--validation-artifacts-dir", dest="artifacts", type=Path, required=True) parser.add_argument("--candidate-manifest", type=Path, required=True) parser.add_argument("--testing-commit") @@ -553,7 +571,8 @@ def main(argv=None): args.poll_interval, args.freshness_samples)), "Timeouts and sample counts must be positive", "INFRA_ERROR") require(2 <= args.objects <= 100000 and math.isfinite(args.load_seconds) and args.load_seconds >= 0, "Fixture counts or load duration are outside the supported bounds", "INFRA_ERROR") if args.dry_run: - print(json.dumps({"cases": [case.id for case in selected], "mutations": "suite-owned buckets only", + mutations = "suite-owned buckets and an isolated USAGE-22 namespace" if any(case.number == 22 for case in selected) else "suite-owned buckets only" + print(json.dumps({"cases": [case.id for case in selected], "mutations": mutations, "node_actions": [], "native_capability_required": [case.id for case in selected if any(kind == "native" for kind, _ in case.assertions)]}, indent=2)) return 0 @@ -571,7 +590,7 @@ def main(argv=None): provenance = {"candidate_url": candidate["package_url"], "candidate_sha256": candidate["package_sha256"], "binary_sha256": candidate["binary_sha256"], "source_commit": candidate["source_sha"], "testing_commit": actual_commit, "rc_path": str(Path(rc_path).resolve()), "rc_sha256": sha256(rc_path), - "binary_identity_source": "operator-supplied candidate manifest; suite does not deploy or inspect host binaries"} + "binary_identity_source": "operator-supplied candidate manifest"} native = json.loads(args.native_manifest.read_text()) if args.native_manifest else None args.artifacts.mkdir(parents=True) (args.artifacts / "run-configuration.json").write_text(json.dumps({ diff --git a/test_validation_scanner_usage.py b/test_validation_scanner_usage.py index bd24aa8..60d7b89 100644 --- a/test_validation_scanner_usage.py +++ b/test_validation_scanner_usage.py @@ -13,6 +13,7 @@ import signal import subprocess import sys +import tarfile import tempfile import threading import time @@ -27,6 +28,7 @@ from scripts.validation_scanner_usage.client import Client, Evidence, ProbeError, bucket_view, endpoint_url, run_command, sha256 from scripts.validation_scanner_usage.contracts import CASES, assertion_id, catalog_module, select_cases from scripts.validation_scanner_usage.cycle import CycleTracker +from scripts.validation_scanner_usage.helm_checkpoint import FIXTURE, FIXTURE_SHA256, check_snapshot from scripts.validation_scanner_usage.native import run_native from scripts.validation_scanner_usage.runner import execute_case, Fixture, main, render_report @@ -52,7 +54,7 @@ def options(**changes): value = dict(endpoints=["http://example.invalid:9000"], admin_endpoints=[], execution="combined", aws_bin="aws", region="us-east-1", request_timeout=1, convergence_timeout=0.002, native_timeout=2, poll_interval=0.001, - objects=3, freshness_samples=2, load_seconds=0) + objects=3, freshness_samples=2, load_seconds=0, helm_chart=None, kube_context=None) value.update(changes) return SimpleNamespace(**value) @@ -864,6 +866,33 @@ def interrupted_save(evidence, stem, value): class RegistrationTests(unittest.TestCase): + def test_helm_checkpoint_seed_has_no_published_usage_snapshot(self): + self.assertEqual(sha256(FIXTURE), FIXTURE_SHA256) + with tarfile.open(FIXTURE) as archive: + files = {member.name for member in archive if member.isfile()} + self.assertIn("bucket/item/xl.meta", files) + self.assertIn(".rustfs.sys/buckets/bucket/.usage-cache.bin/xl.meta", files) + self.assertTrue(any(name.startswith(".rustfs.sys/buckets/bucket/.usage-cache.bin.pages/") for name in files)) + system = {".rustfs.sys/format.json", ".rustfs.sys/pool.bin/xl.meta", ".rustfs.sys/pool.bin.identity/xl.meta"} + self.assertEqual({name for name in files if not name.startswith(("bucket/item/", ".rustfs.sys/buckets/bucket/"))}, system) + + def test_helm_checkpoint_requires_explicit_cluster_and_chart(self): + case, = select_cases("USAGE-22") + with tempfile.TemporaryDirectory() as directory, patch("scripts.validation_scanner_usage.helm_checkpoint.command") as command: + result = execute_case(case, directory, options(), PROVENANCE) + command.assert_not_called() + self.assertEqual((result["verdict"], result["hit_count"]), ("BLOCKED", 0)) + + def test_helm_checkpoint_requires_converged_bucket_and_cluster_totals(self): + sample = {"last_update": {"secs_since_epoch": 1, "nanos_since_epoch": 0}, "scanner_cycle": 1, + "usage_snapshot_complete": True, "usage_snapshot_converged": True, + "buckets_usage": {"bucket": {"objects_count": 1, "size": 16}}, "objects_total_count": 1, "objects_total_size": 16} + self.assertTrue(check_snapshot(sample)) + for change in ({"last_update": None}, {"scanner_cycle": None}, {"usage_snapshot_pending_buckets": ["bucket"]}, + {"objects_total_size": 15}, {"buckets_usage": {"bucket": {"objects_count": 4096, "size": 8390656}}}): + with self.subTest(change=change): + self.assertFalse(check_snapshot({**sample, **change})) + def test_cli_rejects_endpoint_secrets_before_artifacts_in_every_mode(self): with tempfile.TemporaryDirectory() as directory, patch.dict(os.environ, {}, clear=True): artifacts = Path(directory) / "must-not-exist" @@ -896,18 +925,18 @@ def test_native_cli_records_only_normalized_endpoints(self): self.assertEqual(config["endpoints"], ["http://host:9000"]) self.assertEqual(config["admin_endpoints"], ["http://host:9001"]) - def test_twenty_native_rows_without_capabilities_remain_blocked(self): + def test_all_rows_without_capabilities_remain_blocked_in_native_mode(self): with tempfile.TemporaryDirectory() as directory: with patch("scripts.validation_scanner_usage.runner.Client", side_effect=AssertionError("no endpoint access")) as client: results = [execute_case(case, directory, options(execution="native", endpoints=[]), PROVENANCE, client_factory=client) for case in select_cases("all")] client.assert_not_called() - self.assertEqual(len(results), 21) + self.assertEqual(len(results), 22) self.assertTrue(all(result["verdict"] == "BLOCKED" for result in results)) self.assertTrue(all(result["profile"] == "native-test" and result["hit_count"] == 0 for result in results)) self.assertTrue(all(result["cleanup_status"] == "PASS" for result in results)) self.assertTrue(all(assertion["status"] == "BLOCKED" for result in results for assertion in result["assertions"])) - self.assertEqual(len(list((Path(directory) / "cases").glob("*.json"))), 21) + self.assertEqual(len(list((Path(directory) / "cases").glob("*.json"))), 22) def test_usage_rows_are_registered_without_rewriting_source_counts(self): catalog = json.loads((ROOT / "validation-cases.json").read_text()) @@ -925,7 +954,7 @@ def test_usage_rows_are_registered_without_rewriting_source_counts(self): [case["id"] for module in catalog_modules(catalog) for case in module["cases"]], source_and_local_ids, ) - self.assertEqual(len(select_cases("all")), 21) + self.assertEqual(len(select_cases("all")), 22) self.assertEqual([case.number for case in select_cases("blackbox")], [1, 20]) self.assertNotIn(CASES[0].id, [case for case, _ in sweepable_cases(catalog)]) self.assertEqual(select_validation_cases(catalog, case=CASES[0].id), [(CASES[0].id, "scanner-usage-regressions")]) @@ -948,7 +977,7 @@ def test_dry_run_neither_reads_candidate_nor_creates_artifacts(self): "--cases", "all", "--artifacts-dir", str(destination), "--candidate-manifest", str(Path(directory) / "not-a-manifest")], 10) self.assertEqual(result["exit_code"], 0, result) - self.assertEqual(len(json.loads(result["stdout"])["cases"]), 21) + self.assertEqual(len(json.loads(result["stdout"])["cases"]), 22) self.assertFalse(destination.exists()) diff --git a/testdata/scanner-usage/generate_checkpoint.rs b/testdata/scanner-usage/generate_checkpoint.rs new file mode 100644 index 0000000..375452d --- /dev/null +++ b/testdata/scanner-usage/generate_checkpoint.rs @@ -0,0 +1,42 @@ +#[tokio::test] +async fn seed_helm_checkpoint_restore() { + let root = + std::path::PathBuf::from(std::env::var_os("USAGE_22_OUTPUT").expect("fixture output")); + assert!(!root.exists(), "fixture output must be new"); + let store = setup_scanner_cycle_store_at_path_with_layout(&root, false, 1, 1, 1).await; + store + .make_bucket("bucket", &Default::default()) + .await + .unwrap(); + let mut object = PutObjReader::from_vec(vec![7; 16]); + store + .put_object("bucket", "item", &mut object, &ObjectOptions::default()) + .await + .unwrap(); + crate::scanner_io::tests::wait_for_namespace_commit_tails(store.as_ref()).await; + + let mut checkpoint = empty_bucket_checkpoint(); + let suffix = "x".repeat(160); + for i in 0..4096 { + checkpoint.replace( + &format!("bucket/{i:05}-{suffix}"), + "bucket", + DataUsageEntry { + size: i + 1, + objects: 1, + versions: 1, + ..Default::default() + }, + ); + } + let bytes = checkpoint.marshal_msg().unwrap().len(); + assert!(bytes > 1024 * 1024); + let revisions = DataUsageCache::read_revisions(store.clone(), NAME) + .await + .unwrap(); + checkpoint + .save_with_revisions_for_epoch(store, NAME, &revisions, 0) + .await + .unwrap(); + println!("paged checkpoint: {bytes} bytes; expected current bucket: 1 object, 16 bytes"); +} diff --git a/testdata/scanner-usage/paged-checkpoint-1.0.7.tgz b/testdata/scanner-usage/paged-checkpoint-1.0.7.tgz new file mode 100644 index 0000000..568ade2 Binary files /dev/null and b/testdata/scanner-usage/paged-checkpoint-1.0.7.tgz differ diff --git a/validation-cases.json b/validation-cases.json index b606e99..cc597e7 100644 --- a/validation-cases.json +++ b/validation-cases.json @@ -4794,6 +4794,31 @@ ], "case_ids": [] } + }, + { + "id": "scanner.usage-22-helm-checkpoint-restore", + "source_status": "procedure-ready", + "priority": "P1", + "channels": [ + "admin-api", + "kubernetes" + ], + "assertions": [ + "The chart's non-root container restores a paged checkpoint larger than 1 MiB and publishes a fresh snapshot matching the fixture's one object and 16 logical bytes." + ], + "probes": { + "designCode": "USAGE-22", + "procedure": "docs/scanner-usage-validation.md", + "executionMode": "configured-endpoint", + "runner": "scripts/validation_scanner_usage/run_case.sh", + "publicScenario": null + }, + "reuse_candidates": { + "suites": [ + "rustfs-scanner-usage-test.sh" + ], + "case_ids": [] + } } ] }, diff --git a/validation-migration-review.json b/validation-migration-review.json index 9801e84..de01223 100644 --- a/validation-migration-review.json +++ b/validation-migration-review.json @@ -5,7 +5,7 @@ "source_sha256": "463fdd02dee43e42fef4f3aacf7506709ce87af535e1a53d91c521bc2e361cad", "reviewed_testing_commit": "5e76033d7ccad414aad1f7edb9867de6462eee43", "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.", + "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. Reviewed USAGE-22 namespace admission, fixture contents, post-restore totals and cleanup on 2026-11-27.", "reviewed_files": { "scripts/run_validation_case.sh": "58e0eb2fb007b28fb16b0fd4a25ac2f997cc9f01a4a3700c01fe7c9a6dd1a683", "scripts/validation_heal/authority.py": "8f2225f184427674de1f45aff4c4976c812f9d70fd4bc927ce460726a4ff74a0", @@ -115,18 +115,19 @@ "scripts/validation_ilm/oracles.py": "557d2f1e6065252a569faae94bea72ede114aef369563ad8c93abc156474ff60", "scripts/validation_replication/replication_behavior.py": "c42d29b43b8828f4d1293eb4a8a8c801277611d734e550f0ee6a0e09f733a584", "scripts/validation_replication/oracles.py": "f90539bd72ba8b5a4c5decf66d559cd7083379f809ef699dd1da62f80893a7d3", - "scripts/validation_scanner_usage/runner.py": "fabc8f2e0936aec686a1ba26b24130d69c564d89e017443e4247dc635990285e", + "scripts/validation_scanner_usage/runner.py": "2af83c02d6532793661fa7f98247e2ba450d7f6f27ae1d021a43fac6f3242157", + "scripts/validation_scanner_usage/helm_checkpoint.py": "d789d21e1c046c94afbd4c5873c22ae0d812a7758c2df2c385f886654e0f72f4", "scripts/validation_scanner_usage/cycle.py": "f8ec961e3760ca9ee7d7fe0477f21b256f7a00d3765a6a009fcdf5629450bfe5", "test_validation_heal_availability.py": "42e394d6c00359a6cb958d294af5c4eb5602c8cdb2b7c413d07584e2c9f79acc", "test_validation_ilm.py": "f4d361850f278a5be965f05ff8950d91347907be2253bfa31a1864ae5b2a730c", "test_validation_replication.py": "83e1b532e8a6a352c5e38de48799356157e1fad4f1f314ea8ad256fdecf942c5", - "test_validation_scanner_usage.py": "e549bab36f5896844ff70ab6bf1d6b1825747e5cc5e9a5003a8336d70e8b8173", + "test_validation_scanner_usage.py": "159769a0f36df64b6a961cb6857b7ecfeb2df8956292fb05dfc346a887d2a34c", "rustfs-s3-compat-test.sh": "31f986f574484da43f36fcc1ee74b0a088d83574202a91945a3473b49cab82aa", "rustfs-security-test.sh": "02cddd15636df1e74210c172ee898dba9b3adf83943da45d874d6c827583d9d2", "rustfs-tier-test.sh": "3b37a6b26a4af862d7f2d178872900f314c8328ffd3db6a3e769928a5d1b3964", "rustfs-storage-test.sh": "950657d31e2b9c33bc06e390f47ac166edf661573246e0900f6fa31b6a423b60", "rustfs-kms-test.sh": "4a20d95a04287fa4d84d1ce58e074725cd0507163eaeb6e27e0ea7fc098c3bb0", - "validation-cases.json": "07f674ae3e8eb8ca5ae77c8d85418d4755332939417999c92ae31a9603b11f66", + "validation-cases.json": "57d89d28dcc88f6e0b0f8f588572a9377a3229eab7edd4830b62933b4199f424", "docs/validation-migration-map.md": "b8dd536df1f1e14324f27bbe61cb3ea796aeb3f7220876c36a828e9d80a9dffc", "docs/source-test-migration-inventory.md": "ac434d583c69f9c2a1128e4a84eb52d9bf46395f3fe22383b2a2d5ce9a0bddd5", "test_source_test_migration_inventory.py": "5c0122c6940ea224e7bde57fa1159536ab9ef132cf9d34517fe27c053a56b972",