You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Flaky unit tests on CI: RtpListenerTest and JieliTest fail now and then #257
Two unit tests fail now and then on the GitHub runners while the same commit passes in another run (and locally). On the branch of #256 the push build failed twice in one day and passed on a re-run each time; a failed test job also skips the build, so a branch gets no APK artifact until someone re-runs it.
Test
Failure
Run
RtpListenerTest.silenceIsReportedWithoutRebinding
java.util.ConcurrentModificationException at RtpListenerTest.java:288
41219980111 (commit 5b669e7; the pull request run of the same commit passed)
JieliTest.noVideoListensElsewhereAndAsksAgain
AssertionError at JieliTest.java:825 (assertNotNull(d): no diagnostic_ports in the stats)
41222571691 (commit 6b89c7d; passed on re-run and in the pull request run)
Likely causes
RtpListenerTest: rec.statuses is a Collections.synchronizedList, but Collections.frequency(rec.statuses, …) and contains iterate it without holding its lock while the listener thread adds statuses. A CopyOnWriteArrayList (or synchronized (rec.statuses) around the reads) removes the race.
JieliTest: the loop waits at most 3 s for both the second OPEN_RT_STREAM and diagnostic_ports; on a loaded runner the diagnostic packet can be counted later (or the stats read before it), and the test then fails on assertNotNull(d). The wait should cover the condition that is asserted, with more headroom, and the loop condition and the asserts should read one snapshot of the stats.
Done when
Both tests are fixed so they no longer depend on timing or unsynchronized reads.
The other tests that read lists filled by a listener thread are checked for the same pattern.
Many local runs pass (e.g. ./gradlew testDebugUnitTest --rerun-tasks in a loop, also with the CPU loaded).
Activity
Merge pull request #259 from OpenIPC/fix/flaky-tests-257