Repository navigation
Fix flaky pytest-advanced-mode-toggle on MIPI devices - #15039
Conversation
…d_mode; clearer test failure logging
There was a problem hiding this comment.
Pull request overview
This PR addresses flakiness in the live unit test that verifies RS400 advanced-mode toggling, primarily affecting MIPI/GMSL D400 devices. It does so by eliminating a redundant simulated reconnect in the MIPI device implementation (which caused duplicate device-changed callbacks) and by making the pytest bind explicitly to the parametrized device serial.
Changes:
- Remove
d400_mipi_device::toggle_advanced_mode()override to avoid a secondsimulate_device_reconnect()(base advanced-mode toggle already triggershardware_reset(), which simulates reconnect for MIPI). - Update
pytest-advanced-mode-toggleto select the device by_test_device_serialfromtest_context, avoiding accidental operation on a different device when multiple are present. - Replace
assertstatements with explicitlog.error(...)+pytest.fail(...)to ensure failures are visible in per-test logs before cleanup runs.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| unit-tests/live/hw-reset/pytest-advanced-mode-toggle.py | Binds test execution to the parametrized serial and improves failure logging to reduce flakiness and improve diagnosability. |
| src/ds/d400/d400-mipi-device.h | Removes the MIPI-specific toggle_advanced_mode override declaration so base advanced-mode logic is used. |
| src/ds/d400/d400-mipi-device.cpp | Removes the redundant reconnect simulation in toggle_advanced_mode, preventing double device-changed callback cycles per toggle. |
|
|
||
|
|
||
| def test_advanced_mode_toggle( test_device ): | ||
| def test_advanced_mode_toggle( _test_device_serial, test_context ): |
There was a problem hiding this comment.
If --device solve it locally we don't these changes as they are relevant for all tests
| f"[{i}/{TOGGLE_ITERATIONS}] Device did not reconnect within {TOGGLE_WAIT_TIME} sec after toggling advanced mode" | ||
| if not _wait_for_reconnect( TOGGLE_WAIT_TIME ): | ||
| msg = f"[{i}/{TOGGLE_ITERATIONS}] Device did not reconnect within {TOGGLE_WAIT_TIME} sec after toggling advanced mode" | ||
| log.error( msg ) |
There was a problem hiding this comment.
These should be investigated and fixed at infra level, we don't want to do it on each assert call, we can revert and open a ticket to solve in infra
Summary
simulate_device_reconnectcall ind400_mipi_device::toggle_advanced_mode. The baseds_advanced_mode_base::toggle_advanced_modealready triggers it via_hardware_reset_action()-> virtualhardware_reset()(since ea4ec76), so the explicit second call fired tworemoved/addedcallbacks per toggle and raced the Python test's_wait_for_reconnect.log.errorbefore raising, so the per-test log shows the failure reason instead of jumping straight into thefinallycleanup._test_device_serialinstead of takingdevices_list[0], so it never accidentally operates on a different device when more than one is visible in the context.Test plan
Expected ON after restore but got OFFfrom the double-callback raceLibCI nightly run: https://rsjenkins.realsenseai.com/view/LRS/job/LRS_libci_pipeline/15697 - all green