From 3af44a310d8e55adf9d5dc850ce77a0651de0717 Mon Sep 17 00:00:00 2001 From: Suresh Srinivas Date: Thu, 5 Jan 2012 18:59:26 +0000 Subject: [PATCH] HDFS-2710. Add HDFS tests related to HADOOP-7933. Contributed by Siddarth Seth. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23@1227759 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 + .../fs/viewfs/TestViewFileSystemHdfs.java | 65 +++++++++++++------ 2 files changed, 49 insertions(+), 19 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 153514bd6d6..0095f4511de 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -65,6 +65,9 @@ Release 0.23.1 - UNRELEASED HDFS-2722. HttpFs should not be using an int for block size. (harsh) + HDFS-2710. Add HDFS tests related to HADOOP-7933. (Siddarth Seth via + suresh) + OPTIMIZATIONS HDFS-2130. Switch default checksum to CRC32C. (todd) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemHdfs.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemHdfs.java index 66b8fa32a3e..83115edaad4 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemHdfs.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemHdfs.java @@ -20,44 +20,54 @@ package org.apache.hadoop.fs.viewfs; import java.io.IOException; import java.net.URISyntaxException; -import java.util.List; import javax.security.auth.login.LoginException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.FileSystemTestHelper; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hdfs.MiniDFSCluster; import org.apache.hadoop.hdfs.server.namenode.NameNodeAdapter; import org.apache.hadoop.security.UserGroupInformation; -import org.apache.hadoop.security.token.Token; - import org.junit.After; import org.junit.AfterClass; -import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; -import org.junit.Test; public class TestViewFileSystemHdfs extends ViewFileSystemBaseTest { private static MiniDFSCluster cluster; private static Path defaultWorkingDirectory; + private static Path defaultWorkingDirectory2; private static Configuration CONF = new Configuration(); private static FileSystem fHdfs; + private static FileSystem fHdfs2; + private FileSystem fsTarget2; + Path targetTestRoot2; @BeforeClass public static void clusterSetupAtBegining() throws IOException, LoginException, URISyntaxException { SupportsBlocks = true; - cluster = new MiniDFSCluster.Builder(CONF).numDataNodes(2).build(); + cluster = + new MiniDFSCluster.Builder(CONF).numNameNodes(2).numDataNodes(2) + .build(); cluster.waitClusterUp(); - NameNodeAdapter.getDtSecretManager(cluster.getNamesystem()).startThreads(); - fHdfs = cluster.getFileSystem(); + NameNodeAdapter.getDtSecretManager(cluster.getNamesystem(0)).startThreads(); + NameNodeAdapter.getDtSecretManager(cluster.getNamesystem(1)).startThreads(); + + fHdfs = cluster.getFileSystem(0); + fHdfs2 = cluster.getFileSystem(1); + defaultWorkingDirectory = fHdfs.makeQualified( new Path("/user/" + UserGroupInformation.getCurrentUser().getShortUserName())); + defaultWorkingDirectory2 = fHdfs2.makeQualified( new Path("/user/" + + UserGroupInformation.getCurrentUser().getShortUserName())); + fHdfs.mkdirs(defaultWorkingDirectory); + fHdfs2.mkdirs(defaultWorkingDirectory2); } @@ -70,25 +80,42 @@ public class TestViewFileSystemHdfs extends ViewFileSystemBaseTest { public void setUp() throws Exception { // create the test root on local_fs fsTarget = fHdfs; + fsTarget2 = fHdfs2; + targetTestRoot2 = FileSystemTestHelper.getAbsoluteTestRootPath(fsTarget2); super.setUp(); - } @After public void tearDown() throws Exception { super.tearDown(); } - - /* - * This overides the default implementation since hdfs does have delegation - * tokens. - */ + @Override - @Test - public void testGetDelegationTokens() throws IOException { - List> delTokens = - fsView.getDelegationTokens("sanjay"); - Assert.assertEquals(7, delTokens.size()); + void setupMountPoints() { + super.setupMountPoints(); + ConfigUtil.addLink(conf, "/mountOnNn2", new Path(targetTestRoot2, + "mountOnNn2").toUri()); } + // Overriden test helper methods - changed values based on hdfs and the + // additional mount. + @Override + int getExpectedDirPaths() { + return 7; + } + + @Override + int getExpectedMountPoints() { + return 8; + } + + @Override + int getExpectedDelegationTokenCount() { + return 8; + } + + @Override + int getExpectedDelegationTokenCountWithCredentials() { + return 2; + } }