Skip to content

Clean up e2e test scripts ahead of open-sourcing#1

Merged
DanielMao1 merged 4 commits into
devfrom
refactor/tests-cleanup
May 29, 2026
Merged

Clean up e2e test scripts ahead of open-sourcing#1
DanielMao1 merged 4 commits into
devfrom
refactor/tests-cleanup

Conversation

@fecet
Copy link
Copy Markdown
Contributor

@fecet fecet commented May 29, 2026

What & why

We're getting the repo ready to open-source, so I went through tests/ — especially the manual tests/e2e/ scripts — looking for dead code, comment/code mismatches, and logic that looks clever but doesn't actually do anything.

The unit tests (test_*.py + _fakes.py) turned out to be clean, so they're left untouched. The problems were concentrated in tests/e2e/, where scripts had been copy-pasted and only half-edited — leaving behind wrong paths, contradictory comments, and dead functions. Most importantly, smoke.sh couldn't run on a fresh clone at all.

Changes

Grouped into focused commits so they're easy to review one at a time:

fix(e2e) — correct output paths & make smoke runnable without GPU/camera

  • E2E_DIR pointed at a non-existent repo-root e2e/ (missing tests/), so artifacts landed outside the .gitignored location and polluted the working tree. Now points at tests/e2e.
  • smoke.sh ran sender.py, which needs nvh264enc (GPU) + a physical RealSense camera + pyrealsense2 (not even in the pixi env). Switched to sender_sw.py (software x264enc).
  • receiver.py now decodes via avdec_h264 and uses fakesink, so it runs truly headless on any machine.
  • ipc_two_procs/run.sh: temp-dir cleanup tested -f on a directory (always false, so it leaked) → fixed to -d.
  • Fixed README command/artifact paths and dropped the dead E2E_HEADLESS env var.

refactor(e2e) — remove dead code & misleading comments

  • Dropped a never-called create_test_video_source(), # noqa-suppressed dead imports, # not used comments on a TURN var that's actually passed to the constructor, and a sys.path hack pointing at the wrong dir.
  • receiver_msid_save.py claimed # Keep CPU decode but used nvh264dec; it now actually decodes on CPU.

refactor(gpu_sink) — drop a no-op param & fix a stale comment

  • GpuFrameSink's copy_frame ctor param never changed behavior (frames were always copied regardless); removed it and the dead branch.
  • Fixed a stale ICE comment (>3s>1s) that contradicted both the code and the unit test.

fix(e2e) — bind gpu_sink_save to the receiver's msid-renamed appsink

  • Pre-existing bug found while verifying: WebRTCReceiver renames the appsink to the incoming stream's msid, but gpu_sink_save.py bound by GpuFrameSink's original name → never matched → gpu_sink.sh always timed out on any machine. It now discovers the appsink by element type, the way appsink_msid_e2e.py already does.

Verification

ruff check src tests        ── clean
pytest -m "not gpu"         ── 50 passed
tests/e2e/smoke.sh          ── PASS (both stages; stage 2 actually saves frames)
tests/e2e/gpu_sink.sh       ── PASS (5 frames saved & verified)

Also confirmed the repo root no longer grows a stray e2e/ directory.

Notes

  • Unit tests and _fakes.py are intentionally untouched — they're clean.
  • sender.py is kept as the RealSense hardware demo (only its dead code was removed), not wired into the headless smoke flow.

Summary by CodeRabbit

  • Bug Fixes

    • Improved error handling in IPC test processes with proper validation and status reporting
    • Fixed directory cleanup logic for temporary file management
  • Documentation

    • Updated end-to-end test instructions with correct script paths and artifact locations
  • Tests

    • Reorganized test infrastructure and consolidated script locations
    • Enhanced test pipeline setup with improved frame processing and codec handling
    • Standardized GPU sink frame ownership behavior for consistent thread safety

Review Change Stack

fecet added 4 commits May 29, 2026 17:41
Artifacts were written to a non-existent repo-root e2e/ (missing tests/), bypassing .gitignore; smoke.sh ran sender.py which needs nvh264enc + a RealSense camera + pyrealsense2 (absent from pixi), so it failed on any clone.

- smoke.sh/gpu_sink.sh: point E2E_DIR under tests/e2e (was repo-root e2e/)
- smoke.sh: run sender_sw.py (software x264enc), drop dead E2E_HEADLESS var
- receiver.py: decode via avdec_h264 and use fakesink for headless runs
- ipc_two_procs/run.sh: fix temp-dir cleanup test (-f -> -d)
- .gitignore: ignore stage-2 frames_msid/ output
- README: fix command/artifact paths and sender script name
…cripts

The manual e2e scripts accumulated copy-paste cruft: a never-called test source, noqa-suppressed dead imports, '# not used' comments on a TURN var that is actually passed to the constructor, and a sys.path hack pointing at the wrong dir.

- sender.py: drop unused create_test_video_source() and wh/fr; trim dead imports
- receiver.py/sender_sw.py: drop gi prelude (init_gst handles require_version) and dead imports
- sender_sw.py: drop broken parents[1] sys.path hack; fix docstring path
- receiver_msid_save.py: decode via avdec_h264 to match its CPU-decode comment; drop unused fmt; merge duplicate reshape branches
- appsink_msid_e2e.py: drop redundant sys.path injection (editable install)
- gpu_sink_save.py: drop unused h,w unpack; fix docstring sender path
- inference_buffer_v2_ipc.py: surface child_error instead of crashing on assert
- gpu_sink/core.py: remove the copy_frame ctor param and its dead 'if not self.copy_frame' branch; frames were always copied regardless of the flag.

