steveloughran commented on code in PR #5364:
URL: https://github.com/apache/hadoop/pull/5364#discussion_r1144815944


##########
hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/DistCpSync.java:
##########
@@ -161,20 +161,32 @@ private void checkFilesystemSupport(Path sourceDir, Path 
targetDir,
     if (!srcFs.hasPathCapability(sourceDir,
         CommonPathCapabilities.FS_SNAPSHOTS)) {
       throw new IllegalArgumentException(
-          "The source file system " + srcFs.getScheme() + " does not support 
snapshot.");
+          "The source file system " + srcFs.getScheme()
+              + " does not support snapshot.");
     }
     if (!tgtFs.hasPathCapability(targetDir,
         CommonPathCapabilities.FS_SNAPSHOTS)) {
       throw new IllegalArgumentException(
-          "The target file system " + tgtFs.getScheme() + " does not support 
snapshot.");
+          "The target file system " + tgtFs.getScheme()
+              + " does not support snapshot.");
     }
     try {
       getSnapshotDiffReportMethod(srcFs);
+    } catch (NoSuchMethodException e) {
+      throw new IllegalArgumentException(

Review Comment:
   move to UnsupportedOperationException



##########
hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/TestDistCpSync.java:
##########
@@ -1305,7 +1305,7 @@ public void testSyncSnapshotDiffWithDummyFileSystem() 
throws Exception {
       new DistCp(conf, OptionsParser.parse(args)).execute();
     } catch (Exception e) {

Review Comment:
   ok. catch `UnsupportedOperationException` after tightening the exception 
raised



##########
hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/DistCpSync.java:
##########
@@ -161,20 +161,32 @@ private void checkFilesystemSupport(Path sourceDir, Path 
targetDir,
     if (!srcFs.hasPathCapability(sourceDir,
         CommonPathCapabilities.FS_SNAPSHOTS)) {
       throw new IllegalArgumentException(

Review Comment:
   UnsupportedOperationException



##########
hadoop-tools/hadoop-distcp/src/test/java/org/apache/hadoop/tools/TestDistCpSync.java:
##########
@@ -1276,4 +1283,63 @@ private void snapshotDiffWithPaths(Path sourceFSPath,
     verifyCopyByFs(sourceFS, targetFS, sourceFS.getFileStatus(sourceFSPath),
         targetFS.getFileStatus(targetFSPath), false);
   }
+
+  @Test
+  public void testSyncSnapshotDiffWithLocalFileSystem() throws Exception {
+    String[] args = new String[]{"-update", "-diff", "s1", "s2",
+        "file:///source", "file:///target"};
+    LambdaTestUtils.intercept(
+        IllegalArgumentException.class,
+        "The source file system file does not support snapshot",
+        () -> new DistCp(conf, OptionsParser.parse(args)).execute());
+  }
+
+  @Test
+  public void testSyncSnapshotDiffWithDummyFileSystem() throws Exception {
+    String[] args =
+        new String[] { "-update", "-diff", "s1", "s2", "dummy:///source",
+            "dummy:///target" };
+    try {
+      FileSystem dummyFs = FileSystem.get(URI.create("dummy:///"), conf);
+      Assert.assertTrue(dummyFs instanceof DummyFs);
+      new DistCp(conf, OptionsParser.parse(args)).execute();
+    } catch (Exception e) {
+      // can expect other exceptions as source and target paths
+      // are not created, assert if the exception is not arising
+      // due to the filesystem not supporting snapshots.
+      Assert.assertFalse(e.getMessage().contains("does not support snapshot"));

Review Comment:
   ok. 
   Use `GenericTestUtils.assertExceptionContains(does not support snapshot", 
e)` so on a failure, the unexpected exception message and stack is not lost. 
whoever has to debug a test failure from an html test report will love you for 
this



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