Skip to content

E2E test: Heartbeat handling — verify echo and callback#312

Closed
s2x wants to merge 1 commit intomainfrom
oda-161-e2e-test-heartbeat-handling-verify-echo
Closed

E2E test: Heartbeat handling — verify echo and callback#312
s2x wants to merge 1 commit intomainfrom
oda-161-e2e-test-heartbeat-handling-verify-echo

Conversation

@s2x
Copy link
Copy Markdown
Contributor

@s2x s2x commented Mar 30, 2026

Closes #161

Problem

StreamConnection::dispatchServerPush() handles heartbeats (key 0x0017) by echoing back a heartbeat frame and optionally invoking a registered callback. No E2E test verifies this behavior. In production, heartbeat failures cause connection drops.

Expected test

public function testHeartbeatIsEchoedBack(): void
{
    // 1. Connect with a short heartbeat interval (e.g., 2 seconds)
    //    by sending TuneResponseV1 with heartbeat=2
    // 2. Register heartbeat callback
    // 3. Wait in readLoop for heartbeat interval + margin
    // 4. Verify callback was invoked
    // 5. Verify connection is still alive (heartbeat was echoed)
}

Why it matters

Notes

  • This test requires waiting for the heartbeat interval, so it will be slower
  • Consider using a short heartbeat (1-2 seconds) to keep test duration reasonable
  • The Tune negotiation determines the heartbeat interval

Acceptance criteria

Add comprehensive E2E tests to verify:
- Heartbeat callback is invoked when server sends heartbeat
- Connection remains alive after heartbeat exchange
- No correlationId desync after heartbeat (regression test for #101)
- Heartbeat without callback does not crash
- Multiple heartbeats keep connection alive

Tests use 1-second heartbeat interval and readLoop() to wait for
server-initiated heartbeats, verifying the echo mechanism and callback
system work correctly.
@s2x s2x closed this Mar 30, 2026
@s2x s2x deleted the oda-161-e2e-test-heartbeat-handling-verify-echo branch March 30, 2026 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

E2E test: Heartbeat handling — verify echo and callback

1 participant