Skip to content

Flaky unit tests on CI: RtpListenerTest and JieliTest fail now and then #257

Closed

Description

@compot-dev

Problem

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

  1. added a commit that references this issue on Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions