Skip to content

test: share the block install harness and bus readers - #936

Open
wagenet wants to merge 1 commit into
Eyevinn:mainfrom
wagenet:wagenet/test-common-block-harness
Open

wagenet wants to merge 1 commit into
Eyevinn:mainfrom
wagenet:wagenet/test-common-block-harness

Conversation

@wagenet

@wagenet wagenet commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Opened by Claude (AI), on Peter Wagenet's account.

Refs #912

Problem

Fourteen tests install one block into a bare pipeline by hand, and about twelve read the bus until a deadline, each in its own way. Every copy has to be fixed separately when the block contract changes.

Change

Moves the copies in seven test files and common/recorder.rs into backend/tests/common:

  • common::block: context(), install(pipeline, built) (adds the elements, links internal_links), install_except for the test that leaves the sink out on purpose, and run_setups(ctx), which runs the element setup hooks with one flow ID, as the manager does.
  • common::bus: first_error, first_error_until (main's early exit in the SRT program-change test) and collect_errors.
  • common::free_udp_port(), replacing three identical srt_port copies.

One commit on main, independent of #935. The only overlap is the pub mod lines in common/mod.rs; whichever merges second needs a trivial resolution there.

Differences from the copies it replaces:

  • install links with link_pads, which finds a static or already-requested pad by name and requests one otherwise. Some copies accepted static pads only. For every builder these tests use, the linked pad pairs match the replaced copy's.
  • Setup hooks get one flow ID per pipeline, as in production. Some copies passed a fresh ID to each.
  • install is still a copy of the manager's linker, now one copy instead of fourteen. Calling the production linker means exporting it from backend/src, a separate PR.

Evidence

Mutations in the test code, run on this head:

  • install without its link loop fails mpegtssrt_input_program_change_test, mpegtssrt_streamheader_test, videoenc_profile_negotiation_test, whip_idle_slot_test and whip_slot_caps_reuse_test. The other three binaries need no links.
  • run_setups as a no-op fails two tests in output_refusal_test and two in recorder_test.
  • collect_errors dropping every error fails the three tests in output_refusal_test.
  • first_error and first_error_until dropping every error fails nothing: their one user asserts there is no error. The copy they replace had the same gap.

Tests

Ran (macOS, 2026-10-09): the seven touched test files and recorder_test: 44 passed, 0 skipped. cargo fmt --check and cargo clippy --all-targets -- -D warnings are clean. Not run: Windows, the full suite.

CI: the Linux check failed in vision_mixer_input_format_test::gpu_videotestsrc_direct, a graphics test this PR does not touch; that binary failed in other PRs' runs today. Cargo stopped there, so whip_idle_slot_test and whip_slot_caps_reuse_test did not run in that job (both ran and passed in #935's). The other touched binaries ran and passed. A re-run is pending.

Out of scope

Eight test files still link blocks by hand: drop_on_latency_test, liveaudiorouter_test, efpsrt_data_roundtrip_test, live_recorder_test, whip_video_damage_test, whip_slot_flush_test, whep_fanout_bench, whip_slot_decoder_reuse_test. The first and third also keep their own free-port code. shader_validation_test and vision_mixer_fx_test are left alone too; #917 has merged, so they can move in a follow-up.

🤖 Generated with Claude Code

@srperens

srperens commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

Noted as a draft, so I am holding off on a full review until it is marked ready for review. If you want one before then, say so here or request me as a reviewer.

Adds common::block (a block built through its real builder, installed into
a bare pipeline with its internal links and element setups), common::bus
(first error, first error until a condition holds, and all errors within a
window) and common::free_udp_port, and uses them in place of the per-file
copies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wagenet
wagenet force-pushed the wagenet/test-common-block-harness branch from 3fde4aa to dd958b0 Compare October 9, 2026 16:58
@wagenet wagenet changed the title test: share the block install harness, bus readers and block-ID claims test: share the block install harness and bus readers Oct 9, 2026
@wagenet
wagenet marked this pull request as ready for review October 9, 2026 20:25
wagenet added a commit to wagenet/strom that referenced this pull request Oct 9, 2026
# Conflicts:
#	backend/tests/common/mod.rs

@srperens srperens left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: Comment. The refactor checks out and the touched binaries passed in CI. One check is red, in a test this diff does not touch. Re-run it before merging: gh run rerun 37962999488 --failed. If it comes back green, I see nothing that blocks this.

Claims

Claim Verdict Evidence
install links the declared internal links through link_pads, request pads included CONFIRMED backend/tests/common/block.rs:51 — src.link_pads(from.pad_name.as_deref(), sink, to.pad_name.as_deref())
The recorder helper now shares the same setup runner CONFIRMED backend/tests/common/recorder.rs:66 — crate::common::block::run_setups(&self.ctx);. Every file that includes common/recorder.rs through #[path] (recorder_test, recorder_stall_test, live_recorder_test) also declares pub mod common;, so crate::common::block resolves in all three
The touched binaries ran and passed in CI CONFIRMED Check (Linux) job 113930309722: mpegtssrt_input_program_change_test 2 passed, mpegtssrt_streamheader_test 1, output_refusal_test 4, recorder_test 9, rtmp_output_test 16, videoenc_profile_negotiation_test 7. whip_idle_slot_test and whip_slot_caps_reuse_test never ran because cargo stopped at the failure
The red check is not this diff's CONFIRMED It is gpu_videotestsrc_direct in vision_mixer_input_format_test, which failed to reach PLAYING. The diff touches no vision mixer file. Check (Linux) passed on main's last five runs, and the same binary has failed on other PRs (#898)

Diagnosis. This moves duplicated code into one place and changes no behaviour, apart from three differences the body names:

  • link_pads replaces the copies that used static pads only;
  • setup hooks get one flow ID per pipeline;
  • install_except covers the test that leaves its sink out on purpose.

The body's mutation results do the guard work a refactor can carry. first_error and first_error_until are unguarded, and the body says so honestly: their only caller asserts that there was no error. install is still a copy, not the production linker. Production feeds internal links through Link strings (backend/src/gst/block_expansion.rs:142 — for (from_ref, to_ref) in build_result.internal_links {), so these tests do not cover how the manager resolves pads. That gap predates this PR, which now keeps it in one place instead of fourteen.

Overlaps.

  • #935 conflicts with this PR in backend/tests/common/mod.rs. I checked with git merge-tree: it is the pub mod lines, as the body says. Whichever merges second needs a one-line resolution. #935 already has my Approve, so landing #935 first and rebasing this one is the cheaper order.
  • #1067 also edits common/mod.rs and merges cleanly with this PR.

Radius. LOCAL: test code only. Nothing under backend/src changes.

Tests & CI. At dd958b0: both Linux builds, WASM, API Contract and Static JS pass. Check (Linux) fails as above. macOS and Windows were skipped. The code is portable test code, so the main-branch build covering them is acceptable. The branch merges cleanly with current main.

Confidence: HIGH

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.

2 participants