Skip to content

Conversation

@oopscompiled
Copy link
Contributor

@oopscompiled oopscompiled commented Feb 12, 2026

Which Issue(s) This PR Fixes(Closes)

Brief Description

How Did You Test This Change?

Summary by CodeRabbit

  • Tests
    • Added comprehensive unit tests covering queue time span behavior: initialization defaults, cloning, getter/setter behavior, and timestamp-to-string conversions.
    • Tests include JSON serialization/deserialization checks and validate instances both with and without associated queue information to ensure consistent observable behavior.

Copilot AI review requested due to automatic review settings February 12, 2026 21:16
@rocketmq-rust-bot
Copy link
Collaborator

🔊@oopscompiled 🚀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 Feb 12, 2026

Walkthrough

Adds a test module for QueueTimeSpan under cfg(test) that verifies defaults, setters/getters, Clone, serde_json (camelCase) serialization/deserialization, JSON roundtrip, and timestamp string conversions. No public API or implementation changes.

Changes

Cohort / File(s) Summary
QueueTimeSpan Test Suite
rocketmq-remoting/src/protocol/body/queue_time_span.rs
Added unit tests (~113 lines) under cfg(test) covering initialization/defaults, setters/getters, Clone, serde_json serialization/deserialization with camelCase, JSON roundtrip comparisons, tests with and without a MessageQueue, and timestamp string representations.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 I hopped through tests with nimble paws,
Asserting clones and timestamps without pause,
Json in camelCase, fields in their place,
A tiny rabbit grins at green CI's face,
Hooray for passing tests and tidy code applause.

🚥 Pre-merge checks | ✅ 5 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (20 files):

⚔️ Cargo.lock (content)
⚔️ rocketmq-broker/Cargo.toml (content)
⚔️ rocketmq-client/README.md (content)
⚔️ rocketmq-client/src/base.rs (content)
⚔️ rocketmq-client/src/base/client_config.rs (content)
⚔️ rocketmq-client/src/producer.rs (content)
⚔️ rocketmq-client/src/producer/default_mq_produce_builder.rs (content)
⚔️ rocketmq-client/src/producer/default_mq_producer.rs (content)
⚔️ rocketmq-common/src/common/message.rs (content)
⚔️ rocketmq-controller/Cargo.toml (content)
⚔️ rocketmq-example/Cargo.lock (content)
⚔️ rocketmq-example/examples/consumer/pop_consumer.rs (content)
⚔️ rocketmq-namesrv/Cargo.toml (content)
⚔️ rocketmq-remoting/src/protocol/body/queue_time_span.rs (content)
⚔️ rocketmq-remoting/src/protocol/header/recall_message_response_header.rs (content)
⚔️ rocketmq-tools/rocketmq-admin/rocketmq-admin-core/Cargo.toml (content)
⚔️ rocketmq-tools/rocketmq-admin/rocketmq-admin-core/src/cli/commands.rs (content)
⚔️ rocketmq-tools/rocketmq-admin/rocketmq-admin-core/src/commands.rs (content)
⚔️ rocketmq-tools/rocketmq-admin/rocketmq-admin-core/src/commands/consumer_commands.rs (content)
⚔️ rocketmq-tools/rocketmq-store-inspect/Cargo.toml (content)

These conflicts must be resolved before merging into main.
Resolve conflicts locally and push changes to this branch.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly indicates the main change: adding unit tests for QueueTimeSpan, with reference to issue #6213. The emoji and bracketed labels are minor visual elements but the core message is specific and descriptive.
Linked Issues check ✅ Passed The PR implements comprehensive unit tests covering all 13 test scenarios from issue #6213: initialization, getters/setters, JSON serialization/deserialization, trait implementations (Default, Clone, Debug), and special field handling (MessageQueue, timestamps, delta_time).
Out of Scope Changes check ✅ Passed All changes are scoped to adding unit tests for QueueTimeSpan as required. No unrelated modifications to other modules or functionality are present in the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 87.50% 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 docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch test/add-test-case-QueueTimeSpan
  • Post resolved changes as copyable diffs in a comment

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
rocketmq-remoting/src/protocol/body/queue_time_span.rs (1)

113-130: Test name is misleading — this is a roundtrip test, not a standalone deserialization test.

queue_span_deserialise serializes and then deserializes, which tests roundtrip consistency. Consider renaming it to queue_span_serde_roundtrip and adding a separate deserialization test that parses a known JSON string. A standalone deserialization test would catch issues such as field-name mismatches when consuming JSON from external sources.


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

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

This PR adds comprehensive unit tests for the QueueTimeSpan struct in the rocketmq-remoting module, addressing issue #6213. The tests cover struct initialization, getters/setters, serialization/deserialization, Clone trait, and time string formatting methods.

Changes:

  • Added 7 test functions covering initialization, cloning, serialization, deserialization, getters, setters, and time formatting
  • Tests verify correct behavior of all public methods in the QueueTimeSpan struct
  • Includes validation of JSON serialization format with proper field naming

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

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

