satishd commented on code in PR #11390:
URL: https://github.com/apache/kafka/pull/11390#discussion_r1047369687


##########
core/src/test/scala/unit/kafka/log/ProducerStateManagerTest.scala:
##########
@@ -741,6 +740,30 @@ class ProducerStateManagerTest {
     assertEquals(Set(1), currentSnapshotOffsets)
   }
 
+  @Test
+  def testReloadSnapshots(): Unit = {
+    val epoch = 0.toShort
+    append(stateManager, producerId, epoch, 1, 1L)
+    append(stateManager, producerId, epoch, 2, 2L)
+    stateManager.takeSnapshot()
+    val pathAndDataList = logDir.listFiles().map(file => (file.toPath, 
Files.readAllBytes(file.toPath)))
+
+    append(stateManager, producerId, epoch, 3, 3L)
+    append(stateManager, producerId, epoch, 4, 4L)
+    stateManager.takeSnapshot()
+    assertEquals(2, logDir.listFiles().length)
+    assertEquals(Set(3, 5), currentSnapshotOffsets)
+
+    stateManager.truncateAndReload(3, 5, time.milliseconds())
+    assertEquals(1, logDir.listFiles().length)
+    assertEquals(Set(5), currentSnapshotOffsets)
+
+    pathAndDataList.foreach(e => Files.write(e._1, e._2))
+    stateManager.reloadSnapshots()
+    assertEquals(Some(3), stateManager.latestSnapshotOffset)

Review Comment:
   Added more documentation about the test for better clarity with the latest 
commit. stateManager.reloadSnapshots() deletes the existing snapshots. 



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