Skip to content

[Test🧪] Add test case for GetLiteGroupInfoRequestHeader#6615

Merged
mxsm merged 2 commits intomxsm:mainfrom
slegarraga:test-6569
Mar 3, 2026
Merged

[Test🧪] Add test case for GetLiteGroupInfoRequestHeader#6615
mxsm merged 2 commits intomxsm:mainfrom
slegarraga:test-6569

Conversation

@slegarraga
Copy link
Contributor

@slegarraga slegarraga commented Mar 1, 2026

Motivation

Closes #6569

Modification

Added unit tests for GetLiteGroupInfoRequestHeader covering:

  • Header creation with field values
  • Serialization to map (to_map)
  • Deserialization from map (from_map)
  • Clone behavior
  • Debug formatting
  • Edge cases for top_k (zero, negative, i32::MAX)

Result

All 6 tests pass. Improves test coverage for the remoting protocol headers.

Summary by CodeRabbit

  • Tests
    • Added unit tests for the Lite Group Info request header: validates creation, serialization/deserialization round-trips, cloning, debug formatting, and behavior with edge top_k values (0, negative, max). No public APIs were changed.

Add unit tests covering:
- Header creation with field values
- Serialization to map (to_map)
- Deserialization from map (from_map)
- Clone behavior
- Debug formatting
- Edge cases for top_k (zero, negative, max)

Closes mxsm#6569
@rocketmq-rust-bot
Copy link
Collaborator

🔊@slegarraga 🚀Thanks for your contribution🎉!

💡CodeRabbit(AI) will review your code first🔥!

Note

🚨The code review suggestions from CodeRabbit are to be used as a reference only, and the PR submitter can decide whether to make changes based on their own judgment. Ultimately, the project management personnel will conduct the final code review💥.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 1, 2026

Walkthrough

Added a unit test module for GetLiteGroupInfoRequestHeader verifying instantiation, map serialization/deserialization, cloning, Debug formatting, and boundary cases for the top_k field (0, negative, i32::MAX).

Changes

Cohort / File(s) Summary
GetLiteGroupInfoRequestHeader Tests
rocketmq-remoting/src/protocol/header/get_lite_group_info_request_header.rs
Added a comprehensive unit test suite covering struct creation, serialization to/from maps, cloning, Debug representation, and boundary condition tests for top_k (including 0, negative, and i32::MAX).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • TeslaRustor
  • rocketmq-rust-bot

Poem

🐰 Hops of joy, tests now gleam,
I check each map and every stream.
Zero, negative, MAX in sight,
Assertions snug and tests run right.
A happy rabbit hops—goodnight! 🧪✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding test cases for GetLiteGroupInfoRequestHeader, matching the actual changeset.
Linked Issues check ✅ Passed The PR fully addresses issue #6569 by implementing all requested test cases covering construction, serialization, deserialization, cloning, debug formatting, and edge cases.
Out of Scope Changes check ✅ Passed All changes are directly related to adding test coverage for GetLiteGroupInfoRequestHeader as specified in the linked issue; no unrelated modifications are present.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
rocketmq-remoting/src/protocol/header/get_lite_group_info_request_header.rs (1)

107-120: Consider testing clone with a populated rpc field.

The clone test only verifies behavior when rpc: None. For completeness, consider adding a case where rpc is Some(...) to ensure all nested fields are cloned correctly.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@rocketmq-remoting/src/protocol/header/get_lite_group_info_request_header.rs`
around lines 107 - 120, Add a second case to the
get_lite_group_info_request_header_clone test that sets
GetLiteGroupInfoRequestHeader.rpc to Some(...) (e.g., a populated CheetahRpc or
equivalent struct used in this codebase), clone the header, and assert equality
on rpc as well as group, lite_topic, and top_k to verify the nested rpc field is
correctly cloned; update the test function
get_lite_group_info_request_header_clone to create both None and Some(...)
scenarios (or add a new test) and compare header.rpc == cloned.rpc.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@rocketmq-remoting/src/protocol/header/get_lite_group_info_request_header.rs`:
- Around line 37-163: The CI failure is due to rustfmt formatting issues in the
tests module for GetLiteGroupInfoRequestHeader; run rustfmt (cargo fmt --all)
locally, reformat the file containing the tests (the tests module, the impls for
GetLiteGroupInfoRequestHeader and any related trait impls like
FromMap/CommandCustomHeader), verify formatting passes with cargo fmt --all --
--check, then stage and commit the reformatted file so the CI formatting check
succeeds.

---

Nitpick comments:
In `@rocketmq-remoting/src/protocol/header/get_lite_group_info_request_header.rs`:
- Around line 107-120: Add a second case to the
get_lite_group_info_request_header_clone test that sets
GetLiteGroupInfoRequestHeader.rpc to Some(...) (e.g., a populated CheetahRpc or
equivalent struct used in this codebase), clone the header, and assert equality
on rpc as well as group, lite_topic, and top_k to verify the nested rpc field is
correctly cloned; update the test function
get_lite_group_info_request_header_clone to create both None and Some(...)
scenarios (or add a new test) and compare header.rpc == cloned.rpc.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3c59f59 and f6aa9a8.

📒 Files selected for processing (1)
  • rocketmq-remoting/src/protocol/header/get_lite_group_info_request_header.rs

Copy link
Owner

@mxsm mxsm left a comment

Choose a reason for hiding this comment

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

@slegarraga please Fix ci error

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
rocketmq-remoting/src/protocol/header/get_lite_group_info_request_header.rs (2)

129-153: Edge-case test should round-trip through codec, not only struct assignment.

