From ba66ca6856bb4fc8bba786a59051517f19b15d8f Mon Sep 17 00:00:00 2001 From: Jitendra Nath Pandey Date: Wed, 19 Oct 2011 21:52:50 +0000 Subject: [PATCH] MAPREDUCE-3149. Add a test to verify that TokenCache handles file system uri with no authority. Contributed by John George. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1186516 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-mapreduce-project/CHANGES.txt | 3 +++ .../mapreduce/security/TestTokenCache.java | 26 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/hadoop-mapreduce-project/CHANGES.txt b/hadoop-mapreduce-project/CHANGES.txt index 0eaec390d5f..31ca64fb06b 100644 --- a/hadoop-mapreduce-project/CHANGES.txt +++ b/hadoop-mapreduce-project/CHANGES.txt @@ -25,6 +25,9 @@ Trunk (unreleased changes) MAPREDUCE-3171. normalize nodemanager native code compilation with common/hdfs native. (tucu) + MAPREDUCE-3149. Add a test to verify that TokenCache handles file system + uri with no authority. (John George via jitendra) + BUG FIXES MAPREDUCE-3166. [Rumen] Make Rumen use job history api instead of relying diff --git a/hadoop-mapreduce-project/src/test/mapred/org/apache/hadoop/mapreduce/security/TestTokenCache.java b/hadoop-mapreduce-project/src/test/mapred/org/apache/hadoop/mapreduce/security/TestTokenCache.java index 3a769e7dd19..8661f41e99a 100644 --- a/hadoop-mapreduce-project/src/test/mapred/org/apache/hadoop/mapreduce/security/TestTokenCache.java +++ b/hadoop-mapreduce-project/src/test/mapred/org/apache/hadoop/mapreduce/security/TestTokenCache.java @@ -63,6 +63,7 @@ import org.apache.hadoop.security.Credentials; import org.apache.hadoop.security.SecurityUtil; import org.apache.hadoop.security.token.Token; import org.apache.hadoop.security.token.TokenIdentifier; +import org.apache.hadoop.tools.HadoopArchives; import org.apache.hadoop.util.ToolRunner; import org.codehaus.jackson.map.ObjectMapper; import org.junit.AfterClass; @@ -428,4 +429,29 @@ public class TestTokenCache { assertTrue("didn't find token for [" + lp1 + ", " + lp2 + "]", found); } } + + @Test + public void testGetTokensForUriWithoutAuth() throws IOException { + FileSystem fs = dfsCluster.getFileSystem(); + HadoopArchives har = new HadoopArchives(jConf); + Path archivePath = new Path(fs.getHomeDirectory(), "tmp"); + String[] args = new String[6]; + args[0] = "-archiveName"; + args[1] = "foo1.har"; + args[2] = "-p"; + args[3] = fs.getHomeDirectory().toString(); + args[4] = "test"; + args[5] = archivePath.toString(); + try { + int ret = ToolRunner.run(har, args); + } catch (Exception e) { + fail("Could not create har file"); + } + Path finalPath = new Path(archivePath, "foo1.har"); + Path filePath = new Path(finalPath, "test"); + + Credentials credentials = new Credentials(); + TokenCache.obtainTokensForNamenodesInternal( + credentials, new Path [] {finalPath}, jConf); + } }