You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sentry.apache.org by sh...@apache.org on 2013/11/05 23:05:16 UTC

git commit: SENTRY-51: kinit before hdfs file system operations does not work in hive e2e tests (Sravya Tirukkovalur via Shreepadma Venugopalan)

Updated Branches:
  refs/heads/master 1001b70e1 -> 626149e91


SENTRY-51: kinit before hdfs file system operations does not work in hive e2e tests (Sravya Tirukkovalur via Shreepadma Venugopalan)


Project: http://git-wip-us.apache.org/repos/asf/incubator-sentry/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-sentry/commit/626149e9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-sentry/tree/626149e9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-sentry/diff/626149e9

Branch: refs/heads/master
Commit: 626149e913eafefb0fe82f8094c96a8a1dd2ac53
Parents: 1001b70
Author: Shreepadma Venugopalan <sh...@apache.org>
Authored: Tue Nov 5 14:03:49 2013 -0800
Committer: Shreepadma Venugopalan <sh...@apache.org>
Committed: Tue Nov 5 14:03:49 2013 -0800

----------------------------------------------------------------------
 .../sentry/tests/e2e/hive/fs/ClusterDFS.java    | 24 +++++++++-----------
 1 file changed, 11 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/626149e9/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/fs/ClusterDFS.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/fs/ClusterDFS.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/fs/ClusterDFS.java
index 3641d04..cef8b42 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/fs/ClusterDFS.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/fs/ClusterDFS.java
@@ -34,12 +34,12 @@ public class ClusterDFS extends AbstractDFS{
   private static final String testUser = System.getProperty(TEST_USER, "hive");
   private static final String KEYTAB_LOCATION = System.getProperty("sentry.e2e.hive.keytabs.location");
   private Path sentryDir;
+  private UserGroupInformation ugi;
 
   ClusterDFS() throws Exception{
-    Configuration conf = new Configuration();
-    fileSystem = FileSystem.get(conf);
+    ugi = UserGroupInformation.loginUserFromKeytabAndReturnUGI(testUser, KEYTAB_LOCATION + "/" + testUser + ".keytab");
+    fileSystem = getFS(ugi);
     LOGGER.info("Creating basedir as user : " + testUser);
-    kinit(testUser);
     String policyDir = System.getProperty("sentry.e2etest.hive.policy.location", "/user/hive/sentry");
     sentryDir = assertCreateDir(policyDir);
     dfsBaseDir = assertCreateDir("/tmp/" + (new Random()).nextInt());
@@ -47,7 +47,6 @@ public class ClusterDFS extends AbstractDFS{
 
   @Override
   public Path assertCreateDir(String path) throws Exception{
-    kinit(testUser);
     if(path.startsWith("/")){
       return super.assertCreateDfsDir(new Path(path));
     }else {
@@ -57,16 +56,15 @@ public class ClusterDFS extends AbstractDFS{
 
   @Override
   protected void cleanBaseDir() throws Exception {
-    kinit(testUser);
     super.cleanBaseDir();
     super.cleanDir(sentryDir);
   }
-  @Override
-  public void createBaseDir() throws Exception {
-    kinit(testUser);
-    super.createBaseDir();
-  }
-  public void kinit(String user) throws Exception{
-    UserGroupInformation.loginUserFromKeytab(user, KEYTAB_LOCATION + "/" + user + ".keytab");
+  private FileSystem getFS(UserGroupInformation ugi) throws Exception {
+    return ugi.doAs(new PrivilegedExceptionAction<FileSystem>() {
+      public FileSystem run() throws Exception {
+        Configuration conf = new Configuration();
+        return FileSystem.get(conf);
+      }
+    });
   }
-}
+}
\ No newline at end of file