Skip to content

Harden the racy signal assertions in NoiseCancellationSignalTest - #1791

Merged
andremion merged 1 commit into
developfrom
andrerego/and-1465-harden-the-racy-signal-assertions-in
Aug 31, 2026
Merged

Harden the racy signal assertions in NoiseCancellationSignalTest#1791
andremion merged 1 commit into
developfrom
andrerego/and-1465-harden-the-racy-signal-assertions-in

Conversation

@andremion

@andremion andremion commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Goal

Fix the test that fails deterministically on the develop-v2 merge PR #1790: NoiseCancellationSignalTest > a replacement session is told the current state fails there with expected:<[true]> but was:<[]> on every attempt of the Android CI run, while it passes on develop.

Resolves AND-1465.

Implementation

The failure is a race in the test, not in the production code. The record helper collects the signalled states into a plain mutableListOf from the mock's coAnswers block, which runs on the signal coroutine. The tests assert on that list right after a coVerify(timeout = ...). MockK records the invocation before the answer block finishes, and the list is not thread safe, so the assert can run before the append is visible to the test thread. develop's coroutines 1.9.0 happens to give the timing the test needs; develop-v2's coroutines 1.10.2 consistently does not.

Changes, all in NoiseCancellationSignalTest.kt:

  • record() now collects into a CopyOnWriteArrayList, so writes from the signal coroutine are visible to the test thread.
  • The four instant asserts on the recorded list are replaced with polling helpers that wait for the expected content with the existing 5s deadline: awaitSignalled for the exact-content checks and awaitFinalSignal for the "rapid changes" test where only the last state matters.

No production code change.

🎨 UI Changes

Not applicable, test-only change.

Testing

  • Ran the test class 4 times locally (once normally, 3 times with --rerun-tasks): 8 tests, 0 failures each time.
  • The definitive proof will be the next develop merge into develop-v2, where the previous version failed on both CI attempts.

Summary by CodeRabbit

  • Tests
    • Improved signal-related test reliability by accommodating asynchronous event recording.
    • Replaced immediate snapshot checks with polling assertions and timeout handling.
    • Added thread-safe recording for mocked signal events.

@andremion
andremion requested a review from a team as a code owner August 31, 2026 09:25
@andremion andremion added the pr:internal Internal or infra-only changes label Aug 31, 2026
@github-actions

github-actions Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled, or the PR is bot-authored.
  • An issue is linked (Linear ticket or GitHub issue), or the PR is bot-authored.

🎉 Great job! This PR is ready for review.

@github-actions

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-video-android-core 12.29 MB 12.29 MB 0.00 MB 🟢
stream-video-android-ui-xml 5.70 MB 5.70 MB 0.00 MB 🟢
stream-video-android-ui-compose 6.23 MB 6.23 MB 0.00 MB 🟢

@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9fbd1933-1794-4bab-93c1-793f75633409

📥 Commits

Reviewing files that changed from the base of the PR and between ff9ae01 and 181e01d.

📒 Files selected for processing (1)
  • stream-video-android-core/src/test/kotlin/io/getstream/video/android/core/NoiseCancellationSignalTest.kt

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


Walkthrough

The noise cancellation signal tests now record signals in a thread-safe list and poll for expected values before asserting. Four tests use the new polling helpers.

Changes

Noise cancellation signal test synchronization

Layer / File(s) Summary
Polling-based signal assertions
stream-video-android-core/src/test/kotlin/io/getstream/video/android/core/NoiseCancellationSignalTest.kt
The test recorder uses CopyOnWriteArrayList. New helpers wait for expected signal lists or final values. Four tests use these helpers instead of immediate snapshot assertions.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 181e0

This test-only change makes asynchronous signal assertions thread-safe and more reliable without changing production behavior, public interfaces, security controls, or deployment configuration; no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: aleksandar-apostolov

Poem

A rabbit watched the signals race
And gave each one a little space
The list stayed safe and bright
Polling found the value right
Tests now wait before they bite

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 44.44% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly describes the primary change: hardening race-prone signal assertions in NoiseCancellationSignalTest.
Description check ✅ Passed The description covers the goal, implementation, UI applicability, testing, issue reference, affected file, and test results. The UI and GIF sections are appropriately addressed or non-critical for th…
Full details: Description check

Explanation

The description covers the goal, implementation, UI applicability, testing, issue reference, affected file, and test results. The UI and GIF sections are appropriately addressed or non-critical for this test-only change.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch andrerego/and-1465-harden-the-racy-signal-assertions-in

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

@andremion
andremion enabled auto-merge (squash) August 31, 2026 09:37
@andremion

Copy link
Copy Markdown
Contributor Author

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@andremion andremion added pr:internal Internal or infra-only changes and removed pr:internal Internal or infra-only changes labels Aug 31, 2026
@andremion
andremion merged commit b530e34 into develop Aug 31, 2026
22 of 28 checks passed
@andremion
andremion deleted the andrerego/and-1465-harden-the-racy-signal-assertions-in branch August 31, 2026 09:54
@stream-public-bot stream-public-bot added the released Included in a release label Sep 1, 2026
@stream-public-bot

Copy link
Copy Markdown
Collaborator

🚀 Available in v1.32.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:internal Internal or infra-only changes released Included in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants