adixitconfluent commented on code in PR #20815:
URL: https://github.com/apache/kafka/pull/20815#discussion_r2489539311
##########
core/src/test/java/kafka/server/share/SharePartitionTest.java:
##########
@@ -9940,7 +9942,68 @@ public void testRenewAcknowledgeWithCompleteBatchAck()
throws InterruptedExcepti
sharePartition.acknowledge(MEMBER_ID, List.of(new
ShareAcknowledgementBatch(0, 0, List.of(AcknowledgeType.RENEW.id))));
assertTrue(taskOrig.isCancelled()); // Original acq lock cancelled.
assertNotEquals(taskOrig, batch.batchAcquisitionLockTimeoutTask()); //
Lock changes.
+ assertEquals(1, sharePartition.timer().size()); // Timer jobs
+ assertEquals(RecordState.ACQUIRED, batch.batchState());
Mockito.verify(persister, Mockito.times(0)).writeState(Mockito.any());
// No persister call.
+
+ // Expire timer
+ // On expiration state will transition to AVAILABLE resulting in
persister write RPC
+ WriteShareGroupStateResult writeShareGroupStateResult =
Mockito.mock(WriteShareGroupStateResult.class);
+
Mockito.when(writeShareGroupStateResult.topicsData()).thenReturn(List.of(
+ new TopicData<>(TOPIC_ID_PARTITION.topicId(), List.of(
+ PartitionFactory.newPartitionErrorData(0, Errors.NONE.code(),
Errors.NONE.message())))));
+
when(persister.writeState(Mockito.any())).thenReturn(CompletableFuture.completedFuture(writeShareGroupStateResult));
+
+ mockTimer.advanceClock(ACQUISITION_LOCK_TIMEOUT_MS + 1); // Trigger
expire
+
+ assertNull(batch.batchAcquisitionLockTimeoutTask());
+ assertEquals(RecordState.AVAILABLE, batch.batchState()); // Verify
batch record state
+ Mockito.verify(persister, Mockito.times(1)).writeState(Mockito.any());
// 1 persister call.
+ }
Review Comment:
`assertEquals(0, sharePartition.timer().size()); // No timer jobs after
expiration` adding this assertion at the end of the test should be useful for
the future. Its fine if you ignore this suggestion as well.
--
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]