Replace custom logging with tracing crate and RUST_LOG env var
- Remove custom logging module and init_logging function - Update main.rs to use tracing_subscriber with EnvFilter - Remove log_level from global config structure - Update documentation and tests to use RUST_LOG - Format long lines in config.rs and test files for better readability
This commit is contained in:
parent
50a4d9bc75
commit
55fe47b172
15 changed files with 787 additions and 459 deletions
|
|
@ -13,7 +13,8 @@ fn test_rate_limiting_with_concurrent_requests() {
|
|||
let cert_path = temp_dir.path().join("cert.pem");
|
||||
let key_path = temp_dir.path().join("key.pem");
|
||||
|
||||
let config_content = format!(r#"
|
||||
let config_content = format!(
|
||||
r#"
|
||||
bind_host = "127.0.0.1"
|
||||
port = {}
|
||||
max_concurrent_requests = 1
|
||||
|
|
@ -22,7 +23,12 @@ max_concurrent_requests = 1
|
|||
root = "{}"
|
||||
cert = "{}"
|
||||
key = "{}"
|
||||
"#, port, root_dir.display(), cert_path.display(), key_path.display());
|
||||
"#,
|
||||
port,
|
||||
root_dir.display(),
|
||||
cert_path.display(),
|
||||
key_path.display()
|
||||
);
|
||||
std::fs::write(&config_path, config_content).unwrap();
|
||||
|
||||
// Start server binary with test delay to simulate processing time
|
||||
|
|
@ -30,7 +36,7 @@ key = "{}"
|
|||
.arg("--config")
|
||||
.arg(&config_path)
|
||||
.arg("--test-processing-delay")
|
||||
.arg("3") // 3 second delay per request
|
||||
.arg("3") // 3 second delay per request
|
||||
.spawn()
|
||||
.expect("Failed to start server");
|
||||
|
||||
|
|
@ -68,13 +74,30 @@ key = "{}"
|
|||
let rate_limited_count = results.iter().filter(|r| r.starts_with("41")).count();
|
||||
|
||||
// Debug output
|
||||
println!("Results: {:?}", results);
|
||||
println!("Success: {}, Rate limited: {}", success_count, rate_limited_count);
|
||||
tracing::debug!("Test results: {:?}", results);
|
||||
tracing::debug!(
|
||||
"Success: {}, Rate limited: {}",
|
||||
success_count,
|
||||
rate_limited_count
|
||||
);
|
||||
|
||||
// Strict validation - rate limiting must work deterministically with delay
|
||||
assert_eq!(success_count, 1, "Expected exactly 1 successful request with limit=1, got {}. Results: {:?}", success_count, results);
|
||||
assert_eq!(rate_limited_count, 4, "Expected exactly 4 rate limited requests with limit=1, got {}. Results: {:?}", rate_limited_count, results);
|
||||
assert_eq!(
|
||||
success_count, 1,
|
||||
"Expected exactly 1 successful request with limit=1, got {}. Results: {:?}",
|
||||
success_count, results
|
||||
);
|
||||
assert_eq!(
|
||||
rate_limited_count, 4,
|
||||
"Expected exactly 4 rate limited requests with limit=1, got {}. Results: {:?}",
|
||||
rate_limited_count, results
|
||||
);
|
||||
|
||||
// Verify all requests received valid responses
|
||||
assert_eq!(success_count + rate_limited_count, 5, "All 5 requests should receive responses. Results: {:?}", results);
|
||||
}
|
||||
assert_eq!(
|
||||
success_count + rate_limited_count,
|
||||
5,
|
||||
"All 5 requests should receive responses. Results: {:?}",
|
||||
results
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue