yashmayya commented on code in PR #14102: URL: https://github.com/apache/kafka/pull/14102#discussion_r1288249581
########## connect/runtime/src/test/java/org/apache/kafka/connect/runtime/distributed/DistributedHerderTest.java: ########## @@ -3872,7 +2952,7 @@ public void testVerifyTaskGeneration() { assertThrows(ConnectException.class, () -> herder.verifyTaskGenerationAndOwnership(unassignedTask, 1, verifyCallback)); assertThrows(ConnectException.class, () -> herder.verifyTaskGenerationAndOwnership(unassignedTask, 2, verifyCallback)); - PowerMock.verifyAll(); + verify(verifyCallback, times(3)).onCompletion(isNull(), isNull()); Review Comment: > We expect this to be invoked five times in the original test There are only 3 calls to `herder::verifyTaskGenerationAndOwnership` in this test that aren't expected to throw an exception. > Were we never properly verifying the number of invocations in the existing test? Yep, the `verifyCallback` mock isn't passed into the `PowerMock::replayAll` call which means that it isn't "known" to `PowerMock` and the `PowerMock::verifyAll` call will not make any verifications on it. If this line in the original test - https://github.com/apache/kafka/blob/f23394336a7741bf4eb23fcde951af0a23a69bd0/connect/runtime/src/test/java/org/apache/kafka/connect/runtime/distributed/DistributedHerderTest.java#L3838 is changed to `PowerMock.replayAll(verifyCallback);` then the original test fails and only passes when we change this loop from 5 iterations to 3 - https://github.com/apache/kafka/blob/f23394336a7741bf4eb23fcde951af0a23a69bd0/connect/runtime/src/test/java/org/apache/kafka/connect/runtime/distributed/DistributedHerderTest.java#L3833-L3836 -- 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