From 084bdab156fd08b61484c992e25ce964b46568e8 Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Tue, 25 Oct 2016 15:35:39 -0700 Subject: [PATCH] HDFS-5684. Annotate o.a.h.fs.viewfs.ViewFileSystem.MountPoint as VisibleForTesting. Contributed by Manoj Govindassamy. --- .../org/apache/hadoop/fs/viewfs/ViewFileSystem.java | 5 +++++ .../hadoop/fs/viewfs/ViewFileSystemBaseTest.java | 11 +++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java index ef224d81190..acafc6c9771 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java @@ -32,6 +32,7 @@ import java.util.Map; import java.util.Set; import java.util.Map.Entry; +import com.google.common.annotations.VisibleForTesting; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.conf.Configuration; @@ -104,9 +105,13 @@ public class ViewFileSystem extends FileSystem { src = srcPath; targets = targetURIs; } + + @VisibleForTesting Path getSrc() { return src; } + + @VisibleForTesting URI[] getTargets() { return targets; } diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java index 02d4fd60c83..9ec150f5ac1 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java @@ -24,6 +24,7 @@ import java.util.Collection; import java.util.List; import java.util.ArrayList; +import com.google.common.base.Joiner; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.BlockLocation; import org.apache.hadoop.fs.BlockStoragePolicySpi; @@ -39,13 +40,13 @@ import org.apache.hadoop.fs.permission.AclStatus; import org.apache.hadoop.fs.permission.AclUtil; import org.apache.hadoop.fs.permission.FsAction; import org.apache.hadoop.fs.permission.FsPermission; -import org.apache.hadoop.fs.viewfs.ConfigUtil; import org.apache.hadoop.fs.viewfs.ViewFileSystem.MountPoint; -import org.apache.hadoop.fs.viewfs.ViewFileSystem; import org.apache.hadoop.security.AccessControlException; import org.apache.hadoop.security.Credentials; import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.security.token.Token; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import static org.apache.hadoop.fs.FileSystemTestHelper.*; import static org.apache.hadoop.fs.viewfs.Constants.PERMISSION_555; @@ -82,6 +83,8 @@ abstract public class ViewFileSystemBaseTest { Path targetTestRoot; Configuration conf; final FileSystemTestHelper fileSystemTestHelper; + private static final Logger LOG = + LoggerFactory.getLogger(ViewFileSystemBaseTest.class); public ViewFileSystemBaseTest() { this.fileSystemTestHelper = createFileSystemHelper(); @@ -144,6 +147,10 @@ abstract public class ViewFileSystemBaseTest { public void testGetMountPoints() { ViewFileSystem viewfs = (ViewFileSystem) fsView; MountPoint[] mountPoints = viewfs.getMountPoints(); + for (MountPoint mountPoint : mountPoints) { + LOG.info("MountPoint: " + mountPoint.getSrc() + " => " + + Joiner.on(",").join(mountPoint.getTargets())); + } Assert.assertEquals(getExpectedMountPoints(), mountPoints.length); }