Skip to content

test: fix flaky large raw-frame roundtrips (poll instead of fixed settle)#62

Open
pham-tuan-binh wants to merge 1 commit into
mainfrom
test/frame-video-flaky-settle
Open

test: fix flaky large raw-frame roundtrips (poll instead of fixed settle)#62
pham-tuan-binh wants to merge 1 commit into
mainfrom
test/frame-video-flaky-settle

Conversation

@pham-tuan-binh

Copy link
Copy Markdown
Collaborator

Fixes #60.

Problem

Two frame-video integration tests flaked:

  • test_frame_video.py::test_large_frame_above_data_packet_cap (2.7 MB raw)
  • test_frame_video_stress.py::test_4k_frame_roundtrip[raw] (24.9 MB raw)

They slept a fixed window then asserted the frame had arrived. Profiling showed a 25 MB raw frame takes ~4.6s over the byte-stream path, essentially equal to the test's 4.6s window. Under any load the assert raced the transfer and failed. The transfer itself is correct and byte-exact (the PNG/MJPEG variants, which compress small, always passed).

Fix

Test-only. Add a wait_for(predicate, timeout_s) polling helper to conftest.py and use it in both tests. Poll for arrival up to a generous ceiling (15s / 30s) instead of racing a fixed sleep. It returns as soon as the frame lands, so the fast path stays fast and only a genuine failure waits out the timeout.

No production code changed. This is the transport-latency characteristic already documented for the byte-stream path, the tests just need to tolerate it.

Verification

Against a local LiveKit server:

  • The two previously-failing cases, run together, twice: pass
  • Both full frame-video files in one process (the contention scenario): 44 passed, 0 failed

Branched from main, independent of #58 and #61.

The large-raw-frame roundtrips (test_large_frame_above_data_packet_cap,
test_4k_frame_roundtrip[raw]) flaked because they slept a fixed window
then asserted the frame had arrived. A 25 MB raw frame takes ~4.6s over
the byte-stream path, essentially equal to the 4.6s window, so under any
load the assert raced the transfer and failed. The transfer itself is
correct and byte-exact.

Add a `wait_for` polling helper to conftest and use it in both tests:
poll for arrival up to a generous ceiling (15s / 30s) instead of racing
a fixed sleep. Returns as soon as the frame lands, so the fast path stays
fast and only genuine failures wait out the timeout.

Fixes #60
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.

Large raw (uncompressed) frame byte-stream roundtrips fail

1 participant