From c228fabfdb69b00112563401779e9af8c3d3df87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=AD=A3=E8=B6=85?= Date: Wed, 6 May 2026 08:47:11 +0800 Subject: [PATCH] test(admin): cover orphan resync status cleanup (#2816) --- rustfs/src/admin/handlers/site_replication.rs | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/rustfs/src/admin/handlers/site_replication.rs b/rustfs/src/admin/handlers/site_replication.rs index e68016167..eb9f63c2d 100644 --- a/rustfs/src/admin/handlers/site_replication.rs +++ b/rustfs/src/admin/handlers/site_replication.rs @@ -3382,6 +3382,57 @@ mod tests { assert!(state.resync_status.contains_key("remote-b-deployment")); } + #[test] + fn test_remove_sites_prunes_orphan_resync_status_without_matching_site() { + let mut state = SiteReplicationState { + name: "local".to_string(), + ..Default::default() + }; + state.peers.insert( + "remote-a-deployment".to_string(), + PeerInfo { + deployment_id: "remote-a-deployment".to_string(), + ..peer("remote-a", "https://remote-a.example.com") + }, + ); + state.peers.insert( + "remote-b-deployment".to_string(), + PeerInfo { + deployment_id: "remote-b-deployment".to_string(), + ..peer("remote-b", "https://remote-b.example.com") + }, + ); + state.resync_status.insert( + "remote-a-deployment".to_string(), + SRResyncOpStatus { + resync_id: "active-a".to_string(), + status: "success".to_string(), + ..Default::default() + }, + ); + state.resync_status.insert( + "removed-deployment".to_string(), + SRResyncOpStatus { + resync_id: "orphaned".to_string(), + status: "success".to_string(), + ..Default::default() + }, + ); + + let state = remove_sites( + state, + SRRemoveReq { + site_names: vec!["missing-site".to_string()], + ..Default::default() + }, + ); + + assert!(state.peers.contains_key("remote-a-deployment")); + assert!(state.peers.contains_key("remote-b-deployment")); + assert!(state.resync_status.contains_key("remote-a-deployment")); + assert!(!state.resync_status.contains_key("removed-deployment")); + } + #[test] fn test_remove_sites_clears_state_when_local_site_is_removed() { let mut state = SiteReplicationState {