kamalcph commented on code in PR #16210: URL: https://github.com/apache/kafka/pull/16210#discussion_r1636623718
########## core/src/test/java/kafka/log/remote/RemoteLogManagerTest.java: ########## @@ -1000,7 +1000,7 @@ void testRemoteLogManagerRemoteMetrics() throws Exception { when(mockLog.onlyLocalLogSegmentsSize()).thenReturn(175L, 100L); when(activeSegment.size()).thenReturn(100); - when(mockLog.onlyLocalLogSegmentsCount()).thenReturn(1L); + when(mockLog.onlyLocalLogSegmentsCount()).thenReturn(2L); Review Comment: ```suggestion when(mockLog.onlyLocalLogSegmentsCount()).thenReturn(2L).thenReturn(1L); // before running tasks, the metric should not be registered assertThrows(NoSuchElementException.class, () -> yammerMetricValue("RemoteCopyLagBytes,topic=" + leaderTopic)); assertThrows(NoSuchElementException.class, () -> yammerMetricValue("RemoteCopyLagSegments,topic=" + leaderTopic)); assertThrows(NoSuchElementException.class, () -> yammerMetricValue("RemoteLogSizeComputationTime,topic=" + leaderTopic)); // all topic metrics should be 0 assertEquals(0L, yammerMetricValue("RemoteCopyLagBytes")); assertEquals(0L, yammerMetricValue("RemoteCopyLagSegments")); assertEquals(0L, yammerMetricValue("RemoteLogSizeComputationTime")); remoteLogManager.onLeadershipChange(Collections.singleton(mockLeaderPartition), Collections.emptySet(), topicIds); TestUtils.waitForCondition( () -> 75 == safeLongYammerMetricValue("RemoteCopyLagBytes") && 75 == safeLongYammerMetricValue("RemoteCopyLagBytes,topic=" + leaderTopic), String.format("Expected to find 75 for RemoteCopyLagBytes metric value, but found %d for topic 'Leader' and %d for all topics.", safeLongYammerMetricValue("RemoteCopyLagBytes,topic=" + leaderTopic), safeLongYammerMetricValue("RemoteCopyLagBytes"))); TestUtils.waitForCondition( () -> 1 == safeLongYammerMetricValue("RemoteCopyLagSegments") && 1 == safeLongYammerMetricValue("RemoteCopyLagSegments,topic=" + leaderTopic), String.format("Expected to find 1 for RemoteCopyLagSegments metric value, but found %d for topic 'Leader' and %d for all topics.", safeLongYammerMetricValue("RemoteCopyLagSegments,topic=" + leaderTopic), safeLongYammerMetricValue("RemoteCopyLagSegments"))); // unlock copyLogSegmentData latch.countDown(); TestUtils.waitForCondition( () -> safeLongYammerMetricValue("RemoteLogSizeComputationTime") >= 1000 && safeLongYammerMetricValue("RemoteLogSizeComputationTime,topic=" + leaderTopic) >= 1000, String.format("Expected to find 1000 for RemoteLogSizeComputationTime metric value, but found %d for topic 'Leader' and %d for all topics.", safeLongYammerMetricValue("RemoteLogSizeComputationTime,topic=" + leaderTopic), safeLongYammerMetricValue("RemoteLogSizeComputationTime"))); remoteLogSizeComputationTimeLatch.countDown(); TestUtils.waitForCondition( () -> 0 == safeLongYammerMetricValue("RemoteCopyLagBytes") && 0 == safeLongYammerMetricValue("RemoteCopyLagBytes,topic=" + leaderTopic), String.format("Expected to find 0 for RemoteCopyLagBytes metric value, but found %d for topic 'Leader' and %d for all topics.", safeLongYammerMetricValue("RemoteCopyLagBytes,topic=" + leaderTopic), safeLongYammerMetricValue("RemoteCopyLagBytes"))); TestUtils.waitForCondition( () -> 0 == safeLongYammerMetricValue("RemoteCopyLagSegments") && 0 == safeLongYammerMetricValue("RemoteCopyLagSegments,topic=" + leaderTopic), String.format("Expected to find 0 for RemoteCopyLagSegments metric value, but found %d for topic 'Leader' and %d for all topics.", safeLongYammerMetricValue("RemoteCopyLagSegments,topic=" + leaderTopic), safeLongYammerMetricValue("RemoteCopyLagSegments"))); ``` -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org