@@ -53,7 +53,7 @@ public class ITestAzureBlobFileSystemCheckAccess
5353
5454 private static final String TEST_FOLDER_PATH = "CheckAccessTestFolder" ;
5555 private final FileSystem superUserFs ;
56- private final FileSystem testUserFs ;
56+ private FileSystem testUserFs ;
5757 private final String testUserGuid ;
5858 private final boolean isCheckAccessEnabled ;
5959 private final boolean isHNSEnabled ;
@@ -63,13 +63,15 @@ public ITestAzureBlobFileSystemCheckAccess() throws Exception {
6363 this .superUserFs = getFileSystem ();
6464 testUserGuid = getConfiguration ()
6565 .get (FS_AZURE_BLOB_FS_CHECKACCESS_TEST_USER_GUID );
66- this .testUserFs = getTestUserFs ();
6766 this .isCheckAccessEnabled = getConfiguration ().isCheckAccessEnabled ();
6867 this .isHNSEnabled = getConfiguration ()
6968 .getBoolean (FS_AZURE_TEST_NAMESPACE_ENABLED_ACCOUNT , false );
7069 }
7170
72- private FileSystem getTestUserFs () throws Exception {
71+ private void setTestUserFs () throws Exception {
72+ if (this .testUserFs != null ) {
73+ return ;
74+ }
7375 String orgClientId = getConfiguration ().get (FS_AZURE_BLOB_FS_CLIENT_ID );
7476 String orgClientSecret = getConfiguration ()
7577 .get (FS_AZURE_BLOB_FS_CLIENT_SECRET );
@@ -88,7 +90,7 @@ private FileSystem getTestUserFs() throws Exception {
8890 getRawConfiguration ()
8991 .setBoolean (AZURE_CREATE_REMOTE_FILESYSTEM_DURING_INITIALIZATION ,
9092 orgCreateFileSystemDurungInit );
91- return fs ;
93+ this . testUserFs = fs ;
9294 }
9395
9496 @ Test (expected = IllegalArgumentException .class )
@@ -106,6 +108,7 @@ public void testCheckAccessForFileWithNullFsAction() throws Exception {
106108 @ Test (expected = FileNotFoundException .class )
107109 public void testCheckAccessForNonExistentFile () throws Exception {
108110 assumeHNSAndCheckAccessEnabled ();
111+ setTestUserFs ();
109112 Path nonExistentFile = setupTestDirectoryAndUserAccess (
110113 "/nonExistentFile1.txt" , FsAction .ALL );
111114 superUserFs .delete (nonExistentFile , true );
@@ -149,12 +152,16 @@ public void testCheckAccessForAccountWithoutNS() throws Exception {
149152 Assume .assumeFalse (FS_AZURE_TEST_NAMESPACE_ENABLED_ACCOUNT + " is true" ,
150153 getConfiguration ()
151154 .getBoolean (FS_AZURE_TEST_NAMESPACE_ENABLED_ACCOUNT , true ));
155+ Assume .assumeTrue (FS_AZURE_ENABLE_CHECK_ACCESS + " is false" ,
156+ isCheckAccessEnabled );
157+ setTestUserFs ();
152158 testUserFs .access (new Path ("/" ), FsAction .READ );
153159 }
154160
155161 @ Test
156162 public void testFsActionNONE () throws Exception {
157163 assumeHNSAndCheckAccessEnabled ();
164+ setTestUserFs ();
158165 Path testFilePath = setupTestDirectoryAndUserAccess ("/test2.txt" ,
159166 FsAction .NONE );
160167 assertInaccessible (testFilePath , FsAction .EXECUTE );
@@ -169,6 +176,7 @@ public void testFsActionNONE() throws Exception {
169176 @ Test
170177 public void testFsActionEXECUTE () throws Exception {
171178 assumeHNSAndCheckAccessEnabled ();
179+ setTestUserFs ();
172180 Path testFilePath = setupTestDirectoryAndUserAccess ("/test3.txt" ,
173181 FsAction .EXECUTE );
174182 assertAccessible (testFilePath , FsAction .EXECUTE );
@@ -184,6 +192,7 @@ public void testFsActionEXECUTE() throws Exception {
184192 @ Test
185193 public void testFsActionREAD () throws Exception {
186194 assumeHNSAndCheckAccessEnabled ();
195+ setTestUserFs ();
187196 Path testFilePath = setupTestDirectoryAndUserAccess ("/test4.txt" ,
188197 FsAction .READ );
189198 assertAccessible (testFilePath , FsAction .READ );
@@ -199,6 +208,7 @@ public void testFsActionREAD() throws Exception {
199208 @ Test
200209 public void testFsActionWRITE () throws Exception {
201210 assumeHNSAndCheckAccessEnabled ();
211+ setTestUserFs ();
202212 Path testFilePath = setupTestDirectoryAndUserAccess ("/test5.txt" ,
203213 FsAction .WRITE );
204214 assertAccessible (testFilePath , FsAction .WRITE );
@@ -214,6 +224,7 @@ public void testFsActionWRITE() throws Exception {
214224 @ Test
215225 public void testFsActionREADEXECUTE () throws Exception {
216226 assumeHNSAndCheckAccessEnabled ();
227+ setTestUserFs ();
217228 Path testFilePath = setupTestDirectoryAndUserAccess ("/test6.txt" ,
218229 FsAction .READ_EXECUTE );
219230 assertAccessible (testFilePath , FsAction .EXECUTE );
@@ -229,6 +240,7 @@ public void testFsActionREADEXECUTE() throws Exception {
229240 @ Test
230241 public void testFsActionWRITEEXECUTE () throws Exception {
231242 assumeHNSAndCheckAccessEnabled ();
243+ setTestUserFs ();
232244 Path testFilePath = setupTestDirectoryAndUserAccess ("/test7.txt" ,
233245 FsAction .WRITE_EXECUTE );
234246 assertAccessible (testFilePath , FsAction .EXECUTE );
@@ -244,6 +256,7 @@ public void testFsActionWRITEEXECUTE() throws Exception {
244256 @ Test
245257 public void testFsActionALL () throws Exception {
246258 assumeHNSAndCheckAccessEnabled ();
259+ setTestUserFs ();
247260 Path testFilePath = setupTestDirectoryAndUserAccess ("/test8.txt" ,
248261 FsAction .ALL );
249262 assertAccessible (testFilePath , FsAction .EXECUTE );
0 commit comments