hemantk-12 commented on code in PR #4657:
URL: https://github.com/apache/ozone/pull/4657#discussion_r1195852796


##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOmSnapshot.java:
##########
@@ -927,4 +890,103 @@ public void testSnapshotOpensWithDisabledAutoCompaction() 
throws Exception {
     }
   }
 
+  // Test snapshot diff when OM restarts in non-HA OM env and diff job is
+  // in_progress when it restarts.
+  @Test
+  public void testSnapshotDiffWhenOmRestart()
+      throws IOException, InterruptedException {
+    String snapshot1 = "snap-" + RandomStringUtils.randomNumeric(5);
+    String snapshot2 = "snap-" + RandomStringUtils.randomNumeric(5);
+    createSnapshots(snapshot1, snapshot2);
+
+    SnapshotDiffResponse response = store.snapshotDiff(volumeName, bucketName,
+        snapshot1, snapshot2, null, 0, false);
+
+    assertEquals(IN_PROGRESS, response.getJobStatus());
+
+    // Restart the OM and wait for sometime to make sure that previous snapDiff
+    // job finishes.
+    cluster.restartOzoneManager();
+    await().atMost(Duration.ofSeconds(120)).
+        until(() -> cluster.getOzoneManager().isRunning());
+
+    response = store.snapshotDiff(volumeName, bucketName,
+        snapshot1, snapshot2, null, 0, false);
+
+    // If job was IN_PROGRESS or DONE state when OM restarted, it should be
+    // DONE by this time.
+    // If job FAILED during crash (which mostly happens in the test because
+    // of active snapshot checks), it would be removed by clean up service on
+    // startup, and request after clean up will be considered a new request
+    // and would return IN_PROGRESS. No other state is expected other than
+    // IN_PROGRESS and DONE.
+    if (response.getJobStatus() == DONE) {
+      assertEquals(100, response.getSnapshotDiffReport().getDiffList().size());
+    } else if (response.getJobStatus() == IN_PROGRESS) {
+      Thread.sleep(response.getWaitTimeInMs());
+      response = store.snapshotDiff(volumeName, bucketName,
+          snapshot1, snapshot2, null, 0, false);
+      assertEquals(DONE, response.getJobStatus());
+      assertEquals(100, response.getSnapshotDiffReport().getDiffList().size());
+    } else {
+      fail("Unexpected job status for the test.");
+    }
+  }
+
+  // Test snapshot diff when OM restarts in non-HA OM env and report is
+  // partially received.
+  @Test
+  public void testSnapshotDiffWhenOmRestartAndReportIsPartiallyFetched()
+      throws IOException, InterruptedException {
+    int pageSize = 10;
+    String snapshot1 = "snap-" + RandomStringUtils.randomNumeric(5);
+    String snapshot2 = "snap-" + RandomStringUtils.randomNumeric(5);
+    createSnapshots(snapshot1, snapshot2);
+
+    SnapshotDiffResponse response = store.snapshotDiff(volumeName, bucketName,
+        snapshot1, snapshot2, null, pageSize, false);
+
+    assertEquals(IN_PROGRESS, response.getJobStatus());
+    Thread.sleep(response.getWaitTimeInMs());

Review Comment:
   It should be that case. But I still changed it to while loop.



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