Skip to content

test: fix the flaky heartbeat test (count read before it is updated) - #227

Merged
compot-dev merged 1 commit into
v2from
fix/flaky-heartbeat-test
Oct 17, 2026
Merged

compot-dev merged 1 commit into
v2from
fix/flaky-heartbeat-test

Conversation

@compot-dev

Copy link
Copy Markdown
Collaborator

Test only, no app change, no version bump.

RtspSessionTest.heartbeatWhilePlayingStopsWithTheSlot failed once in 7 local runs (assertTrue(sent >= 2)): UdpHeartbeat counts a heartbeat after send() returns, so the test can receive the second 01 01 before the count reaches 2. The app is right to count only what was sent; the test now waits up to 2 s for the count.

Checked locally in compot/android:2026.10: testDebugUnitTest + lintDebug green; the test alone 15/15 with --rerun.

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Stabilize the RTSP heartbeat count test

🧪 Tests 🕐 Less than 10 minutes

Grey Divider

AI Description

• Wait up to two seconds for the heartbeat count after receiving two UDP packets.
• Preserve the existing checks that heartbeats run during playback and stop with the session.
Diagram

graph TD
  Receive["Receive two packets"] --> Read["Read heartbeat stats"] --> Ready{"Count reached two?"}
  Ready -->|No, before deadline| Wait["Sleep 10 ms"] --> Read
  Ready -->|Yes or timeout| Assert["Assert heartbeat state"] --> Stop["Stop session"]
Loading
High-Level Assessment

Bounded polling is appropriate for this test: it accommodates the interval between UDP delivery and the post-send count update without changing production accounting. A synchronization hook would add production complexity for a test-only race.

Files changed (1) +6 / -0

Tests (1) +6 / -0
RtspSessionTest.javaWait for the heartbeat count before asserting +6/-0

Wait for the heartbeat count before asserting

• After receiving two heartbeat datagrams, the test polls heartbeat statistics every 10 ms for up to two seconds. This avoids asserting before the sender increments its post-send count; the running and stop checks remain in place.

android/app/src/test/java/com/openipc/decoder/RtspSessionTest.java

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can see how risky a PR is at a glance with blast radius labels

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@compot-dev
compot-dev merged commit 705ef14 into v2 Oct 17, 2026
4 checks passed
@compot-dev
compot-dev deleted the fix/flaky-heartbeat-test branch October 17, 2026 15:47
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.

1 participant