smjn commented on code in PR #20815:
URL: https://github.com/apache/kafka/pull/20815#discussion_r2489907333


##########
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:
   Added to all tests



-- 
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]

Reply via email to