fix(cli): drive single-target runs with ManagedClient

Replace the manual single-target ClientSession loops in the stream and TUI adapters with ManagedClient::start_with_subscription so the existing worker owns opening, deadline-aware pacing, receive handling, timeout polling, draining, and close.

Use bounded subscription waits for interruption and input polling, drain queued events before and after join, and report per-subscription drops without changing output, statistics, labels, summaries, warning, or peer-close policy. Add process and unit regressions for 10 ms cadence, interruption, final-event draining, TUI terminal state, and overflow visibility.
This commit is contained in:
Nils Andreas Svee committed 2026-07-28 14:42:02 +07:00
1 parent 080d45ca67
commit 6af4663b6e
9 files changed
+530 -477

No files matched your search

+37 -1
View File
@@ -358,7 +358,7 @@ impl OutcomeCounters {
#[cfg(test)]
mod tests {
use super::*;
use crate::{config::NegotiationPolicy, SubscriberOverflow};
use crate::{config::NegotiationPolicy, EventSubscriptionError, SubscriberOverflow};
use irtt_proto::{
echo_packet_len,
flags::{self, FLAG_OPEN, FLAG_REPLY},
@@ -687,6 +687,42 @@ mod tests {
.any(|event| matches!(event, ClientEvent::SessionClosed { .. })));
}
#[test]
fn joining_before_consuming_preserves_queued_final_events() {
let duration = Duration::from_millis(25);
let server = start_echo_server(test_params(Some(duration), Duration::from_millis(10)));
let (session, sub) = ManagedClient::start_with_subscription(
config(server.addr, Some(duration)),
SubscriberConfig {
capacity: 32,
overflow: SubscriberOverflow::DropOldest,
},
)
.unwrap();
let outcome = session.join().unwrap();
let mut events = Vec::new();
loop {
match sub.try_recv() {
Ok(Some(event)) => events.push(event),
Ok(None) => panic!("joined managed subscription remained connected"),
Err(EventSubscriptionError::Disconnected) => break,
}
}
server.join();
assert_eq!(outcome.end_reason, SessionEndReason::TestComplete);
assert_eq!(sub.dropped_events(), 0);
assert!(matches!(
events.first(),
Some(ClientEvent::SessionStarted { .. })
));
assert!(matches!(
events.last(),
Some(ClientEvent::SessionClosed { .. })
));
}
#[test]
fn finite_managed_run_drains_late_reply_after_timeout_before_close() {
let duration = Duration::from_millis(1);