-
Notifications
You must be signed in to change notification settings - Fork 9.2k
MAPREDUCE-7375 JobSubmissionFiles don't set right permission after mkdirs #4237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
4c06114
a272117
9896814
c075f59
98a9ffe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,8 @@ | |
| import static org.mockito.Mockito.mock; | ||
| import static org.mockito.Mockito.when; | ||
|
|
||
| import org.apache.hadoop.hdfs.MiniDFSCluster; | ||
| import org.apache.hadoop.hdfs.HdfsConfiguration; | ||
| /** | ||
| * Tests for JobSubmissionFiles Utility class. | ||
| */ | ||
|
|
@@ -139,4 +141,19 @@ public void testGetStagingDirWhenShortFileOwnerNameAndShortUserName() | |
| assertEquals(stagingPath, | ||
| JobSubmissionFiles.getStagingDir(cluster, conf, user)); | ||
| } | ||
|
|
||
| @Test | ||
| public void testDirPermission() throws Exception { | ||
cnauroth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Cluster cluster = mock(Cluster.class); | ||
| HdfsConfiguration CONF = new HdfsConfiguration(); | ||
|
||
| MiniDFSCluster cluster1 = new MiniDFSCluster.Builder(CONF).numDataNodes(2).build(); | ||
|
||
| FileSystem fs = cluster1.getFileSystem(); | ||
| UserGroupInformation user = UserGroupInformation | ||
| .createUserForTesting(USER_1_SHORT_NAME, GROUP_NAMES); | ||
| Path stagingPath = new Path(fs.getUri().toString() + "/testDirPermission"); | ||
|
|
||
| when(cluster.getStagingAreaDir()).thenReturn(stagingPath); | ||
| Path res = JobSubmissionFiles.getStagingDir(cluster, CONF, user); | ||
| assertEquals(new FsPermission(0700),fs.getFileStatus(res).getPermission()); | ||
|
||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest using static method
FileSystem.mkdirs(fs, stagingArea, new FsPermission(JOB_DIR_PERMISSION)). It's one less line of code and potentially one less remote call for certainFileSystemimplementations.