Koado commented on code in PR #7082:
URL: https://github.com/apache/rocketmq/pull/7082#discussion_r1276990031


##########
tools/src/test/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtTest.java:
##########
@@ -512,6 +513,30 @@ public void testSearchOffset() throws Exception {
         assertThat(defaultMQAdminExt.searchOffset(new MessageQueue(TOPIC1, 
BROKER1_NAME, 0), System.currentTimeMillis())).isEqualTo(101L);
     }
 
+    @Test
+    public void testSearchOffsetWithSpecificBoundaryType() throws Exception {
+
+        String namesrvAddr = "127.0.0.1:9876";
+        String topic = "test-topic";
+
+        DefaultMQAdminExt mqAdminExt = new DefaultMQAdminExt();
+        mqAdminExt.setInstanceName(UUID.randomUUID().toString());
+        mqAdminExt.setNamesrvAddr(namesrvAddr);
+
+        mqAdminExt.start();
+        List<QueueTimeSpan> timeSpanList = 
mqAdminExt.queryConsumeTimeSpan(topic, null);
+        if (timeSpanList != null && timeSpanList.size() > 0) {
+            for (QueueTimeSpan timeSpan: timeSpanList) {
+                MessageQueue mq = timeSpan.getMessageQueue();
+                long maxOffset = mqAdminExt.maxOffset(mq);
+                long minOffset = mqAdminExt.minOffset(mq);
+                // if there is at least one message in queue, the maxOffset 
returns the queue's latest offset + 1
+                assertThat((maxOffset == 0 ? 0 : maxOffset - 1) == 
mqAdminExt.searchUpperBoundaryOffset(mq, timeSpan.getMaxTimeStamp())).isTrue();
+                assertThat(minOffset == 
mqAdminExt.searchLowerBoundaryOffset(mq, timeSpan.getMinTimeStamp())).isTrue();
+            }
+        }
+    }

Review Comment:
   already replace it with mock, thanks.



-- 
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: commits-unsubscr...@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to