[ 
https://issues.apache.org/jira/browse/HADOOP-18122?focusedWorklogId=731355&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-731355
 ]

ASF GitHub Bot logged work on HADOOP-18122:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 23/Feb/22 05:09
            Start Date: 23/Feb/22 05:09
    Worklog Time Spent: 10m 
      Work Description: ayushtkn commented on a change in pull request #3987:
URL: https://github.com/apache/hadoop/pull/3987#discussion_r812563504



##########
File path: 
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java
##########
@@ -1671,4 +1675,62 @@ public void 
testTargetFileSystemLazyInitializationForChecksumMethods()
     // viewfs inner cache is disabled
     assertEquals(cacheSize + 1, TestFileUtil.getCacheSize());
   }
+
+  @Test
+  public void testInternalDirectoryOwnership() throws IOException {
+    Configuration localConf = new Configuration(conf);
+    FileSystem fs = FileSystem.get(FsConstants.VIEWFS_URI, localConf);
+
+    // Check default owner/group.
+    final UserGroupInformation currentUser =
+        UserGroupInformation.getCurrentUser();
+    FileStatus status = fs.getFileStatus(new Path("/internalDir"));
+    assertEquals(currentUser.getUserName(), status.getOwner());
+    assertEquals(currentUser.getGroupNames()[0], status.getGroup());
+    assertEquals(PERMISSION_555, status.getPermission());
+
+    UserGroupInformation currUgi = UserGroupInformation.getCurrentUser();
+    try {
+      // Force exception when currUgi.getPrimaryGroupName() is called. This 
will
+      // not be triggered when viewfs mount link configs are defined.
+      UserGroupInformation spyUgi = spy(currUgi);
+      String failureMessage = "Fail on group check";
+      when(spyUgi.getPrimaryGroupName()).thenThrow(
+          new IOException(failureMessage));
+      UserGroupInformation.setLoginUser(spyUgi);
+
+      fs = FileSystem.get(FsConstants.VIEWFS_URI, localConf);
+      try {
+        // Exception triggered as currUgi.getPrimaryGroupName() is called.
+        fs.getFileStatus(new Path("/internalDir"));
+        fail("IOException expected");
+      } catch (IOException e) {
+        assertEquals(failureMessage, e.getMessage());
+      }

Review comment:
       Use `LambdaTestUtils.intercept` instead




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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 731355)
    Time Spent: 1h 40m  (was: 1.5h)

> ViewFileSystem fails on determining owning group when primary group doesn't 
> exist for user
> ------------------------------------------------------------------------------------------
>
>                 Key: HADOOP-18122
>                 URL: https://issues.apache.org/jira/browse/HADOOP-18122
>             Project: Hadoop Common
>          Issue Type: Bug
>            Reporter: Chentao Yu
>            Assignee: Chentao Yu
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 1h 40m
>  Remaining Estimate: 0h
>
> ViewFileSystem should not fail on determining owning group when primary group 
> doesn't exist for user



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to