mirror of
https://github.com/CloudNebulaProject/barycenter.git
synced 2026-04-10 21:20:41 +00:00
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:
parent
9244d60368
commit
f2d08af4d0
1 changed files with 15 additions and 3 deletions
|
|
@ -15,11 +15,12 @@ impl TestServer {
|
||||||
let port = 8080;
|
let port = 8080;
|
||||||
let base_url = format!("http://0.0.0.0:{}", port);
|
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", "--"])
|
.args(["run", "--release", "--"])
|
||||||
.env("RUST_LOG", "error")
|
.env("RUST_LOG", "error")
|
||||||
.stdout(std::process::Stdio::null())
|
.stdout(std::process::Stdio::null())
|
||||||
.stderr(std::process::Stdio::null())
|
.stderr(std::process::Stdio::piped())
|
||||||
.spawn()
|
.spawn()
|
||||||
.expect("Failed to start server");
|
.expect("Failed to start server");
|
||||||
|
|
||||||
|
|
@ -30,9 +31,10 @@ impl TestServer {
|
||||||
let client = reqwest::blocking::Client::new();
|
let client = reqwest::blocking::Client::new();
|
||||||
let max_retries = 30;
|
let max_retries = 30;
|
||||||
for i in 0..max_retries {
|
for i in 0..max_retries {
|
||||||
if let Ok(_) = client
|
if client
|
||||||
.get(format!("{}/.well-known/openid-configuration", base_url))
|
.get(format!("{}/.well-known/openid-configuration", base_url))
|
||||||
.send()
|
.send()
|
||||||
|
.is_ok()
|
||||||
{
|
{
|
||||||
println!("Server started successfully");
|
println!("Server started successfully");
|
||||||
return Self { process, base_url };
|
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");
|
panic!("Server failed to start within timeout");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue