Skip to content

ci(perception): run unit tests in CI, check launch default devices - #126

Merged
TCrawley11 merged 2 commits into
perception/perception_devfrom
perception/ci-unit-tests
Nov 29, 2026
Merged

TCrawley11 merged 2 commits into
perception/perception_devfrom
perception/ci-unit-tests

Conversation

@TCrawley11

@TCrawley11 TCrawley11 commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

CI only ran test/deploy, and the unit tests in src/perception/test/ aren't installed in the image, so they never ran in CI. This PR runs them, and adds a deploy test for something no test covered: whether the image can run the device the launch files default to.

Changes

  • Unit tests in CI (.github/workflows/perception-images.yml): a new Unit tests step, before the deploy tests, mounts src/perception/test read-only into each deploy image (cpu and gpu) and runs pytest -p no:cacheprovider /opt/ap1/unit-tests --ignore=/opt/ap1/unit-tests/deploy. The tests stay out of the image the car runs.

  • test/deploy/test_launch_defaults.py: loads every installed launch/*.launch.py that declares a device argument, reads its default (from AP1_GPU), and checks the image can run it:

    • cpu / cuda / tensorrt: onnxruntime lists the provider
    • tensorrt: TensorRT's library (nvinfer) is also installed, because onnxruntime-gpu lists the TensorRT provider even without it
    • auto: always fine (falls back to CPU); any other value fails

    The other deploy tests pick the device with pick_device(), so a launch default the image can't run went unnoticed until the node failed at startup (this is what Perception/91 road seg v0 #123's tensorrt default does on the GPU image).

  • docker/README.md: Tests section describes the new test and how to run the unit tests against a deploy image.

Testing

  • Unit tests (test/ minus deploy), as the new CI step runs them: 15 passed
  • test_launch_defaults.py, current launch files: 10 passed with AP1_GPU=0, and 10 passed with AP1_GPU=1 plus onnxruntime-gpu's provider list
  • With Perception/91 road seg v0 #123's launch files and AP1_GPU=1: fails as intended:
    road_seg.launch.py: device='tensorrt': library 'nvinfer' not found (same for yolo.launch.py)
  • Mutation pass over the new test's rules: 9 of 10 mutants caught. The survivor replaces the image's real provider list with a hardcoded one; the real list is confirmed in use by the AP1_GPU=1 run on CPU onnxruntime, which reports available: ['CPUExecutionProvider'].

Notes

  • After this merges, Perception/91 road seg v0 #123 needs a rebase; its GPU job should then fail this test until its launch defaults go back to cuda. Its own unit tests (test_runtime.py, test_road_seg.py) will run in CI too.
  • find_library searches the linker cache and LD_LIBRARY_PATH. If Switch model runtime from ONNX to TensorRT #98 installs TensorRT from pip (libraries inside site-packages), that path has to be on LD_LIBRARY_PATH for onnxruntime anyway, and this test checks the same thing.

Note

Low Risk
Changes add CI coverage and a read-only test mount; no production runtime or auth paths are modified.

Overview
CI for perception Docker images now runs unit tests in addition to deploy tests: after each image build, src/perception/test is mounted read-only into the container and pytest runs with deploy excluded, using -p no:cacheprovider and disabled launch_testing plugins so --ignore works on the current image.

A new deploy test test_launch_defaults.py walks installed launch files, reads each device default (e.g. from AP1_GPU), and fails if the image lacks the needed onnxruntime providers or libraries (such as nvinfer for tensorrt). Existing deploy tests pick the device themselves, so mismatched launch defaults were previously undetected.

docker/README.md documents the launch-default test and reproduces the CI unit-test docker compose invocation, including the launch_testing workaround.

Reviewed by Cursor Bugbot for commit 156556c. Bugbot is set up for automated code reviews on this repo. Configure here.

CI only ran test/deploy, and the unit tests in test/ aren't installed in the
image, so they never ran in CI. A new "Unit tests" step mounts
src/perception/test read-only into each deploy image (cpu and gpu) and runs
it without test/deploy, before the deploy tests.

test/deploy/test_launch_defaults.py loads every installed launch file that
declares a `device` argument and checks the image can run its default:
onnxruntime has the provider, and for tensorrt the TensorRT library
(nvinfer) is installed, since onnxruntime-gpu lists the TensorRT provider
without it. The other deploy tests choose the device with pick_device(), so
a default the image can't run went unnoticed until the node failed at startup.

docker/README.md: describe the new test and how to run the unit tests
against a deploy image.
@TCrawley11
TCrawley11 requested review from a team as code owners November 29, 2026 06:18
@TCrawley11 TCrawley11 self-assigned this Nov 29, 2026
@TCrawley11 TCrawley11 added the Perception Related to perception team label Nov 29, 2026
@TCrawley11 TCrawley11 added this to the Testing and benchmarks milestone Nov 29, 2026
… step

launch_testing 3.4.13's pytest plugin returns False from a tryfirst
pytest_ignore_collect hook, so pytest's own --ignore handling never runs
(ros2/launch#1047, fixed on jazzy after 3.4.13 but not released yet). The
unit test step therefore also collected test/deploy, whose tests need the
model mount and failed.

Turn off the launch_testing and launch_ros pytest plugins for the unit
tests, which don't use them. Drop the flags once the image has a newer
launch_testing.
@TCrawley11
TCrawley11 merged commit 7b6954a into perception/perception_dev Nov 29, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Perception Related to perception team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant