Merge pull request #435 from rustfs/fix/e2e-lock-test-errors

fix: resolve clippy warnings and doctest failures
This commit is contained in:
安正超
2025-05-28 15:34:29 +08:00
committed by GitHub
4 changed files with 45 additions and 27 deletions
+24 -12
View File
@@ -286,8 +286,10 @@ mod tests {
#[test]
fn test_last_minute_latency_forward_to_same_time() {
let mut latency = LastMinuteLatency::default();
latency.last_sec = 100;
let mut latency = LastMinuteLatency {
last_sec: 100,
..Default::default()
};
// Add some data to verify it's not cleared
latency.totals[0].total = 10;
@@ -302,8 +304,10 @@ mod tests {
#[test]
fn test_last_minute_latency_forward_to_past_time() {
let mut latency = LastMinuteLatency::default();
latency.last_sec = 100;
let mut latency = LastMinuteLatency {
last_sec: 100,
..Default::default()
};
// Add some data to verify it's not cleared
latency.totals[0].total = 10;
@@ -318,8 +322,10 @@ mod tests {
#[test]
fn test_last_minute_latency_forward_to_large_gap() {
let mut latency = LastMinuteLatency::default();
latency.last_sec = 100;
let mut latency = LastMinuteLatency {
last_sec: 100,
..Default::default()
};
// Add some data to verify it's cleared
latency.totals[0].total = 10;
@@ -339,8 +345,10 @@ mod tests {
#[test]
fn test_last_minute_latency_forward_to_small_gap() {
let mut latency = LastMinuteLatency::default();
latency.last_sec = 100;
let mut latency = LastMinuteLatency {
last_sec: 100,
..Default::default()
};
// Add data at specific indices
latency.totals[41].total = 10; // (100 + 1) % 60 = 41
@@ -560,8 +568,10 @@ mod tests {
#[test]
fn test_last_minute_latency_clone() {
let mut latency = LastMinuteLatency::default();
latency.last_sec = 1000;
let mut latency = LastMinuteLatency {
last_sec: 1000,
..Default::default()
};
latency.totals[0].total = 100;
latency.totals[0].n = 5;
@@ -596,8 +606,10 @@ mod tests {
#[test]
fn test_forward_to_boundary_conditions() {
let mut latency = LastMinuteLatency::default();
latency.last_sec = 59;
let mut latency = LastMinuteLatency {
last_sec: 59,
..Default::default()
};
// Add data at the last slot
latency.totals[59].total = 100;
+2 -2
View File
@@ -44,9 +44,9 @@ pub enum GlobalError {
/// ```rust
/// use rustfs_obs::{init_telemetry, load_config, set_global_guard};
///
/// async fn init() -> Result<(), Box<dyn std::error::Error>> {
/// fn init() -> Result<(), Box<dyn std::error::Error>> {
/// let config = load_config(None);
/// let guard = init_telemetry(&config.observability).await?;
/// let guard = init_telemetry(&config.observability);
/// set_global_guard(guard)?;
/// Ok(())
/// }
+11 -5
View File
@@ -22,11 +22,14 @@
///
/// ## Usage
///
/// ```rust
/// ```no_run
/// use rustfs_obs::{AppConfig, init_obs};
///
/// # #[tokio::main]
/// # async fn main() {
/// let config = AppConfig::default();
/// let (logger, guard) = init_obs(config);
/// let (logger, guard) = init_obs(config).await;
/// # }
/// ```
mod config;
mod entry;
@@ -64,11 +67,14 @@ use tracing::{error, info};
/// A tuple containing the logger and the telemetry guard
///
/// # Example
/// ```
/// ```no_run
/// use rustfs_obs::{AppConfig, init_obs};
///
/// # #[tokio::main]
/// # async fn main() {
/// let config = AppConfig::default();
/// let (logger, guard) = init_obs(config);
/// let (logger, guard) = init_obs(config).await;
/// # }
/// ```
pub async fn init_obs(config: AppConfig) -> (Arc<Mutex<Logger>>, telemetry::OtelGuard) {
let guard = init_telemetry(&config.observability);
@@ -97,7 +103,7 @@ pub async fn init_obs(config: AppConfig) -> (Arc<Mutex<Logger>>, telemetry::Otel
/// A reference to the global logger instance
///
/// # Example
/// ```
/// ```no_run
/// use rustfs_obs::get_logger;
///
/// let logger = get_logger();
+8 -8
View File
@@ -224,7 +224,7 @@ impl Logger {
/// # Returns
/// The global logger instance
/// # Example
/// ```
/// ```no_run
/// use rustfs_obs::{AppConfig, start_logger};
///
/// let config = AppConfig::default();
@@ -270,7 +270,7 @@ pub async fn init_global_logger(config: &AppConfig, sinks: Vec<Arc<dyn Sink>>) -
/// A reference to the global logger instance
///
/// # Example
/// ```
/// ```no_run
/// use rustfs_obs::get_global_logger;
///
/// let logger = get_global_logger();
@@ -290,7 +290,7 @@ pub fn get_global_logger() -> &'static Arc<Mutex<Logger>> {
/// Result indicating whether the operation was successful
///
/// # Example
/// ```
/// ```no_run
/// use rustfs_obs::log_info;
///
/// async fn example() {
@@ -309,7 +309,7 @@ pub async fn log_info(message: &str, source: &str) -> Result<(), GlobalError> {
/// # Returns
/// Result indicating whether the operation was successful
/// # Example
/// ```
/// ```no_run
/// use rustfs_obs::log_error;
///
/// async fn example() {
@@ -328,7 +328,7 @@ pub async fn log_error(message: &str, source: &str) -> Result<(), GlobalError> {
/// Result indicating whether the operation was successful
///
/// # Example
/// ```
/// ```no_run
/// use rustfs_obs::log_warn;
///
/// async fn example() {
@@ -348,7 +348,7 @@ pub async fn log_warn(message: &str, source: &str) -> Result<(), GlobalError> {
/// Result indicating whether the operation was successful
///
/// # Example
/// ```
/// ```no_run
/// use rustfs_obs::log_debug;
///
/// async fn example() {
@@ -369,7 +369,7 @@ pub async fn log_debug(message: &str, source: &str) -> Result<(), GlobalError> {
/// Result indicating whether the operation was successful
///
/// # Example
/// ```
/// ```no_run
/// use rustfs_obs::log_trace;
///
/// async fn example() {
@@ -392,7 +392,7 @@ pub async fn log_trace(message: &str, source: &str) -> Result<(), GlobalError> {
/// # Returns
/// Result indicating whether the operation was successful
/// # Example
/// ```
/// ```no_run
/// use tracing_core::Level;
/// use rustfs_obs::log_with_context;
///