fix(tui): surface incomplete statistics and strengthen review coverage
This commit is contained in:
4 files changed
+239
-22
No files matched your search
@@ -355,3 +355,12 @@ fn duration_close_waits_for_rate_allowance_after_the_deadline() {
|
||||
assert_eq!(closed.recv_window, Some(3));
|
||||
assert_eq!(server.session_count(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn default_server_resource_limits_remain_bounded() {
|
||||
let config = ServerConfig::default();
|
||||
// Upper resource budgets, not an exact default or a comparison against
|
||||
// the same constants used by the implementation. Smaller bounds are fine.
|
||||
assert!((1..=1024).contains(&config.max_sessions()));
|
||||
assert!((1..=65_507).contains(&config.max_packet_length()));
|
||||
}
|
||||
@@ -158,8 +158,8 @@ async fn wildcard_construction_is_refused_without_reply_source_selection() {
|
||||
|
||||
// A current-thread runtime cannot receive while this test holds its thread.
|
||||
// Queue real packets before delaying the server: no synthetic ancillary data or
|
||||
// transport hooks. A short queue delay selects kernel wall time; a delay beyond
|
||||
// the documented one-second sanity bound falls back to userspace. Monotonic and
|
||||
// transport hooks. Observed queue timing determines whether kernel wall time
|
||||
// is plausible under the one-second bound, including scheduler overshoot. Monotonic and
|
||||
// midpoint timestamps must always remain at the later userspace observation.
|
||||
#[cfg(target_os = "linux")]
|
||||
#[tokio::test(flavor = "current_thread")]
|
||||
@@ -174,10 +174,10 @@ async fn queued_echoes_select_kernel_receive_wall_only_when_plausible() {
|
||||
)
|
||||
.unwrap()
|
||||
};
|
||||
for (placement, delay, kernel_expected) in [
|
||||
(StampAt::Both, Duration::from_millis(100), true),
|
||||
(StampAt::Both, Duration::from_millis(1100), false),
|
||||
(StampAt::Midpoint, Duration::from_millis(100), false),
|
||||
for (placement, delay) in [
|
||||
(StampAt::Both, Duration::from_millis(100)),
|
||||
(StampAt::Both, Duration::from_millis(1100)),
|
||||
(StampAt::Midpoint, Duration::from_millis(100)),
|
||||
] {
|
||||
let mut server = Server::bind("127.0.0.1:0".parse().unwrap(), unthrottled())
|
||||
.await
|
||||
@@ -238,23 +238,43 @@ async fn queued_echoes_select_kernel_receive_wall_only_when_plausible() {
|
||||
assert_eq!(reply.recv_count, Some(1));
|
||||
assert_eq!(reply.recv_window, Some(1));
|
||||
let timestamps = reply.timestamps;
|
||||
if kernel_expected {
|
||||
if placement == StampAt::Both {
|
||||
let receive = timestamps.recv_wall.unwrap();
|
||||
assert!(
|
||||
receive >= before_send && receive <= queued_by,
|
||||
"receive wall must identify the kernel arrival before the queue delay"
|
||||
);
|
||||
let wall_elapsed = timestamps.send_wall.unwrap() - receive;
|
||||
let mono_elapsed = timestamps.send_mono.unwrap() - timestamps.recv_mono.unwrap();
|
||||
assert!(
|
||||
wall_elapsed - mono_elapsed >= 50_000_000,
|
||||
"queue delay must not move the monotonic endpoint"
|
||||
);
|
||||
let send = timestamps.send_wall.unwrap();
|
||||
let kernel_endpoint = (before_send..=queued_by).contains(&receive);
|
||||
let userspace_endpoint = (resumed_at..=send).contains(&receive);
|
||||
// Arrival lies in [before_send, queued_by], and core observation
|
||||
// lies in [resumed_at, send]. Only demand one selection where these
|
||||
// observed bounds put the whole lag interval on one side of 1 s.
|
||||
// Scheduler overshoot can legitimately change the expected path.
|
||||
if send - before_send <= 1_000_000_000 {
|
||||
assert!(
|
||||
kernel_endpoint,
|
||||
"plausible arrival must select kernel wall time"
|
||||
);
|
||||
} else if resumed_at - queued_by > 1_000_000_000 {
|
||||
assert!(
|
||||
userspace_endpoint,
|
||||
"stale arrival must fall back to userspace"
|
||||
);
|
||||
} else {
|
||||
assert!(
|
||||
kernel_endpoint || userspace_endpoint,
|
||||
"boundary observation must identify a real endpoint"
|
||||
);
|
||||
}
|
||||
if kernel_endpoint {
|
||||
let wall_elapsed = send - receive;
|
||||
let mono_elapsed = timestamps.send_mono.unwrap() - timestamps.recv_mono.unwrap();
|
||||
assert!(
|
||||
wall_elapsed - mono_elapsed >= 50_000_000,
|
||||
"queue delay must not move the monotonic endpoint"
|
||||
);
|
||||
}
|
||||
} else {
|
||||
let receive = timestamps.recv_wall.or(timestamps.midpoint_wall).unwrap();
|
||||
assert!(
|
||||
receive >= resumed_at,
|
||||
"fallback and midpoint must use userspace time"
|
||||
timestamps.midpoint_wall.unwrap() >= resumed_at,
|
||||
"midpoint must use userspace time"
|
||||
);
|
||||
}
|
||||
stop_tx.send(()).unwrap();
|
||||
|
||||
Reference in new issue
Block a user