xBis7 commented on code in PR #4819:
URL: https://github.com/apache/ozone/pull/4819#discussion_r1222896389


##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOmSnapshot.java:
##########
@@ -627,6 +628,47 @@ public void testSnapDiff() throws Exception {
 
   }
 
+  @Test
+  public void testSnapDiffCancel() throws Exception {
+    // Create key1 and take snapshot.
+    String key1 = "key-1-" + RandomStringUtils.randomNumeric(5);
+    createFileKey(ozoneBucket, key1);
+    String fromSnapName = "snap-1-" + RandomStringUtils.randomNumeric(5);
+    createSnapshot(volumeName, bucketName, fromSnapName);
+
+    // Create key2 and take snapshot.
+    String key2 = "key-2-" + RandomStringUtils.randomNumeric(5);
+    createFileKey(ozoneBucket, key2);
+    String toSnapName = "snap-2-" + RandomStringUtils.randomNumeric(5);
+    createSnapshot(volumeName, bucketName, toSnapName);
+
+    // Cancel works only if the job is IN_PROGRESS, and
+    // it's ignored if the job has any other status.
+
+    SnapshotDiffResponse response = store.snapshotDiff(
+        volumeName, bucketName, fromSnapName, toSnapName,
+        null, 0, false, true);
+
+    // Cancel here is ignored, job gets saved in the snapDiffJobTable
+    // as QUEUED and then transitions IN_PROGRESS.
+    assertEquals(IN_PROGRESS, response.getJobStatus());
+
+    response = store.snapshotDiff(volumeName,
+        bucketName, fromSnapName, toSnapName,
+        null, 0, false, true);
+
+    // Job status should be updated to CANCELED.
+    assertEquals(CANCELED, response.getJobStatus());
+
+    // Executing the command again should return CANCELED,
+    // until the job is picked up by the SnapshotDiffCleanupService
+    // and removed from the snapDiffJobTable.
+    response = store.snapshotDiff(volumeName,

Review Comment:
   I will add it here as well. IMO, they are both integration tests since in 
`TestSnapshotDiffManager` we are not mocking anything, we are using 
`TestOmManagers` which creates an actual OzoneManager. The difference is that 
this test spins up a whole cluster to run the test on.
   
   We had a previous discussion in a sync call about this. Most of Ozone tests 
are integration tests, but we keep calling them unit tests because they don't 
use MiniOzoneCluster. 



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