From 7d81183cf1f6879e4794e221e4355559b955d878 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=AD=A3=E8=B6=85?= Date: Mon, 22 Jun 2026 14:55:12 +0800 Subject: [PATCH] refactor: use relative heal test compat consumers (#3733) --- crates/heal/src/error.rs | 2 +- crates/heal/src/heal/channel.rs | 2 +- crates/heal/tests/endpoint_index_test.rs | 2 +- crates/heal/tests/heal_bug_fixes_test.rs | 16 ++++++------ crates/heal/tests/heal_integration_test.rs | 2 +- .../tests/lifecycle_integration_test.rs | 2 +- docs/architecture/migration-progress.md | 25 +++++++++++++++---- rustfs/src/config/config_test.rs | 4 +-- scripts/check_architecture_migration_rules.sh | 20 +++++++++++++++ 9 files changed, 55 insertions(+), 20 deletions(-) diff --git a/crates/heal/src/error.rs b/crates/heal/src/error.rs index a11f51590..2d8fe0afa 100644 --- a/crates/heal/src/error.rs +++ b/crates/heal/src/error.rs @@ -14,7 +14,7 @@ use thiserror::Error; -use crate::heal::storage_compat::{DiskError, EcstoreError}; +use super::heal::storage_compat::{DiskError, EcstoreError}; /// Custom error type for heal operations /// This enum defines various error variants that can occur during diff --git a/crates/heal/src/heal/channel.rs b/crates/heal/src/heal/channel.rs index 947c329b5..b8d7ccd20 100644 --- a/crates/heal/src/heal/channel.rs +++ b/crates/heal/src/heal/channel.rs @@ -494,10 +494,10 @@ impl HealChannelProcessor { #[cfg(test)] mod tests { + use super::super::storage_compat::{DiskStore, Endpoint}; use super::*; use crate::heal::manager::HealConfig; use crate::heal::storage::{HealObjectInfo, HealStorageAPI}; - use crate::heal::storage_compat::{DiskStore, Endpoint}; use rustfs_common::heal_channel::{ HealAdmissionResult, HealChannelPriority, HealChannelRequest, HealRequestSource, HealScanMode, }; diff --git a/crates/heal/tests/endpoint_index_test.rs b/crates/heal/tests/endpoint_index_test.rs index 03702adb4..26f4f037d 100644 --- a/crates/heal/tests/endpoint_index_test.rs +++ b/crates/heal/tests/endpoint_index_test.rs @@ -16,7 +16,7 @@ mod common; -use crate::common::storage_compat::{ECStore, Endpoint, EndpointServerPools, Endpoints, PoolEndpoints, init_local_disks}; +use common::storage_compat::{ECStore, Endpoint, EndpointServerPools, Endpoints, PoolEndpoints, init_local_disks}; use std::net::SocketAddr; use tempfile::TempDir; use tokio_util::sync::CancellationToken; diff --git a/crates/heal/tests/heal_bug_fixes_test.rs b/crates/heal/tests/heal_bug_fixes_test.rs index 01e699f4f..26e76d0f5 100644 --- a/crates/heal/tests/heal_bug_fixes_test.rs +++ b/crates/heal/tests/heal_bug_fixes_test.rs @@ -22,7 +22,7 @@ use rustfs_heal::heal::{ #[test] fn test_heal_event_to_heal_request_no_panic() { - use crate::common::storage_compat::Endpoint; + use common::storage_compat::Endpoint; // Test that invalid pool/set indices don't cause panic // Create endpoint using try_from or similar method @@ -47,7 +47,7 @@ fn test_heal_event_to_heal_request_no_panic() { #[test] fn test_heal_event_to_heal_request_valid_indices() { - use crate::common::storage_compat::Endpoint; + use common::storage_compat::Endpoint; // Test that valid indices work correctly let endpoint_result = Endpoint::try_from("http://localhost:9000"); @@ -192,11 +192,11 @@ fn test_heal_task_status_atomic_update() { } async fn get_disk_status( &self, - _endpoint: &crate::common::storage_compat::Endpoint, + _endpoint: &common::storage_compat::Endpoint, ) -> rustfs_heal::Result { Ok(rustfs_heal::heal::storage::DiskStatus::Ok) } - async fn format_disk(&self, _endpoint: &crate::common::storage_compat::Endpoint) -> rustfs_heal::Result<()> { + async fn format_disk(&self, _endpoint: &common::storage_compat::Endpoint) -> rustfs_heal::Result<()> { Ok(()) } async fn get_bucket_info(&self, _bucket: &str) -> rustfs_heal::Result> { @@ -250,7 +250,7 @@ fn test_heal_task_status_atomic_update() { ) -> rustfs_heal::Result<(Vec, Option, bool)> { Ok((vec![], None, false)) } - async fn get_disk_for_resume(&self, _set_disk_id: &str) -> rustfs_heal::Result { + async fn get_disk_for_resume(&self, _set_disk_id: &str) -> rustfs_heal::Result { Err(rustfs_heal::Error::other("Not implemented in mock")) } } @@ -320,11 +320,11 @@ async fn test_heal_task_transient_object_exists_skip_avoids_recreate() { Ok(Vec::new()) } - async fn get_disk_status(&self, _endpoint: &crate::common::storage_compat::Endpoint) -> rustfs_heal::Result { + async fn get_disk_status(&self, _endpoint: &common::storage_compat::Endpoint) -> rustfs_heal::Result { Ok(DiskStatus::Ok) } - async fn format_disk(&self, _endpoint: &crate::common::storage_compat::Endpoint) -> rustfs_heal::Result<()> { + async fn format_disk(&self, _endpoint: &common::storage_compat::Endpoint) -> rustfs_heal::Result<()> { Ok(()) } @@ -394,7 +394,7 @@ async fn test_heal_task_transient_object_exists_skip_avoids_recreate() { Ok((Vec::new(), None, false)) } - async fn get_disk_for_resume(&self, _set_disk_id: &str) -> rustfs_heal::Result { + async fn get_disk_for_resume(&self, _set_disk_id: &str) -> rustfs_heal::Result { Err(rustfs_heal::Error::other("not implemented")) } } diff --git a/crates/heal/tests/heal_integration_test.rs b/crates/heal/tests/heal_integration_test.rs index 6b2cea79d..7f11eeb83 100644 --- a/crates/heal/tests/heal_integration_test.rs +++ b/crates/heal/tests/heal_integration_test.rs @@ -14,7 +14,7 @@ mod common; -use crate::common::storage_compat::{ +use common::storage_compat::{ ECStore, Endpoint, EndpointServerPools, Endpoints, PoolEndpoints, init_bucket_metadata_sys, init_local_disks, }; use http::HeaderMap; diff --git a/crates/scanner/tests/lifecycle_integration_test.rs b/crates/scanner/tests/lifecycle_integration_test.rs index 92fdc2ec8..a0142fdd8 100644 --- a/crates/scanner/tests/lifecycle_integration_test.rs +++ b/crates/scanner/tests/lifecycle_integration_test.rs @@ -14,7 +14,7 @@ mod common; -use crate::common::storage_compat::{ +use common::storage_compat::{ BUCKET_LIFECYCLE_CONFIG, BucketVersioningSys, DiskOption, ECStore, Endpoint, EndpointServerPools, Endpoints, GLOBAL_TierConfigMgr, PoolEndpoints, ReadCloser, ReaderImpl, STORAGE_FORMAT_FILE, ScannerTestDiskExt as _, ScannerWarmBackend, TierConfig, TierMinIO, TierType, TransitionOptions, WarmBackendGetOpts, build_transition_put_options, diff --git a/docs/architecture/migration-progress.md b/docs/architecture/migration-progress.md index 47e92fb9b..a6aeaedc6 100644 --- a/docs/architecture/migration-progress.md +++ b/docs/architecture/migration-progress.md @@ -609,6 +609,19 @@ Status values: `[ ]` not started, `[~]` in progress, `[x]` complete, `[!]` block compatibility consumer residual scan, migration and layer guards, formatting, diff hygiene, Rust risk scan, pre-commit quality gate, and three-expert review. +- [x] `API-114` Collapse config, heal, and scanner test compatibility consumers. + - Completed slice: replace crate-qualified config test, heal crate, and + heal/scanner integration test local compatibility consumers with relative + owner paths. + - Acceptance: selected config, heal, and scanner test harnesses no longer + point back to local compatibility facades through crate-qualified paths; + migration rules reject regressions. + - Must preserve: config layout parsing tests, heal channel/storage test + coverage, endpoint index tests, and scanner lifecycle integration coverage. + - Verification: RustFS test-target compile coverage, config/heal/scanner + local compatibility consumer residual scan, migration and layer guards, + formatting, diff hygiene, Rust risk scan, pre-commit quality gate, and + three-expert review. - [x] `G-012` Inventory placement and repair invariants. - Acceptance: [`placement-repair-invariants.md`](placement-repair-invariants.md) records @@ -3642,23 +3655,25 @@ Status values: `[ ]` not started, `[~]` in progress, `[x]` complete, `[!]` block | Expert | Status | Notes | |---|---|---| -| Quality/architecture | pass | API-113 keeps selected app context/server local compatibility consumers owner-relative by replacing crate-qualified compatibility paths with scoped `super::` or `super::super::` paths. | -| Migration preservation | pass | The new guard rejects crate-qualified app context/server local compatibility consumer paths while preserving the same facade names and aliases. | -| Testing/verification | pass | Focused compile, app context/server local compatibility consumer residual scan, migration guard, layer guard, formatting, diff hygiene, risk scan, and full pre-commit passed. | +| Quality/architecture | pass | API-114 keeps selected config/heal/scanner local compatibility consumers owner-relative by replacing crate-qualified compatibility paths with scoped relative paths. | +| Migration preservation | pass | The new guard rejects crate-qualified config/heal/scanner local compatibility consumer paths while preserving the same facade names and aliases. | +| Testing/verification | pass | Focused compile, config/heal/scanner local compatibility consumer residual scan, migration guard, layer guard, formatting, diff hygiene, risk scan, and full pre-commit passed. | ## Verification Notes Passed before push: -- Issue #660 API-113 current slice: +- Issue #660 API-114 current slice: - `cargo check -p rustfs --tests`: passed. + - `cargo check -p rustfs-heal --tests`: passed. + - `cargo check -p rustfs-scanner --tests`: passed. - `cargo fmt --all`: passed. - `cargo fmt --all --check`: passed. - `git diff --check`: passed. - `bash -n scripts/check_architecture_migration_rules.sh`: passed. - `./scripts/check_architecture_migration_rules.sh`: passed. - `./scripts/check_layer_dependencies.sh`: passed. - - App context/server local compatibility consumer residual scan: passed. + - Config/heal/scanner local compatibility consumer residual scan: passed. - Rust risk scan on changed Rust files and guard script: passed. - `make pre-commit`: passed. diff --git a/rustfs/src/config/config_test.rs b/rustfs/src/config/config_test.rs index 5c80060ba..c2f9d8cb3 100644 --- a/rustfs/src/config/config_test.rs +++ b/rustfs/src/config/config_test.rs @@ -15,8 +15,8 @@ #[cfg(test)] #[allow(unsafe_op_in_unsafe_fn)] mod tests { + use super::super::super::config_storage_compat::DisksLayout; use crate::config::{CommandResult, Config, Opt, TlsCommands}; - use crate::config_storage_compat::DisksLayout; use rustfs_config::{DEFAULT_CONSOLE_ADDRESS, DEFAULT_CONSOLE_ENABLE, DEFAULT_OBS_ENDPOINT, RUSTFS_REGION}; use rustfs_credentials::{DEFAULT_ACCESS_KEY, DEFAULT_SECRET_KEY}; use serial_test::serial; @@ -262,7 +262,7 @@ mod tests { #[test] #[serial] fn test_volumes_and_disk_layout_parsing() { - use crate::config_storage_compat::DisksLayout; + use super::super::super::config_storage_compat::DisksLayout; // Test case 1: Single volume path let args = vec!["rustfs", "/data/vol1"]; diff --git a/scripts/check_architecture_migration_rules.sh b/scripts/check_architecture_migration_rules.sh index c1bb441bb..f37911984 100755 --- a/scripts/check_architecture_migration_rules.sh +++ b/scripts/check_architecture_migration_rules.sh @@ -105,6 +105,7 @@ RUSTFS_LOCAL_COMPAT_RELATIVE_CONSUMER_HITS_FILE="${TMP_DIR}/rustfs_local_compat_ RUSTFS_STORAGE_LOCAL_COMPAT_RELATIVE_CONSUMER_HITS_FILE="${TMP_DIR}/rustfs_storage_local_compat_relative_consumer_hits.txt" RUSTFS_ADMIN_LOCAL_COMPAT_RELATIVE_CONSUMER_HITS_FILE="${TMP_DIR}/rustfs_admin_local_compat_relative_consumer_hits.txt" RUSTFS_APP_SERVER_LOCAL_COMPAT_RELATIVE_CONSUMER_HITS_FILE="${TMP_DIR}/rustfs_app_server_local_compat_relative_consumer_hits.txt" +RUSTFS_HEAL_TEST_LOCAL_COMPAT_RELATIVE_CONSUMER_HITS_FILE="${TMP_DIR}/rustfs_heal_test_local_compat_relative_consumer_hits.txt" SCANNER_BUCKET_STORAGE_COMPAT_MODULE_HITS_FILE="${TMP_DIR}/scanner_bucket_storage_compat_module_hits.txt" NOTIFY_STORAGE_COMPAT_MODULE_HITS_FILE="${TMP_DIR}/notify_storage_compat_module_hits.txt" OBS_STORAGE_COMPAT_PASSTHROUGH_HITS_FILE="${TMP_DIR}/obs_storage_compat_passthrough_hits.txt" @@ -1152,6 +1153,25 @@ if [[ -s "$RUSTFS_APP_SERVER_LOCAL_COMPAT_RELATIVE_CONSUMER_HITS_FILE" ]]; then report_failure "RustFS app context/server compatibility consumers must use relative owner paths instead of crate-qualified local compatibility paths: $(paste -sd '; ' "$RUSTFS_APP_SERVER_LOCAL_COMPAT_RELATIVE_CONSUMER_HITS_FILE")" fi +( + cd "$ROOT_DIR" + { + rg -n --with-filename 'crate::config_storage_compat' \ + rustfs/src/config/config_test.rs || true + rg -n --with-filename 'crate::heal::storage_compat' \ + crates/heal/src/error.rs \ + crates/heal/src/heal/channel.rs || true + rg -n --with-filename 'crate::common::storage_compat' \ + crates/heal/tests \ + crates/scanner/tests \ + -g '*.rs' || true + } +) >"$RUSTFS_HEAL_TEST_LOCAL_COMPAT_RELATIVE_CONSUMER_HITS_FILE" + +if [[ -s "$RUSTFS_HEAL_TEST_LOCAL_COMPAT_RELATIVE_CONSUMER_HITS_FILE" ]]; then + report_failure "RustFS config/heal/scanner compatibility consumers must use relative owner paths instead of crate-qualified local compatibility paths: $(paste -sd '; ' "$RUSTFS_HEAL_TEST_LOCAL_COMPAT_RELATIVE_CONSUMER_HITS_FILE")" +fi + ( cd "$ROOT_DIR" rg -n --no-heading 'pub\(crate\)\s+use rustfs_ecstore::api::bucket::\{[^}]*\b(?:bucket_target_sys|lifecycle|metadata_sys|replication|versioning|versioning_sys)\b[^}]*\}\s*;' \