refactor(site-replication): move business tests next to the service module (#6716)

* refactor(site-replication): move business tests next to the service module

backlog#1840 PR5: 79 business-logic tests (plus 12 helpers, 6 of them small fixtures kept on both sides) move from the admin handler file's test module into rustfs/src/site_replication/tests.rs, next to the code they exercise: peer connection/TLS/DNS/egress validation, the peer client cache and payload wire contract, retry-queue classification/settlement/escalation/backoff, the repair state machine, bootstrap-plan construction, lifecycle expiry subsetting, bucket-target reconciliation, endpoint/identity normalization, and state serialization. The 149 tests that exercise the admin handlers, apply/reconcile paths, status/resync builders, and the four include_str! tripwires stay in rustfs/src/admin/handlers/site_replication.rs with their subjects (229 total conserved: 149 + 79 + 1).

The issue's PR5 also called for converting the source-order tripwire at the old file's line 11339 into a behavior test; both adversarial review passes re-derived all four tripwires against the shrunken file and found them non-vacuous and byte-identical in the regions they guard (the handler bodies, which did not move), so they stay as source-text assertions.

Supporting changes: the root facade's site_replication consumer gains cfg(test) re-exports (endpoint types, merge_incoming_replication_config, five lifecycle DTO types) so the relocated tests stay off the direct s3s/admin surfaces — including rewriting the one inline crate::admin BucketMetadata path a moved test carried over (review finding); tests.rs joins the logging-guardrail checked list; the embedded-secrets guard comment follows the validate_peer_connection_inner fixtures to their new file.

Verified: cargo check -p rustfs --all-targets clean; cargo nextest run -p rustfs --lib 3856/3856 passed; relocated tests run under site_replication::tests::; make pre-commit green including the s3s footprint ratchet; logging and embedded-secrets guards green.

Refs rustfs/backlog#1840

* style(site-replication): apply rustfmt import ordering
This commit is contained in:
Zhengchao An
2026-08-27 15:17:16 +08:00
committed by GitHub
parent c006f84461
commit 7b17d46ca9
6 changed files with 2345 additions and 2261 deletions
File diff suppressed because it is too large Load Diff
+3
View File
@@ -34,6 +34,9 @@ pub(crate) mod retry;
pub(crate) mod state;
pub(crate) mod transport;
#[cfg(test)]
mod tests;
pub(crate) use self::hooks::*;
pub(crate) use self::repair::*;
pub(crate) use self::retry::*;
File diff suppressed because it is too large Load Diff
+6
View File
@@ -227,6 +227,8 @@ pub(crate) mod site_replication {
BUCKET_REPLICATION_CONFIG, BUCKET_TARGETS_FILE, BUCKET_VERSIONING_CONFIG, BucketMetadata,
};
#[cfg(test)]
pub(crate) use crate::storage::storage_api::ecstore_bucket::replication::merge_incoming_replication_config;
pub(crate) use crate::storage::storage_api::ecstore_bucket::replication::{
OperatorRuleContract, assign_site_replication_rule_priorities, is_site_replication_role,
replication_target_arn_deployment_id, site_replication_rule_deployment_id,
@@ -238,6 +240,8 @@ pub(crate) mod site_replication {
pub(crate) use crate::storage::storage_api::ecstore_bucket::versioning::VersioningApi;
#[cfg(test)]
pub(crate) use crate::storage::storage_api::ecstore_config::com::save_config;
#[cfg(test)]
pub(crate) use crate::storage::storage_api::{Endpoint, Endpoints, PoolEndpoints};
pub(crate) use crate::storage::storage_api::{
ECStore, EndpointServerPools, StorageError, delete_config_no_lock, lock_bucket_targets_metadata, read_config,
@@ -260,6 +264,8 @@ pub(crate) mod site_replication {
LifecycleRule, ReplicaModifications, ReplicaModificationsStatus, ReplicationConfiguration, ReplicationRule,
ReplicationRuleStatus, SourceSelectionCriteria, VersioningConfiguration,
};
#[cfg(test)]
pub(crate) use s3s::dto::{ExpirationStatus, LifecycleExpiration, Timestamp, Transition, TransitionStorageClass};
pub(crate) use s3s::{Body, S3Error, S3ErrorCode, S3Response, S3Result, s3_error};
}
}
+1 -1
View File
@@ -88,7 +88,7 @@ PATTERNS=(
# the guard fire again. Entries that stop matching anything are reported as
# stale, so the list cannot decay into a blanket exclusion.
#
# 1-2: rustfs/src/admin/handlers/site_replication.rs negative fixtures for
# 1-2: rustfs/src/site_replication/tests.rs negative fixtures for
# `validate_peer_connection_inner`, which must reject a private key
# submitted where a peer CA certificate is expected. Asserting on the
# rejection requires the header in the input; the key bodies are the
+1
View File
@@ -37,6 +37,7 @@ checked_files=(
"rustfs/src/site_replication/retry.rs"
"rustfs/src/site_replication/repair.rs"
"rustfs/src/site_replication/hooks.rs"
"rustfs/src/site_replication/tests.rs"
"rustfs/src/admin/handlers/group.rs"
"rustfs/src/admin/handlers/quota.rs"
"rustfs/src/admin/handlers/rebalance.rs"