hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From da...@apache.org
Subject hive git commit: HIVE-14399: Fix test flakiness of org.apache.hive.hcatalog.listener.TestDbNotificationListener.cleanupNotifs (Daniel Dai, reviewed by Ashutosh Chauhan)
Date Tue, 09 Aug 2016 06:29:13 GMT
Repository: hive
Updated Branches:
  refs/heads/branch-2.1 759a965ce -> 39a0e5509


HIVE-14399: Fix test flakiness of org.apache.hive.hcatalog.listener.TestDbNotificationListener.cleanupNotifs
(Daniel Dai, reviewed by Ashutosh Chauhan)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/39a0e550
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/39a0e550
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/39a0e550

Branch: refs/heads/branch-2.1
Commit: 39a0e5509a11eae0ba89f092bf75948c971cc7cf
Parents: 759a965
Author: Daniel Dai <daijy@hortonworks.com>
Authored: Mon Aug 8 23:20:58 2016 -0700
Committer: Daniel Dai <daijy@hortonworks.com>
Committed: Mon Aug 8 23:20:58 2016 -0700

----------------------------------------------------------------------
 .../hcatalog/listener/DbNotificationListener.java   |  5 +++--
 .../listener/TestDbNotificationListener.java        | 16 ++++++++++++++++
 2 files changed, 19 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/39a0e550/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/listener/DbNotificationListener.java
----------------------------------------------------------------------
diff --git a/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/listener/DbNotificationListener.java
b/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/listener/DbNotificationListener.java
index 8a49bf7..7245b9e 100644
--- a/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/listener/DbNotificationListener.java
+++ b/hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/listener/DbNotificationListener.java
@@ -261,7 +261,7 @@ public class DbNotificationListener extends MetaStoreEventListener {
   private static class CleanerThread extends Thread {
     private RawStore rs;
     private int ttl;
-
+    static private long sleepTime = 60000;
 
     CleanerThread(HiveConf conf, RawStore rs) {
       super("CleanerThread");
@@ -275,8 +275,9 @@ public class DbNotificationListener extends MetaStoreEventListener {
     public void run() {
       while (true) {
         rs.cleanNotificationEvents(ttl);
+        LOG.debug("Cleaner thread done");
         try {
-          Thread.sleep(60000);
+          Thread.sleep(sleepTime);
         } catch (InterruptedException e) {
           LOG.info("Cleaner thread sleep interupted", e);
         }

http://git-wip-us.apache.org/repos/asf/hive/blob/39a0e550/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java
----------------------------------------------------------------------
diff --git a/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java
b/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java
index d0802d6..81ce67b 100644
--- a/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java
+++ b/itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java
@@ -48,6 +48,7 @@ import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
+import java.lang.reflect.Field;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
@@ -58,12 +59,14 @@ public class TestDbNotificationListener {
 
   private static final Logger LOG = LoggerFactory.getLogger(TestDbNotificationListener.class.getName());
   private static final int EVENTS_TTL = 30;
+  private static final int CLEANUP_SLEEP_TIME = 10;
   private static Map<String, String> emptyParameters = new HashMap<String, String>();
   private static IMetaStoreClient msClient;
   private static Driver driver;
   private int startTime;
   private long firstEventId;
 
+  @SuppressWarnings("rawtypes")
   @BeforeClass
   public static void connectToMetastore() throws Exception {
     HiveConf conf = new HiveConf();
@@ -73,6 +76,16 @@ public class TestDbNotificationListener {
     conf.setBoolVar(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY, false);
     conf.setBoolVar(HiveConf.ConfVars.FIRE_EVENTS_FOR_DML, true);
     conf.setVar(HiveConf.ConfVars.DYNAMICPARTITIONINGMODE, "nonstrict");
+    Class dbNotificationListener =
+        Class.forName("org.apache.hive.hcatalog.listener.DbNotificationListener");
+    Class[] classes = dbNotificationListener.getDeclaredClasses();
+    for (Class c : classes) {
+      if (c.getName().endsWith("CleanerThread")) {
+        Field sleepTimeField = c.getDeclaredField("sleepTime");
+        sleepTimeField.setAccessible(true);
+        sleepTimeField.set(null, CLEANUP_SLEEP_TIME * 1000);
+      }
+    }
     conf
     .setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER,
         "org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactory");
@@ -602,13 +615,16 @@ public class TestDbNotificationListener {
     msClient.createDatabase(db);
     msClient.dropDatabase("cleanup1");
 
+    LOG.info("Pulling events immediately after createDatabase/dropDatabase");
     NotificationEventResponse rsp = msClient.getNextNotification(firstEventId, 0, null);
     assertEquals(2, rsp.getEventsSize());
 
     // sleep for expiry time, and then fetch again
     Thread.sleep(EVENTS_TTL * 2 * 1000); // sleep twice the TTL interval - things should
have been cleaned by then.
 
+    LOG.info("Pulling events again after cleanup");
     NotificationEventResponse rsp2 = msClient.getNextNotification(firstEventId, 0, null);
+    LOG.info("second trigger done");
     assertEquals(0, rsp2.getEventsSize());
   }
 }


Mime
View raw message