- sender/core.py: fix stale ICE comment ('>3s' -> '>1s') to match the 1.0s threshold the code and unit tests actually use.
WebRTCReceiver renames the appsink to the incoming stream's msid, so binding by GpuFrameSink's original name never matched and no frames were pulled (gpu_sink.sh timed out). Discover the appsink by element type instead, the way appsink_msid_e2e.py already does.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 29, 2026

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Free

Run ID: a4428944-00c7-4f3b-93bd-6b6437afc075

📥 Commits

Reviewing files that changed from the base of the PR and between 0b62a66 and 4975ce5.

📒 Files selected for processing (14)
  • src/gst_webrtc/gpu_sink/core.py
  • src/gst_webrtc/sender/core.py
  • tests/e2e/.gitignore
  • tests/e2e/README.md
  • tests/e2e/appsink_msid_e2e.py
  • tests/e2e/gpu_sink.sh
  • tests/e2e/gpu_sink_save.py
  • tests/e2e/inference_buffer_v2_ipc.py
  • tests/e2e/ipc_two_procs/run.sh
  • tests/e2e/receiver.py
  • tests/e2e/receiver_msid_save.py
  • tests/e2e/sender.py
  • tests/e2e/sender_sw.py
  • tests/e2e/smoke.sh
💤 Files with no reviewable changes (1)
  • tests/e2e/appsink_msid_e2e.py

📝 Walkthrough

Walkthrough

This PR removes the optional copy_frame parameter from GPU sink frame handling, making frame copying unconditional; updates ICE disconnect restart timing to 1.0s; and reorganizes the E2E test suite to use tests/e2e/ directory structure, switching H.264 decoding from NVIDIA to CPU and improving error handling and test orchestration.

Changes

Core GStreamer behavior

Layer / File(s) Summary
GPU sink unconditional frame copy
src/gst_webrtc/gpu_sink/core.py
GpuFrameSink constructor removes the copy_frame parameter; frames are now always copied after buffer mapping to ensure consistent thread-safety behavior.
ICE disconnect restart window
src/gst_webrtc/sender/core.py
ICE handler updates the "disconnected" state restart threshold comment to 1.0s and relocates the time import into the restart check block.

E2E test infrastructure and decoder migration

Layer / File(s) Summary
Test directory and documentation updates
tests/e2e/README.md, tests/e2e/.gitignore, tests/e2e/smoke.sh, tests/e2e/gpu_sink.sh
All script paths, output directories, and documentation migrate from e2e/ to tests/e2e/; frames_msid/ directory added to gitignore.
H.264 decoder pipeline CPU migration
tests/e2e/receiver.py, tests/e2e/receiver_msid_save.py
Receiver pipelines switch from NVIDIA nvh264dec to CPU-based avdec_h264; frame reshaping logic simplified with unified width-trim path; fakesink sync=false replaces video rendering.
Test script simplification and sender initialization
tests/e2e/appsink_msid_e2e.py, tests/e2e/sender.py, tests/e2e/sender_sw.py
appsink_msid_e2e.py removes sys.path manipulation; sender.py simplifies GStreamer bootstrap to Gst only and removes unused video source helper; sender_sw.py documentation corrected.
Smoke test receiver and sender orchestration
tests/e2e/smoke.sh
Receiver launched without E2E_HEADLESS=1 flag; sender stage changed from sender.py to sender_sw.py (software x264enc encoder).
GPU sink E2E test appsink discovery and frame handling
tests/e2e/gpu_sink_save.py
Adds GstApp requirement and import; implements dynamic discovery of GstApp.AppSink in receiver pipeline; removes unused frame dimension extraction; documentation path updated.
Error handling and cleanup improvements
tests/e2e/inference_buffer_v2_ipc.py, tests/e2e/ipc_two_procs/run.sh
inference_buffer_v2_ipc.py adds defensive child_error checks at both IPC receive points; run.sh fixes temp directory cleanup by checking for directory instead of file.

🎯 3 (Moderate) | ⏱️ ~20 minutes

🐰 Frames now copy unfailingly true,
ICE restarts at one second through;
Tests hop from e2e/ to tests/ nest,
Decoders run CPU—the fast encode's best! ✨


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

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

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4975ce571d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 41 to 44
output_format: str = "RGBA",
queue_size: int = 4,
drop_when_full: bool = True,
copy_frame: bool = True,
) -> None:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve copy_frame constructor compatibility

The public design/usage docs still advertise GpuFrameSink(..., copy_frame=True) and explicitly say copy_frame=False is accepted for compatibility, but this signature now rejects that keyword with TypeError. Because the option was already a no-op, callers following the documented API (or existing external users) can be kept working by accepting and ignoring the parameter while continuing to always copy frames.

Useful? React with 👍 / 👎.

@DanielMao1 DanielMao1 changed the base branch from main to dev May 29, 2026 10:49
@DanielMao1 DanielMao1 merged commit 6a87192 into dev May 29, 2026
4 checks passed
@DanielMao1 DanielMao1 deleted the refactor/tests-cleanup branch June 1, 2026 03:48
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