You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sentry.apache.org by ls...@apache.org on 2014/11/20 20:14:38 UTC

incubator-sentry git commit: SENTRY-534: TestRuntimeMetadataRetrieval fails intermittently

Repository: incubator-sentry
Updated Branches:
  refs/heads/master a8c878ab5 -> 4bf55b881


SENTRY-534: TestRuntimeMetadataRetrieval fails intermittently


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

Branch: refs/heads/master
Commit: 4bf55b881376abe1257678476150ca4c37c48596
Parents: a8c878a
Author: Lenni Kuff <ls...@cloudera.com>
Authored: Thu Nov 20 11:11:55 2014 -0800
Committer: Lenni Kuff <ls...@cloudera.com>
Committed: Thu Nov 20 11:11:55 2014 -0800

----------------------------------------------------------------------
 .../apache/sentry/provider/file/PolicyFile.java |  1 -
 .../AbstractTestWithStaticConfiguration.java    | 23 ++++++++++----------
 .../sentry/tests/e2e/hive/TestCrossDbOps.java   |  2 +-
 .../sentry/tests/e2e/hive/TestOperations.java   |  1 -
 .../e2e/hive/TestRuntimeMetadataRetrieval.java  |  4 +++-
 5 files changed, 15 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/4bf55b88/sentry-provider/sentry-provider-file/src/main/java/org/apache/sentry/provider/file/PolicyFile.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-file/src/main/java/org/apache/sentry/provider/file/PolicyFile.java b/sentry-provider/sentry-provider-file/src/main/java/org/apache/sentry/provider/file/PolicyFile.java
index f479ac7..32b2d72 100644
--- a/sentry-provider/sentry-provider-file/src/main/java/org/apache/sentry/provider/file/PolicyFile.java
+++ b/sentry-provider/sentry-provider-file/src/main/java/org/apache/sentry/provider/file/PolicyFile.java
@@ -146,7 +146,6 @@ public class PolicyFile {
             "");
     LOGGER.info("Writing policy file to " + file + ":\n" + contents);
     Files.write(contents, file, Charsets.UTF_8);
-
   }
 
   private String getSection(String name, Map<String, String> mapping) {

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/4bf55b88/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithStaticConfiguration.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithStaticConfiguration.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithStaticConfiguration.java
index 9aa03f8..ea19320 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithStaticConfiguration.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/AbstractTestWithStaticConfiguration.java
@@ -109,7 +109,7 @@ public abstract class AbstractTestWithStaticConfiguration {
   private static final String EXTERNAL_SENTRY_SERVICE = "sentry.e2etest.external.sentry";
   protected static final String EXTERNAL_HIVE_LIB = "sentry.e2etest.hive.lib";
 
-  protected static boolean policy_on_hdfs = false;
+  protected static boolean policyOnHdfs = false;
   protected static boolean useSentryService = false;
   protected static boolean setMetastoreListener = false;
   protected static String testServerType = null;
@@ -187,8 +187,8 @@ public abstract class AbstractTestWithStaticConfiguration {
   @BeforeClass
   public static void setupTestStaticConfiguration() throws Exception {
     properties = Maps.newHashMap();
-    if(!policy_on_hdfs) {
-      policy_on_hdfs = new Boolean(System.getProperty("sentry.e2etest.policyonhdfs", "false"));
+    if(!policyOnHdfs) {
+      policyOnHdfs = new Boolean(System.getProperty("sentry.e2etest.policyonhdfs", "false"));
     }
     if (testServerType != null) {
       properties.put("sentry.e2etest.hiveServer2Type", testServerType);
@@ -204,22 +204,21 @@ public abstract class AbstractTestWithStaticConfiguration {
     dfs = DFSFactory.create(dfsType, baseDir, testServerType);
     fileSystem = dfs.getFileSystem();
 
-    String policyURI;
-
-    //TODO: We can probably get rid of this.
     PolicyFile policyFile = PolicyFile.setAdminOnServer1(ADMIN1)
         .setUserGroupMapping(StaticUserGroup.getStaticMapping());
     policyFile.write(policyFileLocation);
-
-    if (policy_on_hdfs) {
-      String dfsUri = fileSystem.getDefaultUri(fileSystem.getConf()).toString();
+    
+    String policyURI;
+    if (policyOnHdfs) {
+      String dfsUri = FileSystem.getDefaultUri(fileSystem.getConf()).toString();
       LOGGER.error("dfsUri " + dfsUri);
-      policyURI = dfsUri + System.getProperty("sentry.e2etest.hive.policy.location", "/user/hive/sentry");
+      policyURI = dfsUri + System.getProperty("sentry.e2etest.hive.policy.location",
+          "/user/hive/sentry");
       policyURI += "/" + HiveServerFactory.AUTHZ_PROVIDER_FILENAME;
-      dfs.writePolicyFile(policyFileLocation);
     } else {
       policyURI = policyFileLocation.getPath();
     }
+    
     boolean startSentry = new Boolean(System.getProperty(EXTERNAL_SENTRY_SERVICE, "false"));
     if (useSentryService && (!startSentry)) {
       setupSentryService();
@@ -248,7 +247,7 @@ public abstract class AbstractTestWithStaticConfiguration {
   protected void writePolicyFile(PolicyFile policyFile) throws Exception{
 
     policyFile.write(context.getPolicyFile());
-    if(policy_on_hdfs) {
+    if(policyOnHdfs) {
       dfs.writePolicyFile(context.getPolicyFile());
     } else if(useSentryService) {
       grantPermissions(policyFile);

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/4bf55b88/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestCrossDbOps.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestCrossDbOps.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestCrossDbOps.java
index 2fd0cd9..5d3a4f1 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestCrossDbOps.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestCrossDbOps.java
@@ -48,7 +48,7 @@ public class TestCrossDbOps extends AbstractTestWithStaticConfiguration {
 
   @BeforeClass
   public static void setupTestStaticConfiguration() throws Exception{
-    policy_on_hdfs = true;
+    policyOnHdfs = true;
     AbstractTestWithStaticConfiguration.setupTestStaticConfiguration();
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/4bf55b88/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestOperations.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestOperations.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestOperations.java
index 1a0ad68..bff372b 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestOperations.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestOperations.java
@@ -67,7 +67,6 @@ public class TestOperations extends AbstractTestWithStaticConfiguration {
     policyFile = PolicyFile.setAdminOnServer1(ADMINGROUP)
         .setUserGroupMapping(StaticUserGroup.getStaticMapping());
     writePolicyFile(policyFile);
-
   }
 
   private void adminCreate(String db, String table) throws Exception{

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/4bf55b88/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestRuntimeMetadataRetrieval.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestRuntimeMetadataRetrieval.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestRuntimeMetadataRetrieval.java
index e103465..c47686b 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestRuntimeMetadataRetrieval.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/TestRuntimeMetadataRetrieval.java
@@ -51,7 +51,9 @@ public class TestRuntimeMetadataRetrieval extends AbstractTestWithStaticConfigur
     FileOutputStream to = new FileOutputStream(dataFile);
     Resources.copy(Resources.getResource(SINGLE_TYPE_DATA_FILE_NAME), to);
     to.close();
-    policyFile = PolicyFile.setAdminOnServer1(ADMINGROUP);
+    policyFile = PolicyFile.setAdminOnServer1(ADMINGROUP)
+        .setUserGroupMapping(StaticUserGroup.getStaticMapping());
+    writePolicyFile(policyFile);
   }
 
   /**