From 8c6689ff13a297cc741af3854dda7118d0243ea9 Mon Sep 17 00:00:00 2001 From: houseme Date: Tue, 8 Sep 2026 19:27:23 +0800 Subject: [PATCH] test(scanner): derive evidence runner profile from registry (#7484) Co-authored-by: zhi22915 --- scripts/check_test_wiring.py | 13 +++++++ scripts/run_scanner_heal_evidence_case.sh | 43 ++++++++++++++++------- 2 files changed, 44 insertions(+), 12 deletions(-) diff --git a/scripts/check_test_wiring.py b/scripts/check_test_wiring.py index e7b29a550..80c2577ec 100755 --- a/scripts/check_test_wiring.py +++ b/scripts/check_test_wiring.py @@ -956,6 +956,9 @@ def scanner_heal_oracle_names(root: Path) -> tuple[str, ...]: names = set() for case_id, requirement in cases.items(): require(isinstance(case_id, str) and case_id, "invalid scanner/heal case identity") + lane = requirement.get("lane") + require(isinstance(lane, str) and re.fullmatch(r"[a-z0-9-]+", lane) is not None, + f"invalid nextest profile lane for {case_id}") oracle = requirement.get("oracle") require(isinstance(oracle, str) and oracle.endswith(".json"), f"invalid oracle for {case_id}") path = Path(oracle) @@ -1667,6 +1670,16 @@ class SelfTests(unittest.TestCase): finish_scanner_heal_receipt(run_dir, 0, root) return root, run_dir + def test_scanner_heal_case_lane_is_required_for_runner_profile(self) -> None: + with tempfile.TemporaryDirectory() as tmp: + root, _ = self.scanner_heal_fixture(Path(tmp)) + registry_path = root / ".config/scanner-heal-required-tests.json" + registry = read_json(registry_path) + del registry["cases"]["ec84-target-drive-restart"]["lane"] + write_json(registry_path, registry) + with self.assertRaisesRegex(ValueError, "invalid nextest profile lane for ec84-target-drive-restart"): + scanner_heal_oracle_names(root) + def scanner_heal_release_bundle_fixture(self, directory: Path) -> tuple[Path, Path]: """Parser fixtures only; the bundle is not runtime evidence.""" root, _ = self.scanner_heal_fixture(directory) diff --git a/scripts/run_scanner_heal_evidence_case.sh b/scripts/run_scanner_heal_evidence_case.sh index 8cf918c77..7c61435b6 100755 --- a/scripts/run_scanner_heal_evidence_case.sh +++ b/scripts/run_scanner_heal_evidence_case.sh @@ -4,7 +4,7 @@ set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" PYTHON_BIN="${RUSTFS_PYTHON_BIN:-python3}" -PROFILE="e2e-nightly" +PROFILE="" CASE_ID="background-target-crash" RUN_DIR="" PLAN_ONLY=0 @@ -18,7 +18,7 @@ then validate the produced receipt, nextest listing, JUnit, and case oracle. Options: --case CASE Registry case to run (default: background-target-crash) - --profile PROFILE Nextest profile to use (default: e2e-nightly) + --profile PROFILE Nextest profile to use (default: registry lane) --run-dir DIR New evidence directory (default: target/scanner-heal-evidence/CASE-TIMESTAMP) --plan-only Validate registry selection and print the exact filter without running cargo --self-test Run lightweight CLI/registry checks without building Rust @@ -31,6 +31,18 @@ port allocator when the default 20000..30000 test range is unavailable. USAGE } +case_ids() { + "$PYTHON_BIN" - "$ROOT/.config/scanner-heal-required-tests.json" <<'PY' +import json +import pathlib +import sys + +registry = json.loads(pathlib.Path(sys.argv[1]).read_text()) +for case_id in sorted(registry["cases"]): + print(case_id) +PY +} + case_field() { local case_id="$1" local field="$2" @@ -109,20 +121,24 @@ PY } run_self_test() { - local filter - filter="$(test_filter_for background-target-crash)" - case "$filter" in - *background_target_crash*) ;; - *) - echo "self-test failed: crash case filter missing" >&2 - return 1 - ;; - esac if "$0" --case release --plan-only >/dev/null 2>&1; then echo "self-test failed: release pseudo-case must not be runnable" >&2 return 1 fi - "$0" --case background-target-crash --plan-only >/dev/null + local case_id + while IFS= read -r case_id; do + local expected_filter expected_profile plan + expected_filter="$(test_filter_for "$case_id")" + expected_profile="$(case_field "$case_id" lane)" + plan="$("$0" --case "$case_id" --plan-only)" + if [[ "$plan" != *"case=$case_id"* ]] || + [[ "$plan" != *"profile=$expected_profile"* ]] || + [[ "$plan" != *"filter=$expected_filter"* ]] || + [[ "$plan" != *"run_dir=$ROOT/target/scanner-heal-evidence/$case_id-"* ]]; then + echo "self-test failed: registry case plan mismatch for $case_id" >&2 + return 1 + fi + done < <(case_ids) } while [[ $# -gt 0 ]]; do @@ -166,6 +182,9 @@ fi case_field "$CASE_ID" name >/dev/null TEST_FILTER="$(test_filter_for "$CASE_ID")" +if [[ -z "$PROFILE" ]]; then + PROFILE="$(case_field "$CASE_ID" lane)" +fi case "$CASE_ID" in background-target-crash|background-target-restart) export RUSTFS_HEAL_CHAOS_OBJECT_COUNT="${RUSTFS_HEAL_CHAOS_OBJECT_COUNT:-64}"