mirror of
https://github.com/rustfs/rustfs.git
synced 2026-09-07 12:35:54 +00:00
test(ecstore): stabilize activation race capacity (#6989)
This commit is contained in:
@@ -7369,51 +7369,15 @@ impl DecommissionPoolCapacityInfo {
|
|||||||
physical_used,
|
physical_used,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
fn from_logical(pool_index: usize, space: PoolSpaceInfo) -> Self {
|
|
||||||
Self {
|
|
||||||
pool_index,
|
|
||||||
space,
|
|
||||||
layout: DecommissionErasureLayout { data: 1, parity: 0 },
|
|
||||||
physical_free: space.free,
|
|
||||||
physical_total: space.total,
|
|
||||||
physical_used: space.used,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
type DecommissionSpaceInfoOverrides = std::sync::Mutex<HashMap<uuid::Uuid, Vec<(usize, PoolSpaceInfo)>>>;
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
type DecommissionCapacityInfoOverrides =
|
type DecommissionCapacityInfoOverrides =
|
||||||
std::sync::Mutex<HashMap<uuid::Uuid, std::collections::VecDeque<Vec<DecommissionPoolCapacityInfo>>>>;
|
std::sync::Mutex<HashMap<uuid::Uuid, std::collections::VecDeque<Vec<DecommissionPoolCapacityInfo>>>>;
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
static DECOMMISSION_SPACE_INFO_OVERRIDES: std::sync::OnceLock<DecommissionSpaceInfoOverrides> = std::sync::OnceLock::new();
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
static DECOMMISSION_CAPACITY_INFO_OVERRIDES: std::sync::OnceLock<DecommissionCapacityInfoOverrides> = std::sync::OnceLock::new();
|
static DECOMMISSION_CAPACITY_INFO_OVERRIDES: std::sync::OnceLock<DecommissionCapacityInfoOverrides> = std::sync::OnceLock::new();
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
pub(crate) fn set_decommission_space_info_override_for_test(store_id: uuid::Uuid, space_infos: Vec<(usize, PoolSpaceInfo)>) {
|
|
||||||
DECOMMISSION_SPACE_INFO_OVERRIDES
|
|
||||||
.get_or_init(|| std::sync::Mutex::new(HashMap::new()))
|
|
||||||
.lock()
|
|
||||||
.expect("decommission space info override should not be poisoned")
|
|
||||||
.insert(store_id, space_infos);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
fn take_decommission_space_info_override_for_test(store_id: uuid::Uuid) -> Option<Vec<(usize, PoolSpaceInfo)>> {
|
|
||||||
DECOMMISSION_SPACE_INFO_OVERRIDES
|
|
||||||
.get_or_init(|| std::sync::Mutex::new(HashMap::new()))
|
|
||||||
.lock()
|
|
||||||
.expect("decommission space info override should not be poisoned")
|
|
||||||
.remove(&store_id)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub(crate) fn set_decommission_capacity_info_overrides_for_test(
|
pub(crate) fn set_decommission_capacity_info_overrides_for_test(
|
||||||
store_id: uuid::Uuid,
|
store_id: uuid::Uuid,
|
||||||
@@ -9156,14 +9120,6 @@ impl ECStore {
|
|||||||
return Ok(capacity_infos);
|
return Ok(capacity_infos);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
if let Some(space_infos) = take_decommission_space_info_override_for_test(self.id) {
|
|
||||||
return Ok(space_infos
|
|
||||||
.into_iter()
|
|
||||||
.map(|(pool_index, space)| DecommissionPoolCapacityInfo::from_logical(pool_index, space))
|
|
||||||
.collect());
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut capacity_infos = Vec::with_capacity(self.pools.len());
|
let mut capacity_infos = Vec::with_capacity(self.pools.len());
|
||||||
for idx in 0..self.pools.len() {
|
for idx in 0..self.pools.len() {
|
||||||
capacity_infos.push(self.get_decommission_pool_capacity_info(idx).await?);
|
capacity_infos.push(self.get_decommission_pool_capacity_info(idx).await?);
|
||||||
|
|||||||
@@ -1329,8 +1329,9 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use crate::config::com::delete_config;
|
use crate::config::com::delete_config;
|
||||||
use crate::core::pools::{
|
use crate::core::pools::{
|
||||||
POOL_META_NAME, PoolActivationDurableSaveBarrier, PoolActivationStartKind, PoolActivationStartProbe, PoolMetaWriteState,
|
DecommissionErasureLayout, DecommissionPoolCapacityInfo, POOL_META_NAME, PoolActivationDurableSaveBarrier,
|
||||||
persist_pool_meta_identity_for_startup,
|
PoolActivationStartKind, PoolActivationStartProbe, PoolMetaWriteState, persist_pool_meta_identity_for_startup,
|
||||||
|
set_decommission_capacity_info_overrides_for_test,
|
||||||
};
|
};
|
||||||
use crate::object_api::NamespaceLockFence;
|
use crate::object_api::NamespaceLockFence;
|
||||||
use crate::set_disk::{PutObjectCommitBarrier, PutObjectCommitPause, hermetic_set_disks_isolated};
|
use crate::set_disk::{PutObjectCommitBarrier, PutObjectCommitPause, hermetic_set_disks_isolated};
|
||||||
@@ -1751,26 +1752,15 @@ mod tests {
|
|||||||
];
|
];
|
||||||
set_rebalance_disk_stats_override_for_test(rebalance_store.id, disk_stats.clone());
|
set_rebalance_disk_stats_override_for_test(rebalance_store.id, disk_stats.clone());
|
||||||
set_rebalance_disk_stats_override_for_test(decommission_store.id, disk_stats);
|
set_rebalance_disk_stats_override_for_test(decommission_store.id, disk_stats);
|
||||||
crate::core::pools::set_decommission_space_info_override_for_test(
|
let layout = DecommissionErasureLayout { data: 1, parity: 0 };
|
||||||
|
let capacity_snapshot = vec![
|
||||||
|
DecommissionPoolCapacityInfo::for_test(0, layout, 0, 100, 100),
|
||||||
|
DecommissionPoolCapacityInfo::for_test(1, layout, 200, 200, 0),
|
||||||
|
];
|
||||||
|
// Decommission start samples capacity before and inside its durable activation fence.
|
||||||
|
set_decommission_capacity_info_overrides_for_test(
|
||||||
decommission_store.id,
|
decommission_store.id,
|
||||||
vec![
|
vec![capacity_snapshot.clone(), capacity_snapshot],
|
||||||
(
|
|
||||||
0,
|
|
||||||
crate::core::pools::PoolSpaceInfo {
|
|
||||||
free: 0,
|
|
||||||
total: 100,
|
|
||||||
used: 100,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
1,
|
|
||||||
crate::core::pools::PoolSpaceInfo {
|
|
||||||
free: 200,
|
|
||||||
total: 200,
|
|
||||||
used: 0,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
let (first_object, competing_object, competing_kind) = match paused_kind {
|
let (first_object, competing_object, competing_kind) = match paused_kind {
|
||||||
PoolActivationStartKind::Rebalance => {
|
PoolActivationStartKind::Rebalance => {
|
||||||
|
|||||||
Reference in New Issue
Block a user