Skip to content

test: Consolidate Rust integration tests into category binaries; cap test targets (#968) - #978

Merged
zackees merged 6 commits into
masterfrom
test/968-test-categories
Oct 16, 2026
Merged

zackees merged 6 commits into
masterfrom
test/968-test-categories

Conversation

@zackees

@zackees zackees commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Fixes #968. Refs #700 #897.

RED (f38d92b): ci/test_binary_cap.py + ci/test_test_binary_cap.py. ./lint runs them through its unittest discover -s ci -p test_*.py step. On master it fails:

obs-codec: 9 integration-test binaries (cap 8)
obs-graphics: 32 integration-test binaries (cap 8)
obs-media-io: 25 integration-test binaries (cap 8)
obs-util: 73 integration-test binaries (cap 8)
workspace: 157 integration-test binaries (cap 20)

GREEN (76fce42): tests/*.rs moved with git mv into tests/<category>/<old>.rs, with one mod per file in main.rs. That takes the workspace from 157 targets to 21: obs-util 8, graphics 3, media-io 2, and 1 for every other crate. The workspace cap is 21.

The moves needed a few non-body edits:

  • 2 include_str! paths gained one ../.
  • mod common; became use super::common;, and main.rs now declares #[path="../common/mod.rs"].
  • The base_parity self-respawn now passes the filter base_parity::default_handler_capture_worker.
  • The .proptest-regressions files moved next to their tests.
  • bmem has its own memory binary because it counts allocations process-wide; it failed when it shared a binary.
  • Crate-level #![cfg]/#![allow] stay as module inner attributes, so they still scope to that one file.

Tests: before, 1102 passed and 1 ignored across 156 binaries. After, 1102 passed and 1 ignored across 21 binaries.

Timings (--no-run, this host):

  • Linux, incremental after touching every crate's lib.rs: 104.3 s before, 99.1 s after.
  • Linux, cold: 797 s before, 225 s after. Not a fair comparison: the soldr cache was warmer for the second run.
  • Windows MSVC cross: 279 s after. The before run died at 222 s on a soldr broker error.

Docs: the example in testing-policy.md now uses the category layout. No references to --test <name> or to individual binaries were found in ci/, rust/tools, local-gate.toml or the workflows.

@zackees
zackees marked this pull request as ready for review October 16, 2026 12:30
@zackees
zackees force-pushed the test/968-test-categories branch from 76fce42 to 091f484 Compare October 16, 2026 12:30
@zackees

zackees commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

Rebased onto master (clean) and grouped obs-gpu-status's 4 newer tests/*.rs into its gpu_status binary so the workspace cap (21) holds again. ci/test_binary_cap.py and ./lint pass locally; the local cargo test run hit a soldr daemon timeout compiling the oracle's C (environment), so PR CI runs the tests.

@zackees
zackees enabled auto-merge October 16, 2026 12:33
@zackees

zackees commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

Windows Rust Tests failure (job 116974504460) comes from the consolidation itself, not a flake. Two tests fail in the obs-util profiler category binary:

  • profiler::test_profiler_cmocka (tests/profiler/profiler.rs:203): after.roots.len() is 3, expected 2.
  • profiler_parity::lifecycle_matches_oracle (profiler_parity.rs:221): the snapshot has an extra empty root (overall_count: 0) that belongs to the other test.

The obs-util profiler keeps its roots in process-global state. Before this PR, profiler.rs and profiler_parity.rs were separate binaries, so each ran in its own process. Grouped into one binary, libtest runs them on parallel threads in the same process, and each test sees the other's registrations. It shows up on Windows here because of scheduling, but the race is there on every OS.

Fix options:

  1. A shared static PROFILER_LOCK: Mutex<()> in the category's common module, held for the whole body of every test that touches the profiler. The two tests are then serialized and each one resets the state (profiler_free/profiler_start) under the lock.
  2. Keep the profiler tests as their own binary, as an exception to the per-crate cap.

Option 1 keeps the consolidation, and it is also the regression test for the new layout: a test like this should fail without the lock.

zackees added a commit that referenced this pull request Oct 16, 2026
profiler.rs and profiler_parity.rs both reset the process-global profiler.
As separate binaries each ran alone; grouped into one binary libtest runs
them on parallel threads, each behind its own mutex, so each saw the
other's roots (Windows Rust Tests on #978: 3 roots instead of 2, and an
extra empty root in the parity snapshot).
@zackees

zackees commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

Pushed the profiler fix (58b3b50), RED then GREEN:

  • RED (test: Profiler test modules must share one lock): profiler_tests_share_one_lock in tests/profiler/main.rs checks that profiler::TEST_LOCK and profiler_parity::PARITY_LOCK are the same lock. On the previous head they were two separate mutexes, and it fails with "profiler.rs and profiler_parity.rs must serialize on one lock". This doesn't depend on thread timing, unlike the Windows race.
  • GREEN (test: Serialize the profiler tests on one shared lock): one PROFILER_LOCK in main.rs, which both modules re-export under their old names.

Locally, soldr cargo test -p obs-util --test profiler passes 19/19, and cargo clippy -p obs-util --tests -D warnings and fmt pass. The Windows Rust Tests job is the real check for the race itself.

@zackees
zackees added this pull request to the merge queue Oct 16, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 16, 2026
@zackees
zackees force-pushed the test/968-test-categories branch from 58b3b50 to 3cfc2dc Compare October 16, 2026 13:55
zackees added a commit that referenced this pull request Oct 16, 2026
profiler.rs and profiler_parity.rs both reset the process-global profiler.
As separate binaries each ran alone; grouped into one binary libtest runs
them on parallel threads, each behind its own mutex, so each saw the
other's roots (Windows Rust Tests on #978: 3 roots instead of 2, and an
extra empty root in the parity snapshot).
@zackees

zackees commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

The merge-queue run failed this PR's own cap check: workspace: 22 integration-test binaries (cap 21). #814 merged in between and adds a new crate, obs-preflight, with one test binary. I rebased onto master (no conflicts) and raised WORKSPACE_CAP to 22, giving that reason in the comment as the file asks. ci/test_binary_cap.py passes. Head is now 3cfc2dc.

@zackees
zackees enabled auto-merge October 16, 2026 13:55
@zackees
zackees added this pull request to the merge queue Oct 16, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 16, 2026
#968)

157 test targets -> 21 (<= 8 per crate). Pure moves via git mv; test count
unchanged (1102 passed, 1 ignored). Move-only edits: include_str! paths,
mod common -> use super::common, the base_parity self-respawn filter, and
the proptest regression files. bmem gets its own binary: it counts
allocations process-wide.
profiler.rs and profiler_parity.rs both reset the process-global profiler.
As separate binaries each ran alone; grouped into one binary libtest runs
them on parallel threads, each behind its own mutex, so each saw the
other's roots (Windows Rust Tests on #978: 3 roots instead of 2, and an
extra empty root in the parity snapshot).
One PROFILER_LOCK in the category binary's main.rs; profiler.rs and
profiler_parity.rs re-export it as TEST_LOCK and PARITY_LOCK, so their
tests no longer reset the global profiler under each other.
#814 merged a new crate, obs-preflight, with one integration-test binary.
That is a new crate's single binary, not a missed consolidation, so the
workspace cap goes from 21 to 22.
@zackees

zackees commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

Rebased onto master again (clean; conflicted after ~4 h idle). ci/test_binary_cap.py still OK at cap 22.

@zackees
zackees force-pushed the test/968-test-categories branch from 3cfc2dc to d0770a6 Compare October 16, 2026 17:22
@zackees
zackees enabled auto-merge October 16, 2026 17:22
@zackees
zackees added this pull request to the merge queue Oct 16, 2026
Merged via the queue into master with commit a263104 Oct 16, 2026
27 checks passed
zackees added a commit that referenced this pull request Oct 17, 2026
#978 moved threading_allocs into the threading binary, where ~40 tests
run in parallel and several allocate through bmem, so its absolute
deltas of the process-wide bnum_allocs() counter race (macOS master run
38979468586: left 6, right 5). holds_under_concurrent_allocation keeps
another thread allocating through bmem while the same measurement runs:
it fails every time (5/5 locally, left 7 right 4).

Refs #1133
zackees added a commit to vpacher/obs-studio that referenced this pull request Oct 17, 2026
…ust#1209)

* test: bnum_allocs checks must hold while other tests allocate (RED)

obs-rust#978 moved threading_allocs into the threading binary, where ~40 tests
run in parallel and several allocate through bmem, so its absolute
deltas of the process-wide bnum_allocs() counter race (macOS master run
38979468586: left 6, right 5). holds_under_concurrent_allocation keeps
another thread allocating through bmem while the same measurement runs:
it fails every time (5/5 locally, left 7 right 4).

Refs obs-rust#1133

* test(obs-util): measure bmem counters in an isolated child process

The bnum_allocs checks in threading_allocs and bmem_parity now run alone in
a re-exec of the test binary, so the binary's other tests can allocate in
parallel without skewing the deltas.

Fixes obs-rust#1133
@zackees
zackees deleted the test/968-test-categories branch October 26, 2026 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

test: Consolidate Rust integration tests into category binaries; lint a cap on test targets

1 participant