swamirishi commented on code in PR #9131:
URL: https://github.com/apache/ozone/pull/9131#discussion_r2481297570


##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMDbCheckpointServletInodeBasedXfer.java:
##########
@@ -586,6 +592,119 @@ public void testBootstrapLockBlocksMultipleServices() 
throws Exception {
     assertTrue(servicesSucceeded.get() > 0, "Services should have succeeded 
after lock release");
   }
 
+  /**
+   * Tests the full checkpoint servlet flow to ensure snapshot paths are read
+   * from checkpoint metadata (frozen state) rather than live OM metadata 
(current state).
+   * Scenario:
+   * 1. Create snapshots S1, S2
+   * 2. Create Snapshot S3
+   * 3. Checkpoint is created (freezes state with S1, S2)
+   * 4. S2 gets purged from live OM (after checkpoint creation)
+   * 5. Servlet processes checkpoint - should still include S2 data
+   */
+  @Test
+  public void testCheckpointIncludesSnapshotsFromFrozenState() throws 
Exception {
+    String volumeName = "vol" + RandomStringUtils.secure().nextNumeric(5);
+    String bucketName = "buck" + RandomStringUtils.secure().nextNumeric(5);
+
+    setupCluster();
+    om.getKeyManager().getSnapshotSstFilteringService().pause();
+
+    // Create test data and snapshots
+    OzoneBucket bucket = TestDataUtil.createVolumeAndBucket(client, 
volumeName, bucketName);
+
+    // Create key before first snapshot
+    TestDataUtil.createKey(bucket, "key1",
+        ReplicationConfig.fromTypeAndFactor(ReplicationType.RATIS, 
ReplicationFactor.ONE),
+        "data1".getBytes(StandardCharsets.UTF_8));
+    client.getObjectStore().createSnapshot(volumeName, bucketName, 
"snapshot1");
+
+    // Create key before second snapshot
+    TestDataUtil.createKey(bucket, "key2",
+        ReplicationConfig.fromTypeAndFactor(ReplicationType.RATIS, 
ReplicationFactor.ONE),
+        "data2".getBytes(StandardCharsets.UTF_8));
+    client.getObjectStore().createSnapshot(volumeName, bucketName, 
"snapshot2");
+    TestDataUtil.createKey(bucket, "key3",
+        ReplicationConfig.fromTypeAndFactor(ReplicationType.RATIS, 
ReplicationFactor.ONE),
+        "data3".getBytes(StandardCharsets.UTF_8));
+    client.getObjectStore().createSnapshot(volumeName, bucketName, 
"snapshot3");
+    om.getMetadataManager().getStore().flushDB();
+
+    // At this point: Live OM has snapshots S1, S2
+    List<OzoneSnapshot> snapshotsBeforePurge = new ArrayList<>();
+    client.getObjectStore().listSnapshot(volumeName, bucketName, "", null)
+        .forEachRemaining(snapshotsBeforePurge::add);
+    assertEquals(3, snapshotsBeforePurge.size(), "Should have 3 snapshots 
initially");
+    OzoneSnapshot snapshot2 = snapshotsBeforePurge.stream()
+        .filter(snap -> snap.getName().equals("snapshot2"))
+        .findFirst()
+        .orElseThrow(() -> new RuntimeException("snapshot2 not found"));
+    OzoneSnapshot snapshot3 = snapshotsBeforePurge.stream()
+        .filter(snap -> snap.getName().equals("snapshot3"))
+        .findFirst()
+        .orElseThrow(() -> new RuntimeException("snapshot2 not found"));
+
+    // Setup servlet mocks for checkpoint processing
+    setupMocks();
+    
when(requestMock.getParameter(OZONE_DB_CHECKPOINT_INCLUDE_SNAPSHOT_DATA)).thenReturn("true");
+
+    // Create a checkpoint that captures current state (S1, S2)
+    DBStore dbStore = om.getMetadataManager().getStore();
+    DBStore spyDbStore = spy(dbStore);
+    AtomicReference<DBCheckpoint> capturedCheckpoint = new AtomicReference<>();
+
+    when(spyDbStore.getCheckpoint(true)).thenAnswer(invocation -> {
+      DBCheckpoint checkpoint = spy(dbStore.getCheckpoint(true));
+      doNothing().when(checkpoint).cleanupCheckpoint(); // Don't cleanup for 
verification
+      capturedCheckpoint.set(checkpoint);
+      return checkpoint;
+    });

Review Comment:
   @sadanand48 Let us purge the snapshot just before we are trying to take a 
checkpoint which means that we should purge the snapshot in this block



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to