ayushtkn commented on a change in pull request #2516:
URL: https://github.com/apache/hive/pull/2516#discussion_r713671862



##########
File path: ql/src/test/org/apache/hadoop/hive/ql/parse/repl/TestCopyUtils.java
##########
@@ -110,6 +112,100 @@ public void shouldThrowExceptionOnDistcpFailure() throws 
Exception {
     copyUtils.doCopy(destination, srcPaths);
   }
 
+  @Test
+  public void testFSCallsFailOnParentExceptions() throws Exception {
+    mockStatic(UserGroupInformation.class);
+    mockStatic(ReplChangeManager.class);
+    
when(UserGroupInformation.getCurrentUser()).thenReturn(mock(UserGroupInformation.class));
+    HiveConf conf = mock(HiveConf.class);
+    conf.set(HiveConf.ConfVars.REPL_RETRY_INTIAL_DELAY.varname, "1s");
+    FileSystem fs = mock(FileSystem.class);
+    Path source = mock(Path.class);
+    Path destination = mock(Path.class);
+    ContentSummary cs = mock(ContentSummary.class);
+
+    Exception exception = new 
org.apache.hadoop.fs.PathPermissionException("Failed");
+    when(ReplChangeManager.checksumFor(source, 
fs)).thenThrow(exception).thenReturn("dummy");
+    when(fs.exists(same(source))).thenThrow(exception).thenReturn(true);
+    when(fs.delete(same(source), 
anyBoolean())).thenThrow(exception).thenReturn(true);
+    when(fs.mkdirs(same(source))).thenThrow(exception).thenReturn(true);
+    when(fs.rename(same(source), 
same(destination))).thenThrow(exception).thenReturn(true);
+    
when(fs.getContentSummary(same(source))).thenThrow(exception).thenReturn(cs);
+
+    CopyUtils copyUtils = new 
CopyUtils(UserGroupInformation.getCurrentUser().getUserName(), conf, fs);
+    CopyUtils copyUtilsSpy = Mockito.spy(copyUtils);
+    try {
+      copyUtilsSpy.exists(fs, source);
+    } catch (Exception e) {
+      assertEquals(exception.getClass(), e.getCause().getClass());
+    }
+    Mockito.verify(fs, Mockito.times(1)).exists(source);
+    try {

Review comment:
       Check if you can use
   ``LambdaTestUtils.intercept`` instead of try-catch




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