mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-31 09:18:28 +00:00
fix: bypass OnceLock in test for metadata early-stop gates (#4135)
This commit is contained in:
@@ -539,25 +539,48 @@ fn get_codec_streaming_multipart_max_parts() -> usize {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Check if metadata early-stop is enabled (base flag).
|
/// Check if metadata early-stop is enabled (base flag).
|
||||||
|
///
|
||||||
|
/// **Note**: Cached via `OnceLock` in production. In test builds the env var
|
||||||
|
/// is read directly so that `temp_env` overrides take effect.
|
||||||
fn is_get_metadata_early_stop_enabled() -> bool {
|
fn is_get_metadata_early_stop_enabled() -> bool {
|
||||||
static CACHED: OnceLock<bool> = OnceLock::new();
|
#[cfg(test)]
|
||||||
*CACHED.get_or_init(|| {
|
{
|
||||||
rustfs_utils::get_env_bool(ENV_RUSTFS_GET_METADATA_EARLY_STOP_ENABLE, DEFAULT_RUSTFS_GET_METADATA_EARLY_STOP_ENABLE)
|
rustfs_utils::get_env_bool(ENV_RUSTFS_GET_METADATA_EARLY_STOP_ENABLE, DEFAULT_RUSTFS_GET_METADATA_EARLY_STOP_ENABLE)
|
||||||
})
|
}
|
||||||
|
#[cfg(not(test))]
|
||||||
|
{
|
||||||
|
static CACHED: OnceLock<bool> = OnceLock::new();
|
||||||
|
*CACHED.get_or_init(|| {
|
||||||
|
rustfs_utils::get_env_bool(ENV_RUSTFS_GET_METADATA_EARLY_STOP_ENABLE, DEFAULT_RUSTFS_GET_METADATA_EARLY_STOP_ENABLE)
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if version-aware early-stop is enabled.
|
/// Check if version-aware early-stop is enabled.
|
||||||
///
|
///
|
||||||
/// When enabled, versioned requests can early-stop when the requested
|
/// When enabled, versioned requests can early-stop when the requested
|
||||||
/// version_id reaches quorum across disks.
|
/// version_id reaches quorum across disks.
|
||||||
|
///
|
||||||
|
/// **Note**: Cached via `OnceLock` in production. In test builds the env var
|
||||||
|
/// is read directly so that `temp_env` overrides take effect.
|
||||||
fn is_version_early_stop_enabled() -> bool {
|
fn is_version_early_stop_enabled() -> bool {
|
||||||
static CACHED: OnceLock<bool> = OnceLock::new();
|
#[cfg(test)]
|
||||||
*CACHED.get_or_init(|| {
|
{
|
||||||
rustfs_utils::get_env_bool(
|
rustfs_utils::get_env_bool(
|
||||||
ENV_RUSTFS_GET_METADATA_VERSION_EARLY_STOP_ENABLE,
|
ENV_RUSTFS_GET_METADATA_VERSION_EARLY_STOP_ENABLE,
|
||||||
DEFAULT_RUSTFS_GET_METADATA_VERSION_EARLY_STOP_ENABLE,
|
DEFAULT_RUSTFS_GET_METADATA_VERSION_EARLY_STOP_ENABLE,
|
||||||
)
|
)
|
||||||
})
|
}
|
||||||
|
#[cfg(not(test))]
|
||||||
|
{
|
||||||
|
static CACHED: OnceLock<bool> = OnceLock::new();
|
||||||
|
*CACHED.get_or_init(|| {
|
||||||
|
rustfs_utils::get_env_bool(
|
||||||
|
ENV_RUSTFS_GET_METADATA_VERSION_EARLY_STOP_ENABLE,
|
||||||
|
DEFAULT_RUSTFS_GET_METADATA_VERSION_EARLY_STOP_ENABLE,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Rollout Percentage Functions ---
|
// --- Rollout Percentage Functions ---
|
||||||
|
|||||||
Reference in New Issue
Block a user