test: protect durable behavior identified in review
This commit is contained in:
7 files changed
+528
-6
No files matched your search
@@ -316,3 +316,42 @@ fn negotiated_timestamp_modes_emit_only_the_selected_fields_in_order() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn duration_close_waits_for_rate_allowance_after_the_deadline() {
|
||||
let refill = Duration::from_secs(4);
|
||||
let maximum = Duration::from_millis(1);
|
||||
let mut server = ServerCore::new(
|
||||
ServerConfig::default()
|
||||
.with_min_send_interval(refill)
|
||||
.with_burst_allowance(1)
|
||||
.with_idle_timeout(Duration::MAX)
|
||||
.with_max_test_duration(maximum),
|
||||
);
|
||||
let opened = open(
|
||||
&mut server,
|
||||
&Params {
|
||||
received_stats: ReceivedStats::Both,
|
||||
..Params::with_protocol_defaults()
|
||||
},
|
||||
);
|
||||
let first = echo(&mut server, &opened, 0).unwrap();
|
||||
assert_eq!(first.flags & FLAG_CLOSE, 0);
|
||||
thread::sleep(maximum + Duration::from_secs(2));
|
||||
assert!(
|
||||
echo(&mut server, &opened, 63).is_none(),
|
||||
"exhausted allowance must suppress the deadline-crossing reply"
|
||||
);
|
||||
assert_eq!(
|
||||
server.session_count(),
|
||||
1,
|
||||
"rate refusal must not release the session"
|
||||
);
|
||||
thread::sleep(refill);
|
||||
let closed = echo(&mut server, &opened, 1).unwrap();
|
||||
assert_ne!(closed.flags & FLAG_CLOSE, 0);
|
||||
assert_eq!(closed.sequence, 1);
|
||||
assert_eq!(closed.recv_count, Some(2));
|
||||
assert_eq!(closed.recv_window, Some(3));
|
||||
assert_eq!(server.session_count(), 0);
|
||||
}
|
||||
Reference in new issue
Block a user