Skip to content

Skip rosbag tests when the installed librealsense2 cannot play compressed db3 - #3558

Merged
Nir-Az merged 5 commits into
realsenseai:ros2-developmentfrom
Nir-Az:prerelease-db3-skip
Sep 7, 2026
Merged

Nir-Az merged 5 commits into
realsenseai:ros2-developmentfrom
Nir-Az:prerelease-db3-skip

Conversation

@Nir-Az

@Nir-Az Nir-Az commented Sep 3, 2026 •

Copy link
Copy Markdown
Collaborator

Overview: Makes the rosbag tests skip, instead of fail, when the installed librealsense2 is too old to play back the compressed .db3 recordings they now use.

Tracked on [RSDSO-21716]

Why

The pre-release workflow has failed on every commit since #3539, on every branch. It installs ros-humble-librealsense2 2.58.4 from repo.ros2.org/ubuntu/testing, and the migrated tests feed it recordings whose frames live on /compressed and /compressedDepth topics. Support for reading those landed in librealsense PR #15556, which is not in v2.58.4, so the SDK reader logs

ros2_reader.cpp:156 read_next_data: unknown message type on topic: /device_0/sensor_1/Color_0/image/metadata

for every metadata message and delivers no frames. 8 of 11 tests fail or time out. main.yml is unaffected because it builds librealsense from the development branch.

test_rosbag_db3_play_test.py used to guard against exactly this ("rosdistro's librealsense2 may predate the bag-to-db3 converter"), but that probe did not survive the migration.

Summary

  • Added realsense2_camera/test/conftest.py (43 lines, 13 of them the license header), which skips every rosbag-marked test when the installed librealsense2 cannot read compressed .db3.
  • The check probes the installed library for the /compressedDepth topic suffix rather than comparing versions: a source build of development reports 2.58.0, lower than the released 2.58.4 that lacks the support, so a version floor would skip the tests exactly where they pass.
  • Returns True when it cannot tell, so the tests run.
  • No test file changes; all eight affected tests already carry @pytest.mark.rosbag.

The guard becomes inert on its own once a librealsense2 package containing #15556 reaches the ROS servers.

Test plan

  • pre-release (humble/jazzy/kilted) reports the rosbag tests as skipped instead of the current 8 failures.
  • CI and CI - Rolling stay green — they build librealsense from development, so the probe must let the tests run there.

Both are readable from this PR's own checks; the second is the one that proves the probe does not over-skip.


🤖 Generated by AI

@sysrsbuild-gh-agentic sysrsbuild-gh-agentic left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Auto-review by rs-agentic bot. Good approach overall — probing the binary instead of comparing versions is the right call. A few items worth addressing.

Comment thread realsense2_camera/test/conftest.py Resolved
Comment thread realsense2_camera/test/conftest.py Resolved
Comment thread realsense2_camera/test/conftest.py Resolved
@Nir-Az
Nir-Az requested a review from AviaAv September 3, 2026 10:34
@Nir-Az

Nir-Az commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator Author

@AviaAv handing this over to you since it follows your db3 migration. The pre-release job has been red on every branch since #3539: it installs ros-humble-librealsense2 2.58.4 from the ROS servers, and I confirmed the hosted outdoors_1color.db3 carries its frames only on /image/data/compressed and /image/data/compressedDepth (no plain /image/data topic at all), which 2.58.4's stream-topic regex /(data|metadata)$ filters out — so no frame is built and every metadata message ends up logging unknown message type. Reading those topics came in librealsense #15556, which landed three days after v2.58.4 was tagged, so nothing is wrong with the bags or the tests, they just need an SDK newer than anything released.

This PR guards it with a conftest that skips the rosbag-marked tests when the installed library lacks the support, probing for the topic suffix rather than a version floor because a source build of development reports 2.58.0 and would otherwise skip in the main CI where it works. Placement is your call though — it could equally be a pytest.skip inside the shared launch_descr_* fixtures or a marker on each test class, and you know that test layout better than I do. Also worth deciding whether it's worth guarding at all versus just waiting for the next librealsense2 release to reach the ROS servers, given pre-release is informational and self-heals.

@Nir-Az

Nir-Az commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator Author

The first attempt did not fire — pre-release stayed red and my skip reason never appeared in the log, so I pulled the actual deb apart to see why. Two findings: the /compressedDepth string check is a valid discriminator (absent from the released librealsense2.so.2.58.4, present in a development build), but the ROS package installs to /opt/ros/humble/lib/x86_64-linux-gnu/, which is reached via LD_LIBRARY_PATH and is not in the ldconfig cache — so my lookup found nothing and failed open, and the tests ran exactly as before.

b142f56 resolves the library through the dynamic loader instead (/proc/self/maps after a CDLL, falling back to LD_LIBRARY_PATH), which I verified against the real released .so (returns False, tests skip), a library carrying the string (returns True, tests run) and no library at all (True, fail open). Waiting on this run to confirm it in the container.

Comment thread realsense2_camera/test/conftest.py Resolved
@Nir-Az
Nir-Az requested review from AviaAv and removed request for AviaAv September 3, 2026 12:43
@Nir-Az

