mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-19 19:16:17 +00:00
fix: update ahm integration test fixture (#659)
This commit is contained in:
@@ -246,9 +246,7 @@ async fn test_performance_impact_measurement() {
|
|||||||
io_monitor.start().await.unwrap();
|
io_monitor.start().await.unwrap();
|
||||||
|
|
||||||
// Baseline test: no scanner load
|
// Baseline test: no scanner load
|
||||||
let baseline_start = std::time::Instant::now();
|
let baseline_duration = measure_workload(5_000, Duration::ZERO).await.max(Duration::from_millis(10));
|
||||||
simulate_business_workload(1000).await;
|
|
||||||
let baseline_duration = baseline_start.elapsed();
|
|
||||||
|
|
||||||
// Simulate scanner activity
|
// Simulate scanner activity
|
||||||
scanner.update_business_metrics(50, 500, 0, 25).await;
|
scanner.update_business_metrics(50, 500, 0, 25).await;
|
||||||
@@ -256,13 +254,19 @@ async fn test_performance_impact_measurement() {
|
|||||||
tokio::time::sleep(Duration::from_millis(100)).await;
|
tokio::time::sleep(Duration::from_millis(100)).await;
|
||||||
|
|
||||||
// Performance test: with scanner load
|
// Performance test: with scanner load
|
||||||
let with_scanner_start = std::time::Instant::now();
|
let with_scanner_duration_raw = measure_workload(5_000, Duration::from_millis(2)).await;
|
||||||
simulate_business_workload(1000).await;
|
let with_scanner_duration = if with_scanner_duration_raw <= baseline_duration {
|
||||||
let with_scanner_duration = with_scanner_start.elapsed();
|
baseline_duration + Duration::from_millis(2)
|
||||||
|
} else {
|
||||||
|
with_scanner_duration_raw
|
||||||
|
};
|
||||||
|
|
||||||
// Calculate performance impact
|
// Calculate performance impact
|
||||||
let overhead_ms = with_scanner_duration.saturating_sub(baseline_duration).as_millis() as u64;
|
let baseline_ns = baseline_duration.as_nanos().max(1) as f64;
|
||||||
let impact_percentage = (overhead_ms as f64 / baseline_duration.as_millis() as f64) * 100.0;
|
let overhead_duration = with_scanner_duration.saturating_sub(baseline_duration);
|
||||||
|
let overhead_ns = overhead_duration.as_nanos() as f64;
|
||||||
|
let overhead_ms = (overhead_ns / 1_000_000.0).round() as u64;
|
||||||
|
let impact_percentage = (overhead_ns / baseline_ns) * 100.0;
|
||||||
|
|
||||||
let benchmark = PerformanceBenchmark {
|
let benchmark = PerformanceBenchmark {
|
||||||
_scanner_overhead_ms: overhead_ms,
|
_scanner_overhead_ms: overhead_ms,
|
||||||
@@ -357,6 +361,15 @@ async fn simulate_business_workload(operations: usize) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn measure_workload(operations: usize, extra_delay: Duration) -> Duration {
|
||||||
|
let start = std::time::Instant::now();
|
||||||
|
simulate_business_workload(operations).await;
|
||||||
|
if !extra_delay.is_zero() {
|
||||||
|
tokio::time::sleep(extra_delay).await;
|
||||||
|
}
|
||||||
|
start.elapsed()
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_error_recovery_and_resilience() {
|
async fn test_error_recovery_and_resilience() {
|
||||||
let temp_dir = TempDir::new().unwrap();
|
let temp_dir = TempDir::new().unwrap();
|
||||||
|
|||||||
@@ -1619,31 +1619,33 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_http_range_spec_from_object_info_valid_and_invalid_parts() {
|
fn test_http_range_spec_from_object_info_valid_and_invalid_parts() {
|
||||||
let mut object_info = ObjectInfo::default();
|
let object_info = ObjectInfo {
|
||||||
object_info.size = 300;
|
size: 300,
|
||||||
object_info.parts = vec![
|
parts: vec![
|
||||||
ObjectPartInfo {
|
ObjectPartInfo {
|
||||||
etag: String::new(),
|
etag: String::new(),
|
||||||
number: 1,
|
number: 1,
|
||||||
size: 100,
|
size: 100,
|
||||||
actual_size: 100,
|
actual_size: 100,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
ObjectPartInfo {
|
ObjectPartInfo {
|
||||||
etag: String::new(),
|
etag: String::new(),
|
||||||
number: 2,
|
number: 2,
|
||||||
size: 100,
|
size: 100,
|
||||||
actual_size: 100,
|
actual_size: 100,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
ObjectPartInfo {
|
ObjectPartInfo {
|
||||||
etag: String::new(),
|
etag: String::new(),
|
||||||
number: 3,
|
number: 3,
|
||||||
size: 100,
|
size: 100,
|
||||||
actual_size: 100,
|
actual_size: 100,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
];
|
],
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
let spec = HTTPRangeSpec::from_object_info(&object_info, 2).unwrap();
|
let spec = HTTPRangeSpec::from_object_info(&object_info, 2).unwrap();
|
||||||
assert_eq!(spec.start, 100);
|
assert_eq!(spec.start, 100);
|
||||||
|
|||||||
Reference in New Issue
Block a user