🤖 Fix all issues with AI agents
In `@rocketmq-remoting/src/protocol/body/queue_time_span.rs`:
- Around line 180-193: Rename the test function from qeueu_span_time_str to
queue_span_time_str and make the assertions timezone-independent by computing
expected strings with the same formatter used in production
(time_millis_to_human_string2) rather than hardcoding UTC+1 values; for example,
construct the QueueTimeSpan as shown and assert that
body.get_min_time_stamp_str() ==
time_millis_to_human_string2(body.min_time_stamp) (and similarly for
get_max_time_stamp_str/get_consume_time_stamp_str) so the test uses the same
formatting logic and will pass on any CI host.
🧹 Nitpick comments (1)
rocketmq-remoting/src/protocol/body/queue_time_span.rs (1)

113-130: Test name is misleading — this is a roundtrip test, not a pure deserialization test.

This test serializes then deserializes, so it's effectively a roundtrip. Consider renaming to queue_span_roundtrip and adding a separate deserialization test that starts from a hardcoded JSON string. A dedicated deserialization test would catch issues where field renames or serde attributes break ingestion of externally-produced JSON.

Comment on lines 180 to 193
#[test]
fn qeueu_span_time_str() {
let body: QueueTimeSpan = QueueTimeSpan {
message_queue: Some(MessageQueue::new()),
min_time_stamp: 1,
max_time_stamp: 2,
consume_time_stamp: 3,
delay_time: 4,
};

assert_eq!(body.get_min_time_stamp_str(), "1970-01-01 01:00:00,001".to_string());
assert_eq!(body.get_max_time_stamp_str(), "1970-01-01 01:00:00,002".to_string());
assert_eq!(body.get_consume_time_stamp_str(), "1970-01-01 01:00:00,003".to_string());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

rg -n 'fn time_millis_to_human_string2' --type rust -A 20

Repository: mxsm/rocketmq-rust

Length of output: 3084


🏁 Script executed:

cd rocketmq-remoting/src/protocol/body && head -20 queue_time_span.rs && echo "---" && sed -n '180,193p' queue_time_span.rs

Repository: mxsm/rocketmq-rust

Length of output: 1462


Typo in test name and timezone-dependent assertions will cause CI failures.

Two issues:

  1. Typo: qeueu_span_time_strqueue_span_time_str.
  2. Timezone-sensitive: The expected strings (e.g., "1970-01-01 01:00:00,001") assume UTC+1. time_millis_to_human_string2 formats using Local::timestamp_millis_opt(), so this test will fail on any machine not running in UTC+1 (including most CI environments). Compute expected strings dynamically using the same formatting function:
Fix both issues
-    fn qeueu_span_time_str() {
+    fn queue_span_time_str() {
         let body: QueueTimeSpan = QueueTimeSpan {
             message_queue: Some(MessageQueue::new()),
             min_time_stamp: 1,
             max_time_stamp: 2,
             consume_time_stamp: 3,
             delay_time: 4,
         };
 
-        assert_eq!(body.get_min_time_stamp_str(), "1970-01-01 01:00:00,001".to_string());
-        assert_eq!(body.get_max_time_stamp_str(), "1970-01-01 01:00:00,002".to_string());
-        assert_eq!(body.get_consume_time_stamp_str(), "1970-01-01 01:00:00,003".to_string());
+        assert_eq!(body.get_min_time_stamp_str(), time_millis_to_human_string2(1));
+        assert_eq!(body.get_max_time_stamp_str(), time_millis_to_human_string2(2));
+        assert_eq!(body.get_consume_time_stamp_str(), time_millis_to_human_string2(3));
🤖 Prompt for AI Agents
In `@rocketmq-remoting/src/protocol/body/queue_time_span.rs` around lines 180 -
193, Rename the test function from qeueu_span_time_str to queue_span_time_str
and make the assertions timezone-independent by computing expected strings with
the same formatter used in production (time_millis_to_human_string2) rather than
hardcoding UTC+1 values; for example, construct the QueueTimeSpan as shown and
assert that body.get_min_time_stamp_str() ==
time_millis_to_human_string2(body.min_time_stamp) (and similarly for
get_max_time_stamp_str/get_consume_time_stamp_str) so the test uses the same
formatting logic and will pass on any CI host.

Co-authored-by: Copilot <[email protected]>
@codecov
Copy link

codecov bot commented Feb 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 42.48%. Comparing base (c81e83c) to head (e2e6230).
⚠️ Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6309      +/-   ##
==========================================
+ Coverage   42.20%   42.48%   +0.27%     
==========================================
  Files         901      909       +8     
  Lines      126236   127280    +1044     
==========================================
+ Hits        53284    54069     +785     
- Misses      72952    73211     +259     

☔ 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 ✅

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 unit tests for QueueTimeSpan

3 participants