Nir-Az commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator Author

@AviaAv re-pinging for a review — this is ready now. All checks are green on 4bdd88b, including the three pre-release jobs that have been red on every branch since #3539, and the bot threads are answered. The pre-release runs also dropped from 26-28 min to 11-17 min, and the log shows the rosbag files skipping in under a second each with everything else still running, so the guard is doing what it says rather than passing by luck.

Still your call whether to take it at all: pre-release is not a required check and ros2-development has no branch protection, so the alternative is simply living with the red until a librealsense2 carrying #15556 reaches the ROS servers. If you do want it, the placement is also yours — conftest hook as written, a skip inside the shared launch_descr_* fixtures, or a marker per test class.

@AviaAv AviaAv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approach and probe verified — v2.58.4 has zero compressedDepth occurrences in src/media/ros2/, development has them in 4 files, so the discriminator is sound. Source-build CI ran all rosbag tests (36 tests, 4 pre-existing skips); pre-release now skips them. Both test-plan items hold.

Three comments inline: one real over-skip, one uncaught OSError, one observability gap.

🤖 Generated by AI

Comment thread realsense2_camera/test/conftest.py Outdated
skip = pytest.mark.skip(reason="installed librealsense2 cannot play compressed .db3 "
"recordings (needs librealsense PR #15556)")
for item in items:
if 'rosbag' in item.keywords:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Over-skips two tests that don't depend on the SDK version:

The marker is right for both (they do use a recording), so exempt rather than strip:

        if 'rosbag' in item.keywords and 'no_librealsense' not in item.keywords:

plus @pytest.mark.no_librealsense on those two.

🤖 Generated by AI

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good catch - fixed in 56eb005. Both now carry @pytest.mark.no_librealsense and the hook exempts it, so they run in pre-release again while keeping the rosbag marker.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

change approved

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

change approved — no_librealsense exemption added in conftest.py and @pytest.mark.no_librealsense applied to both tests in the new commit.

Comment thread realsense2_camera/test/conftest.py Outdated
except Exception:
pass
libs = [lib for d in os.environ.get('LD_LIBRARY_PATH', '').split(':') if d
for lib in glob.glob(os.path.join(d, 'librealsense2.so*')) if os.path.getsize(lib)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

os.path.getsize(lib) sits outside the try, so it breaks fail-open instead of extending it: a dangling librealsense2.so* symlink in any LD_LIBRARY_PATH directory raises OSError into pytest collection — a collection error, not a skip and not a run.

The size filter also changes nothing; a zero-byte .so fails the substring check anyway. Drop it:

    libs = [lib for d in os.environ.get('LD_LIBRARY_PATH', '').split(':') if d
            for lib in glob.glob(os.path.join(d, 'librealsense2.so*'))]

🤖 Generated by AI

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 56eb005 - size filter dropped. You are right that it broke the fail-open property it looked like it was helping.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

change approved

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

change approved — os.path.getsize removed; glob fallback is clean with no size check.

Comment thread realsense2_camera/test/conftest.py Outdated


def pytest_collection_modifyitems(config, items):
if sdk_plays_compressed_db3():

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When this skips, nothing in the log says so. 19 tests disappear from the run with no reason and no path printed — so if the probe ever resolves the wrong .so, it looks identical to an old SDK.

One print fixes it:

def pytest_collection_modifyitems(config, items):
    path = librealsense_path()
    if sdk_plays_compressed_db3(path):
        return
    print(f"rosbag tests skipped: {path} lacks compressed .db3 support")

with sdk_plays_compressed_db3 taking the path instead of calling librealsense_path() itself.

🤖 Generated by AI

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 56eb005 - sdk_plays_compressed_db3 takes the path now and the hook prints it on skip. This one bit me already: when the first attempt silently failed open, the log looked identical to an old SDK and I had to unpack the deb to tell the difference.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

change approved

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

change approved — print("rosbag tests skipped: %s lacks compressed .db3 support" % path) is present in the new conftest.py.

@Nir-Az
Nir-Az force-pushed the prerelease-db3-skip branch from 4bdd88b to 56eb005 Compare September 6, 2026 12:42
@Nir-Az
Nir-Az requested a review from AviaAv September 6, 2026 12:43
@Nir-Az

Nir-Az commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator Author

@AviaAv all three addressed in 56eb005, and the branch is rebased onto current ros2-development. The two SDK-independent tests now carry no_librealsense and are exempt from the skip, the size filter is gone, and the hook prints the resolved path when it skips — that last one had already cost me a debugging round, since a silent fail-open looked exactly like an old SDK in the log.

Checks are re-running; worth a look at whether test_rosbag_db3_play_test and test_non_existing_rosbag come back as passing in pre-release rather than skipped, which is the direct check on your first comment.

@AviaAv AviaAv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@Nir-Az
Nir-Az merged commit d2b8c22 into realsenseai:ros2-development Sep 7, 2026
10 checks passed
@Nir-Az
Nir-Az deleted the prerelease-db3-skip branch September 7, 2026 08:14
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.

3 participants