Skip to content

test: wait for the player state instead of sleeping - #186

Draft
JarbasAl wants to merge 1 commit into
devfrom
fix/ocp-bridging-test-waits-on-state
Draft

test: wait for the player state instead of sleeping#186
JarbasAl wants to merge 1 commit into
devfrom
fix/ocp-bridging-test-waits-on-state

Conversation

@JarbasAl

@JarbasAl JarbasAl commented Sep 7, 2026

Copy link
Copy Markdown
Member

🤖 Auto-generated by Claude Sonnet 5 (claude-sonnet-5) via Claude Code — NOT human-reviewed. Verify before acting.

TestOCPHarnessNamespaceBridging::test_no_bridging_isolates_spec_from_legacy intermittently fails when the full unit suite runs, with Expected PlayerState.PLAYING, got PlayerState.STOPPED, but always passes when run alone. Each test in that class emits a bus message, sleeps for a fixed 0.05–0.2s, then asserts the player state. That includes the shared _play_then() helper, which starts playback and immediately checks for PLAYING. Under load the FakeBus dispatch thread can take longer than the fixed sleep to actually update player.state, so the assertion races the dispatch.

The fix drops every fixed sleep in this class in favor of a small local helper that polls player.state every 10ms for up to 2 seconds and returns as soon as it matches the expected state (or the timeout elapses). This is applied to _play_then() and to all three tests that follow the same emit-sleep-assert shape: test_cork_via_legacy_topic_natively, test_cork_via_spec_topic_through_bridging, and test_no_bridging_isolates_spec_from_legacy. What each test asserts is unchanged.

I could not force the flake to reproduce locally despite several attempts (CPU-quota throttling down to 0.25 cores via cap, and running with six CPU-bound competing processes), so I cannot paste a captured failing run. The fix targets the documented race (fixed sleep racing an async dispatch thread) directly and cannot regress passing behavior, since it only makes assertions wait longer for the same expected state rather than changing what is checked. Full unit suite (pytest test/unittests) passed at 688 passed / 24 skipped on Python 3.10 (two runs) and Python 3.11 (one run) after the change.

@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

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.

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown

Hello there! Your PR checks are ready for review. ✨

I've aggregated the results of the automated checks for this PR below.

📋 Repo Health

Checking if the repo is following its diet. 🥗

✅ All required files present.

Latest Version: 1.8.1a1

ovoscope/version.py — Version file
README.md — README
LICENSE — License file
pyproject.toml — pyproject.toml
⚠️ setup.py — setup.py
CHANGELOG.md — Changelog
ovoscope/version.py has valid version block markers

🔍 Lint

Here's the latest update on this check. 🗞️

ruff: issues found — see job log

🏷️ Release Preview

I've checked the 'Migration Guide' for clarity. 🗺️

Current: 1.8.1a1Next: 1.8.1a2

Signal Value
Label (none)
PR title test: wait for the player state instead of sleeping
Bump alpha

✅ PR title follows conventional commit format.


🚀 Release Channel Compatibility

Predicted next version: 1.8.1a2

Channel Status Note Current Constraint
Stable Not in channel -
Testing Too new (must be <1.0.0) ovoscope>=0.7.2,<1.0.0
Alpha Compatible ovoscope>=1.6.15a1

🔒 Security (pip-audit)

Scanning for any potential man-in-the-middle risks. 👨‍💻

✅ No known vulnerabilities found (129 packages scanned).

⚖️ License Check

Ensuring no unlicensed code has snuck in. 🕵️

✅ No license violations found.

Policy: Apache 2.0 (universal donor). StrongCopyleft / NetworkCopyleft / WeakCopyleft / Other / Error categories fail. MPL allowed.

📊 Coverage

Calculating the density of our test suite. 🧮

⚠️ 62.8% total coverage

Files below 80% coverage (15 files)
File Coverage Missing lines
ovoscope/simple_listener.py 0.0% 63
ovoscope/version.py 0.0% 5
ovoscope/classic_listener.py 18.2% 117
ovoscope/intent_cases.py 22.3% 153
ovoscope/pytest_plugin.py 47.0% 210
ovoscope/cli.py 47.8% 132
ovoscope/ocp.py 47.9% 61
ovoscope/tts_intelligibility.py 49.0% 102
ovoscope/e2e.py 56.2% 67
ovoscope/media.py 56.7% 101
ovoscope/listener.py 57.1% 127
ovoscope/voice_loop.py 59.0% 119
ovoscope/__init__.py 63.2% 423
ovoscope/audio.py 64.4% 126
ovoscope/media_provider.py 67.6% 23

Full report: download the coverage-report artifact.

🔨 Build Tests

The build process has successfully terminated. 🏁

✅ All versions pass

Python Build Install Tests
3.10
3.11
3.12
3.13
3.14

The automation engine never sleeps. 🚂

TestOCPHarnessNamespaceBridging asserted the player state right after a
fixed time.sleep() following each bus emit. Under full-suite load the
FakeBus dispatch thread can take longer than the sleep to update the
player, so test_no_bridging_isolates_spec_from_legacy intermittently
observed PlayerState.STOPPED instead of PLAYING/PAUSED (it passes in
isolation, where dispatch is fast).

Replaced every fixed sleep in the class, including the one inside the
shared _play_then() helper, with a bounded poll (10ms interval, 2s
timeout) on h.player.state via a small local helper. The assertions
themselves are unchanged.

Full unit suite: 688 passed, 24 skipped on Python 3.10 (x2) and 3.11 (x1).
@JarbasAl
JarbasAl force-pushed the fix/ocp-bridging-test-waits-on-state branch from 57b147c to d475857 Compare September 8, 2026 00:45
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