Skip to content

multi devices tests added#14778

Merged
remibettan merged 11 commits intorealsenseai:developmentfrom
remibettan:multi-dev-tests
Mar 9, 2026
Merged

multi devices tests added#14778
remibettan merged 11 commits intorealsenseai:developmentfrom
remibettan:multi-dev-tests

Conversation

@remibettan
Copy link
Contributor

Tracked by: RSDEV-6160

Copilot AI review requested due to automatic review settings March 2, 2026 11:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds new live multi-device unit tests under unit-tests/live/multi_devices to validate basic multi-device enumeration and simultaneous multi-stream (depth/color/IR) streaming behavior across connected D400 devices (RSDEV-6160).

Changes:

  • Added a basic device-enumeration test that iterates through all connected devices and verifies sensor responsiveness.
  • Added a multi-device, multi-stream stress test that finds a common stream configuration across devices, streams simultaneously, and checks for frame drops/independence.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 9 comments.

File Description
unit-tests/live/multi_devices/test-devices-streaming.py New multi-device multi-stream test with common-profile discovery, streaming collection, and drop analysis.
unit-tests/live/multi_devices/test-devices-enumeration.py New multi-device enumeration test that logs device info and checks sensors are present.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Nir-Az
Copy link
Collaborator

Nir-Az commented Mar 3, 2026

Please update once ready for review

@Nir-Az Nir-Az requested a review from AviaAv March 5, 2026 15:46
@Nir-Az
Copy link
Collaborator

Nir-Az commented Mar 5, 2026

@AviaAv please review

Copy link
Contributor

@AviaAv AviaAv left a comment

Choose a reason for hiding this comment

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

Some comments, let's try to simplify/shorten test-devices-streaming.py‎ if possible


if device_count != 2:
log.e(f"FAIL: Test requires exactly 2 D400 devices but found {device_count}")
test.print_results_and_exit()
Copy link
Contributor

Choose a reason for hiding this comment

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

log.f

since those are the first multiple devices tests, I'd even consider adding a function that will do find_first_device_or_exit for those tests - find_n_devices_or_exit(number_of_wanted_devices) or something similar

relevant for both tests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

if len(stream_configs) < 2:
log.w(f"Insufficient common streams found ({len(stream_configs)})")
log.w("At least 2 stream types needed for multi-stream test")
test.check(False, "Devices should support at least 2 common stream types")
Copy link
Contributor

Choose a reason for hiding this comment

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

log.f here too, this will exit the test so we can also remove the else block and unindent

note that it might be needed to be outside of the test closure, on_fail=test.abort is also an option

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

Choose a reason for hiding this comment

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

done?

All streams will use the same resolution and FPS for simplicity.
"""
# Guard against empty device list
if len(devs) == 0:
Copy link
Contributor

Choose a reason for hiding this comment

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

unreachable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


# Try common resolutions in order of preference
# 640x360 added as fallback to support safety camera profiles
target_resolutions = [
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a variable that is being passed as a parameter many times, but only used at _select_best_resolution - I suggest we move it to that function, or have it as a global variable in this test, passing it as a parameter on many functions seems confusing IMO

also, the test is running currently just on D400 - do we need SC resolutions? if yes, is there another resolution that should be present on both SC and D400?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

great comment.
the resolution 480x360 is present on both.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

return common_profiles


def _select_best_resolution(available_configs, target_resolutions):
Copy link
Contributor

Choose a reason for hiding this comment

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

function can be simplified to something like

  next((t for t in target_resolutions if t in available_configs), None)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not used - becasue of your next comment

return all_profiles


def _find_common_profiles(all_profiles, stream_key):
Copy link
Contributor

Choose a reason for hiding this comment

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

def find_common_profile(devs, stream_type, stream_format, target_resolutions):
      """Return (width, height, fps) available on all devices, or None."""
      for w, h, fps in target_resolutions:
          if all(
              any(p.stream_type() == stream_type and p.format() == stream_format
                  and p.as_video_stream_profile().width() == w
                  and p.as_video_stream_profile().height() == h
                  and p.fps() == fps
                  for sensor in dev.query_sensors()
                  for p in sensor.profiles
                  if p.is_video_stream_profile())
              for dev in devs
          ):
              return w, h, fps
      return None

  That replaces _discover_device_profiles, _find_common_profiles, _select_best_resolution, and all three _try_add_*_stream
  functions — ~120 lines down to ~12. And it uses the API the way every other test in the repo does.

can you please try and see if works for us? this test seems very long

Copy link
Contributor Author

Choose a reason for hiding this comment

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

great improvement!

@remibettan remibettan requested a review from AviaAv March 8, 2026 14:24
devices_list = c.query_devices()

device_count = devices_list.size()
if device_count != n:
Copy link
Contributor

Choose a reason for hiding this comment

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

the original find_first_device_or_exit does not fail if there's more than one device - IMO let's make this function also pass if there are more devices and just return the first n requested - this if should be device_count < n - up to you

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

@AviaAv AviaAv left a comment

Choose a reason for hiding this comment

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

Great tests!

@Nir-Az Nir-Az self-requested a review March 9, 2026 10:21
Copy link
Collaborator

@Nir-Az Nir-Az left a comment

Choose a reason for hiding this comment

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

Great addition

@remibettan remibettan merged commit b2fd690 into realsenseai:development Mar 9, 2026
25 of 27 checks passed
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.

4 participants