-
Notifications
You must be signed in to change notification settings - Fork 9.2k
HADOOP-16825: Checkaccess testcase fix #1821
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 4 commits
729f44e
49abe9c
6954c0c
331a203
72aea97
195023b
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 |
|---|---|---|
|
|
@@ -53,7 +53,7 @@ public class ITestAzureBlobFileSystemCheckAccess | |
|
|
||
| private static final String TEST_FOLDER_PATH = "CheckAccessTestFolder"; | ||
| private final FileSystem superUserFs; | ||
| private final FileSystem testUserFs; | ||
| private FileSystem testUserFs; | ||
| private final String testUserGuid; | ||
| private final boolean isCheckAccessEnabled; | ||
| private final boolean isHNSEnabled; | ||
|
|
@@ -63,13 +63,15 @@ public ITestAzureBlobFileSystemCheckAccess() throws Exception { | |
| this.superUserFs = getFileSystem(); | ||
| testUserGuid = getConfiguration() | ||
| .get(FS_AZURE_BLOB_FS_CHECKACCESS_TEST_USER_GUID); | ||
| this.testUserFs = getTestUserFs(); | ||
| this.isCheckAccessEnabled = getConfiguration().isCheckAccessEnabled(); | ||
| this.isHNSEnabled = getConfiguration() | ||
| .getBoolean(FS_AZURE_TEST_NAMESPACE_ENABLED_ACCOUNT, false); | ||
| } | ||
|
|
||
| private FileSystem getTestUserFs() throws Exception { | ||
| private void setTestUserFs() throws Exception { | ||
| if(this.testUserFs != null) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: please add a space between if and (.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
| return; | ||
| } | ||
| String orgClientId = getConfiguration().get(FS_AZURE_BLOB_FS_CLIENT_ID); | ||
| String orgClientSecret = getConfiguration() | ||
| .get(FS_AZURE_BLOB_FS_CLIENT_SECRET); | ||
|
|
@@ -88,11 +90,12 @@ private FileSystem getTestUserFs() throws Exception { | |
| getRawConfiguration() | ||
| .setBoolean(AZURE_CREATE_REMOTE_FILESYSTEM_DURING_INITIALIZATION, | ||
| orgCreateFileSystemDurungInit); | ||
| return fs; | ||
| this.testUserFs = fs; | ||
| } | ||
|
|
||
| @Test(expected = IllegalArgumentException.class) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is expected to throw IllegalArgumentException.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
| @Test | ||
| public void testCheckAccessWithNullPath() throws IOException { | ||
| assumeHNSAndCheckAccessEnabled(); | ||
| superUserFs.access(null, FsAction.READ); | ||
| } | ||
|
|
||
|
|
@@ -106,6 +109,7 @@ public void testCheckAccessForFileWithNullFsAction() throws Exception { | |
| @Test(expected = FileNotFoundException.class) | ||
| public void testCheckAccessForNonExistentFile() throws Exception { | ||
| assumeHNSAndCheckAccessEnabled(); | ||
| setTestUserFs(); | ||
| Path nonExistentFile = setupTestDirectoryAndUserAccess( | ||
| "/nonExistentFile1.txt", FsAction.ALL); | ||
| superUserFs.delete(nonExistentFile, true); | ||
|
|
@@ -121,6 +125,7 @@ public void testWhenCheckAccessConfigIsOff() throws Exception { | |
| FileSystem fs = FileSystem.newInstance(conf); | ||
| Path testFilePath = setupTestDirectoryAndUserAccess("/test1.txt", | ||
| FsAction.NONE); | ||
| fs.access(null, FsAction.READ); | ||
| fs.access(testFilePath, FsAction.EXECUTE); | ||
| fs.access(testFilePath, FsAction.READ); | ||
| fs.access(testFilePath, FsAction.WRITE); | ||
|
|
@@ -149,12 +154,16 @@ public void testCheckAccessForAccountWithoutNS() throws Exception { | |
| Assume.assumeFalse(FS_AZURE_TEST_NAMESPACE_ENABLED_ACCOUNT + " is true", | ||
| getConfiguration() | ||
| .getBoolean(FS_AZURE_TEST_NAMESPACE_ENABLED_ACCOUNT, true)); | ||
| Assume.assumeTrue(FS_AZURE_ENABLE_CHECK_ACCESS + " is false", | ||
| isCheckAccessEnabled); | ||
| setTestUserFs(); | ||
| testUserFs.access(new Path("/"), FsAction.READ); | ||
| } | ||
|
|
||
| @Test | ||
| public void testFsActionNONE() throws Exception { | ||
| assumeHNSAndCheckAccessEnabled(); | ||
| setTestUserFs(); | ||
| Path testFilePath = setupTestDirectoryAndUserAccess("/test2.txt", | ||
| FsAction.NONE); | ||
| assertInaccessible(testFilePath, FsAction.EXECUTE); | ||
|
|
@@ -169,6 +178,7 @@ public void testFsActionNONE() throws Exception { | |
| @Test | ||
| public void testFsActionEXECUTE() throws Exception { | ||
| assumeHNSAndCheckAccessEnabled(); | ||
| setTestUserFs(); | ||
| Path testFilePath = setupTestDirectoryAndUserAccess("/test3.txt", | ||
| FsAction.EXECUTE); | ||
| assertAccessible(testFilePath, FsAction.EXECUTE); | ||
|
|
@@ -184,6 +194,7 @@ public void testFsActionEXECUTE() throws Exception { | |
| @Test | ||
| public void testFsActionREAD() throws Exception { | ||
| assumeHNSAndCheckAccessEnabled(); | ||
| setTestUserFs(); | ||
| Path testFilePath = setupTestDirectoryAndUserAccess("/test4.txt", | ||
| FsAction.READ); | ||
| assertAccessible(testFilePath, FsAction.READ); | ||
|
|
@@ -199,6 +210,7 @@ public void testFsActionREAD() throws Exception { | |
| @Test | ||
| public void testFsActionWRITE() throws Exception { | ||
| assumeHNSAndCheckAccessEnabled(); | ||
| setTestUserFs(); | ||
| Path testFilePath = setupTestDirectoryAndUserAccess("/test5.txt", | ||
| FsAction.WRITE); | ||
| assertAccessible(testFilePath, FsAction.WRITE); | ||
|
|
@@ -214,6 +226,7 @@ public void testFsActionWRITE() throws Exception { | |
| @Test | ||
| public void testFsActionREADEXECUTE() throws Exception { | ||
| assumeHNSAndCheckAccessEnabled(); | ||
| setTestUserFs(); | ||
| Path testFilePath = setupTestDirectoryAndUserAccess("/test6.txt", | ||
| FsAction.READ_EXECUTE); | ||
| assertAccessible(testFilePath, FsAction.EXECUTE); | ||
|
|
@@ -229,6 +242,7 @@ public void testFsActionREADEXECUTE() throws Exception { | |
| @Test | ||
| public void testFsActionWRITEEXECUTE() throws Exception { | ||
| assumeHNSAndCheckAccessEnabled(); | ||
| setTestUserFs(); | ||
| Path testFilePath = setupTestDirectoryAndUserAccess("/test7.txt", | ||
| FsAction.WRITE_EXECUTE); | ||
| assertAccessible(testFilePath, FsAction.EXECUTE); | ||
|
|
@@ -244,6 +258,7 @@ public void testFsActionWRITEEXECUTE() throws Exception { | |
| @Test | ||
| public void testFsActionALL() throws Exception { | ||
| assumeHNSAndCheckAccessEnabled(); | ||
| setTestUserFs(); | ||
| Path testFilePath = setupTestDirectoryAndUserAccess("/test8.txt", | ||
| FsAction.ALL); | ||
| assertAccessible(testFilePath, FsAction.EXECUTE); | ||
|
|
||
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.
The original line 949 is correct. If path is null, FileSystem.access should throw IllegalArgumentException and that's what calling makeQualified(path) will do.
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.
Keeping it this way as we don't need to break the existing flow when the checkaccess flag is false.
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 don’t follow. What flow are you referring to? I think you should revert this line because null path should result in IllegalArgumentException. Calling makeQualified is a standard thing done by all the APIs taking a Path.
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.
Removing the addition as discussed.