diff --git a/README.md b/README.md index 9364798..4ec1c12 100644 --- a/README.md +++ b/README.md @@ -32,5 +32,5 @@ See [config_example.yaml](config_example.yaml). - [ ] SQLite/MySQL Adapters (Future) - [ ] Documentation & Testing - [x] Basic End-to-end tests - - [ ] Comprehensive Unit Tests + - [x] Comprehensive Unit Tests - [ ] Deployment Guide diff --git a/README_cn.md b/README_cn.md index f173104..e3e50bb 100644 --- a/README_cn.md +++ b/README_cn.md @@ -32,5 +32,5 @@ traudit 是一个支持 TCP/UDP/Unix Socket 的反向代理程序,专注于连 - [ ] SQLite/MySQL 适配器 (计划中) - [ ] 文档与测试 - [x] 基础端到端测试 - - [ ] 单元测试 + - [x] 单元测试 - [ ] 部署文档 diff --git a/tests/reload_test.rs b/tests/reload_test.rs index 235faf2..0c6bb0f 100644 --- a/tests/reload_test.rs +++ b/tests/reload_test.rs @@ -102,6 +102,14 @@ services: let config_path = std::env::temp_dir().join("stress_test.yaml"); std::fs::write(&config_path, config_content)?; + // Pre-build to ensure cargo run doesn't time out compiling + let _ = Command::new("cargo") + .arg("build") + .arg("--bin") + .arg("traudit") + .status() + .await?; + // Start Traudit using cargo run to ensure correct binary execution let mut _child = Command::new("cargo") .arg("run") @@ -114,8 +122,21 @@ services: .stderr(std::process::Stdio::null()) .spawn()?; - // Give it time to start - tokio::time::sleep(Duration::from_secs(5)).await; + // Wait for port to be open (up to 30s) + let addr = format!("127.0.0.1:{}", t_tcp_port); + let mut started = false; + for _ in 0..60 { + // 30s total (500ms * 60) + if TcpStream::connect(&addr).await.is_ok() { + started = true; + break; + } + tokio::time::sleep(Duration::from_millis(500)).await; + } + + if !started { + panic!("Traudit failed to start on port {} within 30s", t_tcp_port); + } // Run Test Loop for 10 seconds generating mixed traffic