smengcl commented on code in PR #10386:
URL: https://github.com/apache/ozone/pull/10386#discussion_r3417422911


##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/service/TestSnapshotDeletingService.java:
##########
@@ -206,6 +213,51 @@ public void testSnapshotMoveKeysRequestBatching() throws 
Exception {
     assertEquals(totalExpected, totalDeletedKeysProcessed + 
totalRenamedKeysProcessed + totalDeletedDirsProcessed);
   }
 
+  @Test
+  public void testSnapshotDeletingTaskLogsSnapshotId() throws Exception {
+    IOzoneManagerLock lock = Mockito.mock(IOzoneManagerLock.class);
+    UUID snapshotId = UUID.randomUUID();
+    SnapshotInfo snapshotInfo = SnapshotInfo.newBuilder()
+        .setSnapshotId(snapshotId)
+        .setVolumeName("vol1")
+        .setBucketName("bucket1")
+        .setName("snap1")
+        .setSnapshotStatus(SnapshotInfo.SnapshotStatus.SNAPSHOT_DELETED)
+        .setLastTransactionInfo(TransactionInfo.valueOf(1, 1).toByteString())
+        .build();
+
+    
Mockito.when(omMetadataManager.getSnapshotChainManager()).thenReturn(chainManager);
+    Mockito.when(omMetadataManager.getLock()).thenReturn(lock);
+    
Mockito.when(ozoneManager.getOmSnapshotManager()).thenReturn(omSnapshotManager);
+    
Mockito.when(ozoneManager.getMetadataManager()).thenReturn(omMetadataManager);
+    Mockito.when(ozoneManager.getConfiguration()).thenReturn(conf);
+    Mockito.when(ozoneManager.isLeaderReady()).thenReturn(true);
+    
Mockito.when(chainManager.iterator(true)).thenReturn(List.of(snapshotId).iterator());
+    Mockito.when(lock.acquireWriteLocks(any(), any()))
+        .thenReturn(OMLockDetails.EMPTY_DETAILS_LOCK_NOT_ACQUIRED);
+
+    SnapshotDeletingService service = new 
SnapshotDeletingService(sdsRunInterval, sdsServiceTimeout, ozoneManager);
+    LogCapturer logCapturer = 
LogCapturer.captureLogs(SnapshotDeletingService.class);
+
+    try (MockedStatic<SnapshotUtils> snapshotUtils = 
mockStatic(SnapshotUtils.class);
+         MockedStatic<OmSnapshotManager> omSnapshotManagerStatic = 
mockStatic(OmSnapshotManager.class)) {
+      snapshotUtils.when(() -> SnapshotUtils.getSnapshotInfo(ozoneManager, 
chainManager, snapshotId))
+          .thenReturn(snapshotInfo);
+      snapshotUtils.when(() -> SnapshotUtils.getNextSnapshot(ozoneManager, 
chainManager, snapshotInfo))
+          .thenReturn(null);
+      omSnapshotManagerStatic.when(() -> 
OmSnapshotManager.areSnapshotChangesFlushedToDB(omMetadataManager,
+          snapshotInfo)).thenReturn(true);
+
+      service.new SnapshotDeletingTask().call();
+    }
+
+    String expectedLogLabel = snapshotInfo.getTableKey() + " (snapshotId='" + 
snapshotInfo.getSnapshotId() + "')";
+    assertThat(logCapturer.getOutput()).contains(
+        "Started Snapshot Deletion Processing for snapshot : " + 
expectedLogLabel);
+    assertThat(logCapturer.getOutput()).contains(
+        "Snapshot: " + expectedLogLabel + " entries will be moved to AOS.");

Review Comment:
   done!



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