Skip to content

CSHARP-5620: Fix CommandMessageBinaryEncoderTests failures on Big Endian systems #1714

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 25, 2025

Conversation

medhatiwari
Copy link
Contributor

@medhatiwari medhatiwari commented Jun 18, 2025

Jira: CSHARP-5620

This PR fixes endianness-related test failures on Big Endian systems.

Context
Several tests were failing because they assumed the system's native endianness when verifying wire-level byte sequences. However, the driver's implementation explicitly follows Little Endian encoding for I/O operations, as per the MongoDB wire protocol.

Tests Affected:

WriteMessage_should_write_messageLength
WriteMessage_should_write_flags
WriteMessage_should_write_responseTo
WriteMessage_should_write_requestId
WriteMessage_should_write_expected_opcode
ReadMessage_should_throw_when_flags_is_invalid

Updated the affected test cases to compare data in a platform-agnostic way, ensuring they match the expected Little Endian wire format, regardless of host architecture.

Since the driver's core implementation already adheres to the wire protocol's endianness requirements, I believe the issue lies in test assumptions, not in the source code. This change ensures the tests reflect the correct behavior on both Little and Big Endian platforms.

cc: @giritrivedi

@medhatiwari medhatiwari requested a review from a team as a code owner June 18, 2025 19:20
@medhatiwari medhatiwari requested review from sanych-sun and removed request for a team June 18, 2025 19:20
@sanych-sun sanych-sun requested review from BorisDog and removed request for sanych-sun June 18, 2025 21:15
@medhatiwari medhatiwari changed the title CSHARP-5620 Fix CommandMessageBinaryEncoderTests failures on Big Endian systems CSHARP-5620: Fix CommandMessageBinaryEncoderTests failures on Big Endian systems Jun 24, 2025
@BorisDog BorisDog added the chore Label to hide PR from generated Release Notes label Jun 24, 2025
@BorisDog BorisDog merged commit c4cc5e3 into mongodb:main Jun 25, 2025
30 of 38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Label to hide PR from generated Release Notes
2 participants