tju-yxq commented on PR #1884:
URL: 
https://github.com/apache/rocketmq-dashboard/pull/1884#issuecomment-5269775204

   I reviewed PR #1884 against this issue and ran the backend test suite 
declared in the PR:
   
   ```bash
   mvn -q -Dtest=RocketMQMessageProviderTest test
   ```
   
   Result: `BUILD SUCCESS`.
   
   I also narrowed the issue body to avoid implying a live RocketMQ 5.x / UI 
reproduction; the verified evidence is code inspection plus focused unit tests.
   
   One test-coverage suggestion: the current regression test verifies 
newest-first ordering, but the issue is specifically about queue scan order. I 
locally strengthened the test to use two queues where queue 0 returns an older 
message and queue 1 returns a newer message, then verified the final result 
order is `newer`, `older`. That strengthened test passed locally.
   
   Suggested replacement for the current 
`queryByTopicReturnsNewestMessagesFirst` test:
   
   ```java
   @Test
   void queryByTopicSortsMessagesAcrossQueuesNewestFirst() throws Exception {
       MessageQueue olderQueue = new MessageQueue("TopicA", "broker-a", 0);
       MessageQueue newerQueue = new MessageQueue("TopicA", "broker-a", 1);
       MessageExt older = new MessageExt();
       older.setMsgId("older");
       older.setTopic("TopicA");
       older.setStoreTimestamp(150L);
       MessageExt newer = new MessageExt();
       newer.setMsgId("newer");
       newer.setTopic("TopicA");
       newer.setStoreTimestamp(250L);
       PullResult olderPullResult = new PullResult(PullStatus.FOUND, 11L, 10L, 
10L,
               List.of(older));
       PullResult newerPullResult = new PullResult(PullStatus.FOUND, 11L, 10L, 
10L,
               List.of(newer));
       try (MockedConstruction<DefaultMQPullConsumer> ignored =
                    mockConstruction(DefaultMQPullConsumer.class, (consumer, 
context) -> {
                        doNothing().when(consumer).start();
                        when(consumer.fetchSubscribeMessageQueues("TopicA"))
                                .thenReturn(new 
LinkedHashSet<>(List.of(olderQueue, newerQueue)));
                        when(consumer.searchOffset(eq(olderQueue), 
anyLong())).thenReturn(10L);
                        when(consumer.searchOffset(eq(newerQueue), 
anyLong())).thenReturn(10L);
                        when(consumer.pull(olderQueue, "*", 10L, 
32)).thenReturn(olderPullResult);
                        when(consumer.pull(newerQueue, "*", 10L, 
32)).thenReturn(newerPullResult);
                        doNothing().when(consumer).shutdown();
                    })) {
           List<MessageRecordVO> messages = provider.queryMessages(
                   "instance-a", "TopicA", null, null, null, 100L, 300L);
   
           assertThat(messages).extracting(MessageRecordVO::getMsgId)
                   .containsExactly("newer", "older");
       }
   }
   ```
   
   This also needs:
   
   ```java
   import java.util.LinkedHashSet;
   ```
   
   Local verification for this strengthened test:
   
   ```bash
   mvn -q 
"-Dtest=RocketMQMessageProviderTest#queryByTopicSortsMessagesAcrossQueuesNewestFirst"
 test
   mvn -q -Dtest=RocketMQMessageProviderTest test
   ```
   
   Both commands completed successfully locally.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to