mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-08 22:33:22 +00:00
fix: preserve walk-dir internode metrics fallback (#5095)
Co-authored-by: heihutu <heihutu@gmail.com>
This commit is contained in:
@@ -840,6 +840,7 @@ mod tests {
|
||||
use http_body_util::BodyExt;
|
||||
use rustfs_io_metrics::internode_metrics::{
|
||||
INTERNODE_OPERATION_PUT_FILE_STREAM, INTERNODE_OPERATION_READ_FILE_STREAM, INTERNODE_OPERATION_WALK_DIR,
|
||||
global_internode_metrics,
|
||||
};
|
||||
use sha2::Digest as _;
|
||||
use tokio::io;
|
||||
@@ -988,6 +989,30 @@ mod tests {
|
||||
assert_eq!(bytes, Bytes::from_static(b"complete walk data"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn walk_dir_body_records_operation_sent_bytes() {
|
||||
let metrics = global_internode_metrics();
|
||||
let before = metrics.snapshot().sent_bytes_total;
|
||||
let payload = Bytes::from_static(b"metered walk data");
|
||||
let expected_len = u64::try_from(payload.len()).expect("test payload length should fit u64");
|
||||
let body = walk_dir_response_body(true, move |mut writer| async move {
|
||||
writer.write_all(&payload).await?;
|
||||
Ok(())
|
||||
});
|
||||
|
||||
let bytes = BodyExt::collect(body)
|
||||
.await
|
||||
.expect("successful completion should preserve the metered body")
|
||||
.to_bytes();
|
||||
let after = metrics.snapshot().sent_bytes_total;
|
||||
|
||||
assert_eq!(bytes, Bytes::from_static(b"metered walk data"));
|
||||
assert!(
|
||||
after >= before.saturating_add(expected_len),
|
||||
"walk_dir response body should record streamed bytes as internode sent bytes: before={before}, after={after}, expected_delta={expected_len}"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn walk_dir_completion_stream_surfaces_cancelled_producer() {
|
||||
let (completion_tx, completion_rx) = tokio::sync::oneshot::channel();
|
||||
|
||||
@@ -17,7 +17,10 @@ use crate::runtime_sources as root_runtime_sources;
|
||||
use crate::storage::storage_api::runtime_sources_consumer::ECStore;
|
||||
use rustfs_credentials::Credentials;
|
||||
use rustfs_iam::{error::Result as IamResult, store::object::ObjectStore, sys::IamSys};
|
||||
use rustfs_io_metrics::{PerformanceMetrics, internode_metrics::InternodeMetrics};
|
||||
use rustfs_io_metrics::{
|
||||
PerformanceMetrics,
|
||||
internode_metrics::{InternodeMetrics, global_internode_metrics},
|
||||
};
|
||||
use rustfs_kms::ObjectEncryptionService;
|
||||
use rustfs_lock::LockClient;
|
||||
use std::sync::Arc;
|
||||
@@ -41,7 +44,7 @@ pub(crate) fn current_buffer_config() -> RustFSBufferConfig {
|
||||
}
|
||||
|
||||
pub(crate) fn current_internode_metrics() -> Arc<InternodeMetrics> {
|
||||
root_runtime_sources::current_internode_metrics().unwrap_or_else(|| Arc::new(InternodeMetrics::default()))
|
||||
root_runtime_sources::current_internode_metrics().unwrap_or_else(|| global_internode_metrics().clone())
|
||||
}
|
||||
|
||||
pub(crate) async fn current_local_node_name() -> String {
|
||||
|
||||
Reference in New Issue
Block a user