nandini12396 commented on code in PR #21158:
URL: https://github.com/apache/kafka/pull/21158#discussion_r2628222002
##########
storage/src/test/java/org/apache/kafka/server/log/remote/storage/RemoteLogManagerTest.java:
##########
@@ -3632,6 +3632,63 @@ public void testTierLagResetsToZeroOnBecomingFollower() {
assertEquals(0,
brokerTopicStats.topicStats(leaderTopicIdPartition.topic()).remoteCopyLagSegments());
}
+ @Test
+ public void testCopyLagMetricsAfterLeaderChange() {
+ LogSegment activeSegment = mock(LogSegment.class);
+
when(mockLog.topicPartition()).thenReturn(leaderTopicIdPartition.topicPartition());
+ when(mockLog.activeSegment()).thenReturn(activeSegment);
+ when(mockLog.onlyLocalLogSegmentsSize()).thenReturn(50L);
+ when(activeSegment.size()).thenReturn(100);
+ when(mockLog.onlyLocalLogSegmentsCount()).thenReturn(1L);
+
+ remoteLogManager.onLeadershipChange(
+ Set.of(mockPartition(leaderTopicIdPartition)), Set.of(),
topicIds);
+ RemoteLogManager.RLMCopyTask rlmTask = (RemoteLogManager.RLMCopyTask)
remoteLogManager.rlmCopyTask(leaderTopicIdPartition);
+ assertNotNull(rlmTask);
+
+ rlmTask.recordLagStats(mockLog);
+ assertEquals(0,
brokerTopicStats.topicStats(leaderTopicIdPartition.topic()).remoteCopyLagBytes());
+ assertEquals(0,
brokerTopicStats.topicStats(leaderTopicIdPartition.topic()).remoteCopyLagSegments());
+ }
+
+ @Test
+ public void testCopyLagMetricsWithOnlyActiveSegment() {
+ LogSegment activeSegment = mock(LogSegment.class);
+
when(mockLog.topicPartition()).thenReturn(leaderTopicIdPartition.topicPartition());
+ when(mockLog.activeSegment()).thenReturn(activeSegment);
+ when(mockLog.onlyLocalLogSegmentsSize()).thenReturn(100L);
+ when(activeSegment.size()).thenReturn(100);
+ when(mockLog.onlyLocalLogSegmentsCount()).thenReturn(0L);
Review Comment:
got it, please check
--
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]