test: capture server stderr to diagnose CI failures

Problem:
- Integration tests are failing in CI with "Server failed to start"
- Server stdout/stderr were suppressed, hiding the actual error
- Can't diagnose why server won't start in CI environment

Changes:
- Change stderr from null() to piped()
- Capture and print stderr output when server fails to start
- Fix redundant pattern matching (is_ok() instead of if let Ok(_))

This will help us see the actual error message from the server
in CI logs and diagnose the root cause of the startup failure.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Till Wegmueller 2025-11-29 14:08:33 +01:00
parent 9244d60368
commit f2d08af4d0
No known key found for this signature in database

View file

@ -15,11 +15,12 @@ impl TestServer {
let port = 8080;
let base_url = format!("http://0.0.0.0:{}", port);
let process = Command::new("cargo")
// Use piped stderr so we can capture errors if server fails to start
let mut process = Command::new("cargo")
.args(["run", "--release", "--"])
.env("RUST_LOG", "error")
.stdout(std::process::Stdio::null())
.stderr(std::process::Stdio::null())
.stderr(std::process::Stdio::piped())
.spawn()
.expect("Failed to start server");
@ -30,9 +31,10 @@ impl TestServer {
let client = reqwest::blocking::Client::new();
let max_retries = 30;
for i in 0..max_retries {
if let Ok(_) = client
if client
.get(format!("{}/.well-known/openid-configuration", base_url))
.send()
.is_ok()
{
println!("Server started successfully");
return Self { process, base_url };
@ -42,6 +44,16 @@ impl TestServer {
}
}
// Server failed to start - try to get stderr output
use std::io::Read;
if let Some(mut stderr) = process.stderr.take() {
let mut error_output = String::new();
let _ = stderr.read_to_string(&mut error_output);
if !error_output.is_empty() {
eprintln!("Server stderr output:\n{}", error_output);
}
}
panic!("Server failed to start within timeout");
}