You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sentry.apache.org by co...@apache.org on 2017/11/22 15:50:04 UTC

[2/9] sentry git commit: SENTRY-2052: Reduce TestSentryStore time by setting transaction retries to 1 and other refactors (Sergio Pena, reviewed by kalyan kumar kalvagadda, Na Li)

SENTRY-2052: Reduce TestSentryStore time by setting transaction retries to 1 and other refactors (Sergio Pena, reviewed by kalyan kumar kalvagadda, Na Li)


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

Branch: refs/heads/akolb-cli
Commit: 1860b946b90f8fa3c17d00a6b419deb583fd538f
Parents: 755e942
Author: Sergio Pena <se...@cloudera.com>
Authored: Mon Nov 20 17:44:55 2017 -0600
Committer: Sergio Pena <se...@cloudera.com>
Committed: Mon Nov 20 17:44:55 2017 -0600

----------------------------------------------------------------------
 .../db/service/persistent/TestSentryStore.java    | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sentry/blob/1860b946/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/persistent/TestSentryStore.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/persistent/TestSentryStore.java b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/persistent/TestSentryStore.java
index 90f35f1..24b11f7 100644
--- a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/persistent/TestSentryStore.java
+++ b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/persistent/TestSentryStore.java
@@ -133,17 +133,20 @@ public class TestSentryStore extends org.junit.Assert {
     policyFilePath = new File(dataDir, "local_policy_file.ini");
     conf.set(ServerConfig.SENTRY_STORE_GROUP_MAPPING_RESOURCE,
         policyFilePath.getPath());
-    conf.setInt(ServerConfig.SENTRY_STORE_TRANSACTION_RETRY, 10);
 
+    // These tests do not need to retry transactions, so setting to 1 to reduce testing time
+    conf.setInt(ServerConfig.SENTRY_STORE_TRANSACTION_RETRY, 1);
 
-  }
+    // SentryStore should be initialized only once. The tables created by the test cases will
+    // be cleaned up during the @After method.
+    sentryStore = new SentryStore(conf);
 
-  @Before
-  public void before() throws Exception {
     boolean hdfsSyncEnabled = SentryServiceUtil.isHDFSSyncEnabled(conf);
-    sentryStore = new SentryStore(conf);
     sentryStore.setPersistUpdateDeltas(hdfsSyncEnabled);
+  }
 
+  @Before
+  public void before() throws Exception {
     policyFile = new PolicyFile();
     String adminUser = "g1";
     addGroupsToUser(adminUser, adminGroups);
@@ -153,9 +156,6 @@ public class TestSentryStore extends org.junit.Assert {
   @After
   public void after() {
     sentryStore.clearAllTables();
-    if (sentryStore != null) {
-      sentryStore.stop();
-    }
   }
 
   @AfterClass
@@ -163,6 +163,8 @@ public class TestSentryStore extends org.junit.Assert {
     if (dataDir != null) {
       FileUtils.deleteQuietly(dataDir);
     }
+
+    sentryStore.stop();
   }
 
   /**