Line 129-Line 153 currently proves i32 values can be stored, but it does not validate boundary behavior for to_map/FromMap::from. Consider a table-driven round-trip assertion for 0, -1, and i32::MAX.

Suggested round-trip edge-case test
     #[test]
     fn get_lite_group_info_request_header_with_different_top_k_values() {
-        let header_zero = GetLiteGroupInfoRequestHeader {
-            group: CheetahString::from("g"),
-            lite_topic: CheetahString::from("t"),
-            top_k: 0,
-            rpc: None,
-        };
-        assert_eq!(header_zero.top_k, 0);
-
-        let header_negative = GetLiteGroupInfoRequestHeader {
-            group: CheetahString::from("g"),
-            lite_topic: CheetahString::from("t"),
-            top_k: -1,
-            rpc: None,
-        };
-        assert_eq!(header_negative.top_k, -1);
-
-        let header_large = GetLiteGroupInfoRequestHeader {
-            group: CheetahString::from("g"),
-            lite_topic: CheetahString::from("t"),
-            top_k: i32::MAX,
-            rpc: None,
-        };
-        assert_eq!(header_large.top_k, i32::MAX);
+        for top_k in [0, -1, i32::MAX] {
+            let header = GetLiteGroupInfoRequestHeader {
+                group: CheetahString::from("g"),
+                lite_topic: CheetahString::from("t"),
+                top_k,
+                rpc: None,
+            };
+
+            let map = header.to_map().unwrap();
+            let decoded = <GetLiteGroupInfoRequestHeader as FromMap>::from(&map).unwrap();
+            assert_eq!(decoded.top_k, top_k);
+        }
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@rocketmq-remoting/src/protocol/header/get_lite_group_info_request_header.rs`
around lines 129 - 153, The test
get_lite_group_info_request_header_with_different_top_k_values currently only
assigns values to GetLiteGroupInfoRequestHeader fields but must round-trip
through the header codec to validate map conversion; modify the test to iterate
over values [0, -1, i32::MAX], create a GetLiteGroupInfoRequestHeader with each
top_k, call its to_map (or equivalent serialization) and then parse back with
FromMap::from (or equivalent deserialization), and assert the
deserialized.header.top_k equals the original value (use the
GetLiteGroupInfoRequestHeader name and the to_map / FromMap::from code paths to
locate the logic to exercise).

113-126: Tighten debug assertions to avoid false positives.

Line 123-Line 125 currently check broad substrings ("group", "lite", "7"), which can still pass if debug formatting regresses. Prefer checking field labels.

Suggested assertion tightening
-        assert!(debug_str.contains("group"));
-        assert!(debug_str.contains("lite"));
-        assert!(debug_str.contains("7"));
+        assert!(debug_str.contains("group:"));
+        assert!(debug_str.contains("lite_topic:"));
+        assert!(debug_str.contains("top_k: 7"));
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@rocketmq-remoting/src/protocol/header/get_lite_group_info_request_header.rs`
around lines 113 - 126, The test get_lite_group_info_request_header_debug is
using loose substring checks that can produce false positives; update the
assertions in that test to verify the debug output contains the field labels
together with their values for the GetLiteGroupInfoRequestHeader fields (e.g.,
the "group" field label and its value, the "lite_topic" field label and its
value, and the "top_k" label and value) instead of broad substrings like
"group", "lite", and "7" so the test will fail if Debug formatting regresses.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@rocketmq-remoting/src/protocol/header/get_lite_group_info_request_header.rs`:
- Around line 129-153: The test
get_lite_group_info_request_header_with_different_top_k_values currently only
assigns values to GetLiteGroupInfoRequestHeader fields but must round-trip
through the header codec to validate map conversion; modify the test to iterate
over values [0, -1, i32::MAX], create a GetLiteGroupInfoRequestHeader with each
top_k, call its to_map (or equivalent serialization) and then parse back with
FromMap::from (or equivalent deserialization), and assert the
deserialized.header.top_k equals the original value (use the
GetLiteGroupInfoRequestHeader name and the to_map / FromMap::from code paths to
locate the logic to exercise).
- Around line 113-126: The test get_lite_group_info_request_header_debug is
using loose substring checks that can produce false positives; update the
assertions in that test to verify the debug output contains the field labels
together with their values for the GetLiteGroupInfoRequestHeader fields (e.g.,
the "group" field label and its value, the "lite_topic" field label and its
value, and the "top_k" label and value) instead of broad substrings like
"group", "lite", and "7" so the test will fail if Debug formatting regresses.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f6aa9a8 and 8edbe76.

📒 Files selected for processing (1)
  • rocketmq-remoting/src/protocol/header/get_lite_group_info_request_header.rs

@codecov
Copy link

codecov bot commented Mar 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 41.48%. Comparing base (c803c98) to head (8edbe76).
⚠️ Report is 31 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6615      +/-   ##
==========================================
- Coverage   41.52%   41.48%   -0.05%     
==========================================
  Files         961      974      +13     
  Lines      134645   136197    +1552     
==========================================
+ Hits        55909    56496     +587     
- Misses      78736    79701     +965     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Collaborator

@rocketmq-rust-bot rocketmq-rust-bot left a comment

Choose a reason for hiding this comment

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

LGTM - All CI checks passed ✅

Copy link
Owner

@mxsm mxsm left a comment

Choose a reason for hiding this comment

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

LGTM

@mxsm mxsm merged commit bc6cb91 into mxsm:main Mar 3, 2026
9 of 14 checks passed
@rocketmq-rust-bot rocketmq-rust-bot added approved PR has approved and removed ready to review waiting-review waiting review this PR labels Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Test🧪] Add test case for GetLiteGroupInfoRequestHeader

4 participants