Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 21364200B61 for ; Tue, 9 Aug 2016 08:30:01 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 1FE2E160AA5; Tue, 9 Aug 2016 06:30:01 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 64F54160AA4 for ; Tue, 9 Aug 2016 08:30:00 +0200 (CEST) Received: (qmail 49487 invoked by uid 500); 9 Aug 2016 06:29:59 -0000 Mailing-List: contact commits-help@hive.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hive-dev@hive.apache.org Delivered-To: mailing list commits@hive.apache.org Received: (qmail 49476 invoked by uid 99); 9 Aug 2016 06:29:59 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Aug 2016 06:29:59 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 610B7E024E; Tue, 9 Aug 2016 06:29:59 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: daijy@apache.org To: commits@hive.apache.org Message-Id: <6816d838fb79412e967f731254012eaa@git.apache.org> X-Mailer: ASF-Git Admin Mailer 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, 9 Aug 2016 06:29:59 +0000 (UTC) archived-at: Tue, 09 Aug 2016 06:30:01 -0000 Repository: hive Updated Branches: refs/heads/master 3d4408f7d -> ca807c63c 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/ca807c63 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/ca807c63 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/ca807c63 Branch: refs/heads/master Commit: ca807c63ce6b026a368c074ffa1aacdc41322733 Parents: 3d4408f Author: Daniel Dai Authored: Mon Aug 8 23:30:00 2016 -0700 Committer: Daniel Dai Committed: Mon Aug 8 23:30:00 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/ca807c63/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 172f58d..0b3d891 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 @@ -265,7 +265,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"); @@ -281,8 +281,9 @@ public class DbNotificationListener extends MetaStoreEventListener { synchronized(NOTIFICATION_TBL_LOCK) { 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/ca807c63/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 emptyParameters = new HashMap(); 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()); } }