About 10,000 test leftovers had built up in titan's /tmp. loopd's Home and FakeServer, its fake broker's socket, bxctl's temp sockets, fake loopd and command homes, inferproxy's socket, and a few brokerd and toolkit tests created uniquely named directories or sockets and never removed them, or removed them by hand at the end, which a failing test skips. Each is now a guard removed on drop (bxctl gains tests/support/temp.rs). Two races also left gatewayd homes behind: the test Running only signalled its server to stop, and two Stage structs declared the home first, so it was removed while the server could still write into it. Running's drop now waits for the thread (with a 5-second limit), and every home is declared last. Checked: make gate twice, then the gate and three rounds of gatewayd and loopd tests; no new entry in /tmp; 944 tests pass. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
43 lines
1.3 KiB
Rust
43 lines
1.3 KiB
Rust
//! A `brokerd` that accepts and never answers does not hang `bxctl` (M3a review finding 9).
|
|
|
|
#[path = "support/temp.rs"]
|
|
mod temp;
|
|
use std::os::unix::net::UnixListener;
|
|
use std::time::{Duration, Instant};
|
|
|
|
use bxctl::admin::{ADMIN_TIMEOUT, request_with_timeout};
|
|
use proto::{Empty, Message};
|
|
|
|
#[test]
|
|
fn the_default_is_thirty_seconds() {
|
|
assert_eq!(ADMIN_TIMEOUT, Duration::from_secs(30));
|
|
}
|
|
|
|
#[test]
|
|
fn a_silent_brokerd_is_an_error_after_the_timeout() {
|
|
let dir = temp::TempDir::new("bx-admin-timeout");
|
|
let socket = dir.join("admin.sock");
|
|
let listener = UnixListener::bind(&socket).unwrap();
|
|
let held = std::thread::spawn(move || {
|
|
let (stream, _) = listener.accept().unwrap();
|
|
std::thread::sleep(Duration::from_millis(2_000));
|
|
drop(stream);
|
|
});
|
|
|
|
let started = Instant::now();
|
|
let got = request_with_timeout(
|
|
&socket,
|
|
Message::Approvals(Empty {}),
|
|
Duration::from_millis(200),
|
|
);
|
|
let took = started.elapsed();
|
|
let text = got.expect_err("a silent brokerd is an error").to_string();
|
|
assert!(
|
|
text.contains("whether it acted is unknown"),
|
|
"brokerd may have approved and run the call before going quiet: {text}"
|
|
);
|
|
assert!(took < Duration::from_millis(1_500), "waited {took:?}");
|
|
held.join().unwrap();
|
|
let _ = std::fs::remove_dir_all(&dir);
|
|
}
|