File tree Expand file tree Collapse file tree 4 files changed +35
-11
lines changed
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs Expand file tree Collapse file tree 4 files changed +35
-11
lines changed Original file line number Diff line number Diff line change 3333import org .apache .hadoop .fs .FileStatus ;
3434import org .apache .hadoop .fs .FileSystem ;
3535import org .apache .hadoop .fs .Path ;
36+ import static org .apache .hadoop .fs .FileSystem .TRASH_PREFIX ;
37+ import org .apache .hadoop .security .UserGroupInformation ;
3638
3739import org .junit .After ;
3840import org .junit .Before ;
@@ -61,6 +63,13 @@ public void setUp() throws Exception {
6163
6264 }
6365
66+ @ Override
67+ Path getTrashRootInFallBackFS () throws IOException {
68+ return new Path (
69+ "/" + TRASH_PREFIX + "/" + UserGroupInformation .getCurrentUser ()
70+ .getShortUserName ());
71+ }
72+
6473 @ Test
6574 public void testNflyWriteSimple () throws IOException {
6675 LOG .info ("Starting testNflyWriteSimple" );
Original file line number Diff line number Diff line change 2525import org .apache .hadoop .fs .FileSystemTestHelper ;
2626import org .apache .hadoop .fs .FsConstants ;
2727import org .apache .hadoop .fs .Path ;
28+ import static org .apache .hadoop .fs .FileSystem .TRASH_PREFIX ;
29+ import org .apache .hadoop .security .UserGroupInformation ;
30+ import java .io .IOException ;
2831
2932import org .junit .After ;
3033import org .junit .Assert ;
@@ -63,6 +66,13 @@ public void tearDown() throws Exception {
6366 super .tearDown ();
6467 }
6568
69+ @ Override
70+ Path getTrashRootInFallBackFS () throws IOException {
71+ return new Path (
72+ "/" + TRASH_PREFIX + "/" + UserGroupInformation .getCurrentUser ()
73+ .getShortUserName ());
74+ }
75+
6676 @ Override
6777 @ Test
6878 public void testBasicPaths () {
Original file line number Diff line number Diff line change @@ -1104,9 +1104,13 @@ public void testTrashRoot() throws IOException {
11041104 Assert .assertTrue ("" , fsView .getTrashRoots (true ).size () > 0 );
11051105 }
11061106
1107- private String getTrashRootForPathInFallBackFS () {
1108- return fsTarget .getHomeDirectory ().toUri ().getPath () + "/" + TRASH_PREFIX ;
1107+ // Default implementation of getTrashRoot for a fallback FS mounted at root:
1108+ // e.g., fallbackFS.uri.getPath = '/'
1109+ Path getTrashRootInFallBackFS () throws IOException {
1110+ return new Path (fsTarget .getHomeDirectory ().toUri ().getPath (),
1111+ TRASH_PREFIX );
11091112 }
1113+
11101114 /**
11111115 * Test TRASH_FORCE_INSIDE_MOUNT_POINT feature for getTrashRoot.
11121116 */
@@ -1128,15 +1132,8 @@ public void testTrashRootForceInsideMountPoint() throws IOException {
11281132 // Case 2: path p not found in mount table, fall back to the default FS
11291133 // Return a trash root in mount point "/"
11301134 Path nonExistentPath = new Path ("/nonExistentDir/nonExistentFile" );
1131- Path expectedTrash ;
1132- if (targetTestRoot .toUri ().getPath ().equals ("/" )) {
1133- expectedTrash =
1134- fsView2 .makeQualified (new Path (fsTarget .getHomeDirectory ().toUri ().getPath (),
1135- TRASH_PREFIX ));
1136- } else {
1137- expectedTrash =
1138- fsView2 .makeQualified (new Path ("/" + TRASH_PREFIX + "/" + ugi .getShortUserName ()));
1139- }
1135+ Path expectedTrash =
1136+ fsView2 .makeQualified (getTrashRootInFallBackFS ());
11401137
11411138 Assert .assertEquals (expectedTrash , fsView2 .getTrashRoot (nonExistentPath ));
11421139
Original file line number Diff line number Diff line change 5555import org .apache .hadoop .test .GenericTestUtils ;
5656import static org .apache .hadoop .fs .CommonConfigurationKeysPublic .FS_TRASH_INTERVAL_KEY ;
5757import static org .apache .hadoop .fs .CommonConfigurationKeysPublic .IPC_CLIENT_CONNECT_MAX_RETRIES_KEY ;
58+ import static org .apache .hadoop .fs .FileSystem .TRASH_PREFIX ;
5859
5960import org .junit .After ;
6061import org .junit .AfterClass ;
@@ -181,6 +182,13 @@ int getExpectedDelegationTokenCountWithCredentials() {
181182 return 2 ;
182183 }
183184
185+ @ Override
186+ Path getTrashRootInFallBackFS () throws IOException {
187+ return new Path (
188+ "/" + TRASH_PREFIX + "/" + UserGroupInformation .getCurrentUser ()
189+ .getShortUserName ());
190+ }
191+
184192 @ Test
185193 public void testTrashRootsAfterEncryptionZoneDeletion () throws Exception {
186194 final Path zone = new Path ("/EZ" );
You can’t perform that action at this time.
0 commit comments