Skip to content

Commit 4259c0e

Browse files
test(e2e): ignore stale sessions when waiting for a check-in
All e2e tests share one database and run in parallel, so a lingering session from an earlier or finished test could satisfy wait_for_session and swallow the tasks a later test submits (observed as a DNS beacon test timing out under load). Only accept sessions first seen within the last few seconds.
1 parent c3ed6b5 commit 4259c0e

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

‎Cargo.lock‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎crates/server/Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ shikra-implant.workspace = true
5454
base64.workspace = true
5555
hex.workspace = true
5656
prost.workspace = true
57+
prost-types.workspace = true
5758
sha2.workspace = true
5859
tempfile.workspace = true
5960
tracing-subscriber.workspace = true

‎crates/server/tests/e2e.rs‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,22 @@ async fn wait_for_session(
1414
client: &mut shikra_client::OperatorClient,
1515
timeout: Duration,
1616
) -> anyhow::Result<shikra_proto::v1::SessionInfo> {
17+
// Tests share one database and may run in parallel; sessions from
18+
// earlier or finished tests linger until the reaper marks them dead.
19+
// Ignore sessions first seen well before this test, so a stale session
20+
// can never satisfy the wait and swallow the task we are about to send.
21+
let cutoff =
22+
prost_types::Timestamp::from(std::time::SystemTime::now() - Duration::from_secs(5));
1723
let deadline = tokio::time::Instant::now() + timeout;
1824
loop {
1925
let sessions = client.sessions().await?;
20-
if let Some(session) = sessions.into_iter().next() {
26+
let found = sessions.into_iter().find(|session| {
27+
session
28+
.first_seen
29+
.as_ref()
30+
.is_some_and(|seen| (seen.seconds, seen.nanos) >= (cutoff.seconds, cutoff.nanos))
31+
});
32+
if let Some(session) = found {
2133
return Ok(session);
2234
}
2335
if tokio::time::Instant::now() >= deadline {

0 commit comments

Comments
 (0)