Skip to content

[QA] Strengthen CommunicationManager tests with real protobuf contracts - #77

Merged
Haralishev77 merged 4 commits into
mainfrom
feature/continue-test-communication-manager
Mar 29, 2026
Merged

[QA] Strengthen CommunicationManager tests with real protobuf contracts#77
Haralishev77 merged 4 commits into
mainfrom
feature/continue-test-communication-manager

Conversation

@mayaparov

Copy link
Copy Markdown
Contributor

Summary

Strengthen CommunicationManager unit tests by validating real protobuf contracts (serialized bytes → proto_capi.Message parsing, oneof arm selection, order handling) while keeping ZeroMQ fully mocked (no network I/O).

The test suite also auto-prepares protobuf Python modules when missing/stale via the existing toolchain, and cleans up any newly generated artifacts to avoid polluting the working tree.

Motivation

CommunicationManager is an infrastructure component where regressions are easy to introduce and hard to detect (socket identity/timeouts, reply validation, message ordering). Earlier tests were not sufficiently tied to the real protobuf schema, so certain proto changes (field removal/oneof reshaping) could slip through unnoticed.

This PR makes the tests schema-sensitive by parsing and asserting against real generated protobuf message classes, while preserving deterministic and CI-friendly execution in minimal environments.

Changes

  • Updated tests in opencda/core/common/communication/test/test_communication_manager.py to:
    • mock zmq via sys.modules (no real sockets / no network);
    • use real protobuf modules and parse sent/received bytes into proto_capi.Message;
    • assert oneof arm selection (opencda / artery), order, and message_order invariants;
    • cover negative cases (send timeout, receive timeout, unexpected message content, wrong order).
  • Added a session-scoped protobuf readiness fixture that:
    • validates the minimal expected schema for proto_capi.Message;
    • generates missing/stale pb2 modules using CommunicationToolchain (only when required);
    • temporarily adjusts sys.path to support top-level imports inside generated code;
    • cleans up only newly created generated artifacts after the session.

How to run

uv run pytest -q opencda/core/common/communication/test/test_communication_manager.py
uv run pytest -q

@Haralishev77
Haralishev77 self-requested a review March 29, 2026 12:42
@Haralishev77 Haralishev77 added QA Some changes in QA 982 labels Mar 29, 2026
@Haralishev77
Haralishev77 merged commit 6b257f7 into main Mar 29, 2026
9 checks passed
@Haralishev77
Haralishev77 deleted the feature/continue-test-communication-manager branch March 29, 2026 12:48
Haralishev77 added a commit that referenced this pull request Jul 21, 2026
…ts (#77)

* [QA] Strengthen CommunicationManager tests with real protobuf contracts

* [QA] Strengthen CommunicationManager tests with real protobuf contracts

* [style] Add comments with the empty exceptions

---------

Co-authored-by: Khoroshilov Grigoriy <khorogri@gmail.com>
Co-authored-by: Grigoriy Khoroshilov <101859570+Haralishev77@users.noreply.github.com>
meaning-0f-life pushed a commit to meaning-0f-life/OpenCDA that referenced this pull request Jul 25, 2026
…ts (CAVISE#77)

* [QA] Strengthen CommunicationManager tests with real protobuf contracts

* [QA] Strengthen CommunicationManager tests with real protobuf contracts

* [style] Add comments with the empty exceptions

---------

Co-authored-by: Khoroshilov Grigoriy <khorogri@gmail.com>
Co-authored-by: Grigoriy Khoroshilov <101859570+Haralishev77@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

982 QA Some changes in QA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants