fix: implement random-port discovery for CI E2E backend
When PORT=0, the backend now writes its actual bound port to data/test/.port. test-env.sh reads that file when TT_TEST_PORT=0 so all targets (test-up, test-reset, test-down) resolve the real URL. test-up waits for .port to appear before the health-check loop.
This commit is contained in:
+8
-1
@@ -85,7 +85,14 @@ async fn main() {
|
||||
let listener = tokio::net::TcpListener::bind(&addr)
|
||||
.await
|
||||
.expect("failed to bind");
|
||||
tracing::info!("listening on {}", addr);
|
||||
let actual_addr = listener.local_addr().expect("failed to get local addr");
|
||||
tracing::info!("listening on {}", actual_addr);
|
||||
|
||||
// When started with PORT=0 (random), write actual port so the test harness can discover it
|
||||
if port == "0" {
|
||||
let _ = std::fs::create_dir_all("data/test");
|
||||
let _ = std::fs::write("data/test/.port", actual_addr.port().to_string());
|
||||
}
|
||||
|
||||
axum::serve(
|
||||
listener,
|
||||
|
||||
Reference in New Issue
Block a user