Repository navigation
Migrate live/options tests to pytest - #14987
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Use @pytest.mark.dependency(scope='module') for the two prerequisite tests (advanced_mode_support, visual_preset_support) so that all subsequent tests are automatically skipped when a prerequisite fails, matching the legacy on_fail=test.ABORT behavior. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Split into 3 test functions: test_laser_power_frame_drops, test_depth_options_frame_drops, test_color_options_frame_drops. FrameDropChecker class replaces inline callback logic. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Single test function verifying get_option and frame metadata agree for all color options at min/max/default values. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Single weekly stress test verifying no exception is thrown when setting PU (gain) option repeatedly [RSDSO-17185]. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Single weekly stress test for UVC power locking: multiple threads setting visual presets concurrently while GVD commands are issued in parallel. No exceptions should be thrown. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Migrates the unit-tests/live/options/ live device option tests from the legacy rspy.test framework to pytest, introducing pytest-dependency to preserve legacy on_fail=test.ABORT semantics and updating infra/docs to support the new patterns.
Changes:
- Converted 9 legacy
test-*.pyscripts into 9pytest-*.pymodules withdef test_*()granularity and (where needed) dependency-based skipping. - Added
pytest-dependencyto unit test requirements and to the required-plugin availability check. - Added a
device_in_service_modefixture to replace legacy wrapper behavior for D585S service mode and documented the ABORT migration pattern.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| unit-tests/requirements.txt | Adds pytest-dependency dependency for ABORT-style prerequisite skipping. |
| unit-tests/py/rspy/pytest/plugins.py | Registers pytest_dependency as a required plugin for fail-fast missing installs. |
| unit-tests/conftest.py | Adds device_in_service_mode fixture (D585S service mode handling). |
| .github/skills/pytest-infra.md | Documents on_fail=test.ABORT → pytest-dependency migration pattern. |
| unit-tests/live/options/test-uvc-power-stress-test.py | Removes legacy rspy.test version of the weekly UVC power stress test. |
| unit-tests/live/options/test-timestamp-domain.py | Removes legacy timestamp domain test. |
| unit-tests/live/options/test-set-gain-stress-test.py | Removes legacy gain stress test. |
| unit-tests/live/options/test-rgb-options-metadata-consistency.py | Removes legacy RGB options/metadata consistency test. |
| unit-tests/live/options/test-presets.py | Removes legacy presets test. |
| unit-tests/live/options/test-out-of-range-throw.py | Removes legacy out-of-range exception test. |
| unit-tests/live/options/test-options-watcher.py | Removes legacy options watcher test. |
| unit-tests/live/options/test-drops-on-set.py | Removes legacy frame-drop-on-set test. |
| unit-tests/live/options/test-advanced-mode.py | Removes legacy advanced mode test. |
| unit-tests/live/options/pytest-uvc-power-stress-test.py | Adds pytest version of weekly UVC locking stress test (threads + GVD). |
| unit-tests/live/options/pytest-timestamp-domain.py | Adds pytest version of nightly timestamp domain test split into 4 cases. |
| unit-tests/live/options/pytest-set-gain-stress-test.py | Adds pytest version of weekly gain stress test using device_in_service_mode. |
| unit-tests/live/options/pytest-rgb-options-metadata-consistency.py | Adds pytest version of nightly RGB option vs metadata consistency test. |
| unit-tests/live/options/pytest-presets.py | Adds pytest version of nightly presets test with dependency-based prerequisites. |
| unit-tests/live/options/pytest-out-of-range-throw.py | Adds pytest version of out-of-range exception test using pytest.raises. |
| unit-tests/live/options/pytest-options-watcher.py | Adds pytest version of nightly options watcher test split into multiple tests. |
| unit-tests/live/options/pytest-drops-on-set.py | Adds pytest version of nightly “drops on set” tests with callback-based checker. |
| unit-tests/live/options/pytest-advanced-mode.py | Adds pytest version of nightly advanced mode test split into dependency-gated cases. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
11cc009 to
38a9841
Compare
|
CI running all migrated tests (including weekly context) LRS_libci_pipeline/15318/ |
| def make_callback(get_sensor): | ||
| """Return a (callback, count) pair. get_sensor() returns the current sensor, | ||
| used to skip read-only options (e.g. temperature) that may change spuriously.""" | ||
| count = [0] |
There was a problem hiding this comment.
a bit hard to follow the count[0] , count[1] around.
Can you make it clearer?
Any reason for the small refactor?
Note that migration should be done as is with small diff unless a BUG is found.
Make the review simpler and if the test starts failing we know to distinguish between migration issue or refactor issue
So far I see a refactor 2/2 files I reviewed, will keep reviewing
There was a problem hiding this comment.
From my conversion conversation with Clode:
"each test will do its own sensor setup so the callback counter starts clean, avoiding the shared-state problem"
There was a problem hiding this comment.
I will check if a simple counter can be used instead of a list
There was a problem hiding this comment.
As discussed, using a global counter like before. I have created a helper function that setup the sensor and callback and it also zero the counter for each test.
|
|
||
| def check_option_and_metadata_values(color_sensor, option, metadata, value_to_set, frame): | ||
| changed = color_sensor.get_option(option) | ||
| assert changed == value_to_set, f"Option {option}: expected {value_to_set}, got {changed}" |
There was a problem hiding this comment.
Since this function is called in some kind of loop better to replace assert with check.equal
It will keep going after the first failure and fail at the end with all the failures and we get a full picture
Tracked on [RSDSO-21353]
Summary
unit-tests/live/options/from the legacyrspy.testframework to pytest (pytest-*.py)pytest-dependencyplugin to handleon_fail=test.ABORTsemantics: prerequisite tests are marked with@pytest.mark.dependency(scope='module')and dependent tests declaredepends=[...], so they are automatically skipped when a prerequisite failsdef test_*()functions (one per closure) so failures are isolated rather than aborting the whole filepytest-dependency==0.6.1torequirements.txtand registers it inrspy/pytest/plugins.pyfor fast-fail on missing install.github/skills/pytest-infra.mdwith theon_fail=test.ABORTmigration patternFiles migrated
test-out-of-range-throw.pypytest-out-of-range-throw.pytest-timestamp-domain.pypytest-timestamp-domain.pytest-options-watcher.pypytest-options-watcher.pytest-advanced-mode.pypytest-advanced-mode.pytest-presets.pypytest-presets.pytest-drops-on-set.pypytest-drops-on-set.pytest-rgb-options-metadata-consistency.pypytest-rgb-options-metadata-consistency.pytest-set-gain-stress-test.pypytest-set-gain-stress-test.pytest-uvc-power-stress-test.pypytest-uvc-power-stress-test.pyTest plan
pytest-set-gain-stress-testverified locally (weekly)pytest-uvc-power-stress-testverified locally (weekly, 33s)unit-tests/infra-tests/) -- 85/85 passed