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 35C58200C59 for ; Mon, 17 Apr 2017 20:17:58 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 34C9F160BAB; Mon, 17 Apr 2017 18:17:58 +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 5D7FD160B92 for ; Mon, 17 Apr 2017 20:17:57 +0200 (CEST) Received: (qmail 20526 invoked by uid 500); 17 Apr 2017 18:17:44 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 19768 invoked by uid 99); 17 Apr 2017 18:17:44 -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; Mon, 17 Apr 2017 18:17:44 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id EAFADDFFD7; Mon, 17 Apr 2017 18:17:43 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: inigoiri@apache.org To: common-commits@hadoop.apache.org Date: Mon, 17 Apr 2017 18:18:03 -0000 Message-Id: In-Reply-To: <5649cd6ec5944efb9f145fa5171cdafe@git.apache.org> References: <5649cd6ec5944efb9f145fa5171cdafe@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [21/45] hadoop git commit: HDFS-11630. TestThrottledAsyncCheckerTimeout fails intermittently in Jenkins builds. Contributed by Hanisha Koneru. archived-at: Mon, 17 Apr 2017 18:17:58 -0000 HDFS-11630. TestThrottledAsyncCheckerTimeout fails intermittently in Jenkins builds. Contributed by Hanisha Koneru. Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/0ac91db6 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/0ac91db6 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/0ac91db6 Branch: refs/heads/HDFS-10467 Commit: 0ac91db62186a381e80b0ced05fe52fee0491cc6 Parents: 99ae945 Author: Hanisha Koneru Authored: Tue Apr 11 21:36:24 2017 -0700 Committer: Inigo Committed: Mon Apr 17 11:17:01 2017 -0700 ---------------------------------------------------------------------- .../TestDatasetVolumeCheckerTimeout.java | 2 +- .../TestThrottledAsyncCheckerTimeout.java | 45 ++++++++++---------- 2 files changed, 24 insertions(+), 23 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/0ac91db6/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/checker/TestDatasetVolumeCheckerTimeout.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/checker/TestDatasetVolumeCheckerTimeout.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/checker/TestDatasetVolumeCheckerTimeout.java index dc091ed..953de4f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/checker/TestDatasetVolumeCheckerTimeout.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/checker/TestDatasetVolumeCheckerTimeout.java @@ -94,7 +94,7 @@ public class TestDatasetVolumeCheckerTimeout { return volume; } - @Test (timeout = 1000) + @Test (timeout = 300000) public void testDiskCheckTimeout() throws Exception { LOG.info("Executing {}", testName.getMethodName()); final FsVolumeSpi volume = makeSlowVolume(); http://git-wip-us.apache.org/repos/asf/hadoop/blob/0ac91db6/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/checker/TestThrottledAsyncCheckerTimeout.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/checker/TestThrottledAsyncCheckerTimeout.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/checker/TestThrottledAsyncCheckerTimeout.java index 52cab57..b0993b5 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/checker/TestThrottledAsyncCheckerTimeout.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/checker/TestThrottledAsyncCheckerTimeout.java @@ -17,6 +17,14 @@ */ package org.apache.hadoop.hdfs.server.datanode.checker; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyObject; +import static org.mockito.Matchers.anySet; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.timeout; +import static org.mockito.Mockito.verify; + import com.google.common.base.Optional; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; @@ -35,12 +43,7 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TestName; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyObject; -import static org.mockito.Matchers.anySet; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; +import org.junit.rules.Timeout; import org.slf4j.LoggerFactory; import java.util.Set; @@ -58,10 +61,10 @@ public class TestThrottledAsyncCheckerTimeout { @Rule public TestName testName = new TestName(); + @Rule + public Timeout testTimeout = new Timeout(300_000); - Configuration conf; private static final long DISK_CHECK_TIMEOUT = 10; - private static final long DISK_CHECK_TIME = 100; private ReentrantLock lock; private ExecutorService getExecutorService() { @@ -73,7 +76,7 @@ public class TestThrottledAsyncCheckerTimeout { lock = new ReentrantLock(); } - @Test (timeout = 1000) + @Test public void testDiskCheckTimeout() throws Exception { LOG.info("Executing {}", testName.getMethodName()); @@ -123,7 +126,7 @@ public class TestThrottledAsyncCheckerTimeout { assertTrue(throwable[0] instanceof TimeoutException); } - @Test (timeout = 2000) + @Test public void testDiskCheckTimeoutInvokesOneCallbackOnly() throws Exception { LOG.info("Executing {}", testName.getMethodName()); @@ -143,13 +146,12 @@ public class TestThrottledAsyncCheckerTimeout { assertTrue(olf1.isPresent()); Futures.addCallback(olf1.get(), futureCallback); - // Wait for the callback - Thread.sleep(DISK_CHECK_TIMEOUT); - // Verify that timeout results in only 1 onFailure call and 0 onSuccess // calls. - verify(futureCallback, times(1)).onFailure(any()); - verify(futureCallback, times(0)).onSuccess(any()); + verify(futureCallback, timeout((int) DISK_CHECK_TIMEOUT*10).times(1)) + .onFailure(any()); + verify(futureCallback, timeout((int) DISK_CHECK_TIMEOUT*10).times(0)) + .onSuccess(any()); // Release lock so that target can acquire it. lock.unlock(); @@ -160,16 +162,15 @@ public class TestThrottledAsyncCheckerTimeout { assertTrue(olf2.isPresent()); Futures.addCallback(olf2.get(), futureCallback); - // Wait for the callback - Thread.sleep(DISK_CHECK_TIME); - // Verify that normal check (dummy) results in only 1 onSuccess call. - // Number of times onFailure is invoked should remain the same - 1. - verify(futureCallback, times(1)).onFailure(any()); - verify(futureCallback, times(1)).onSuccess(any()); + // Number of times onFailure is invoked should remain the same i.e. 1. + verify(futureCallback, timeout((int) DISK_CHECK_TIMEOUT*10).times(1)) + .onFailure(any()); + verify(futureCallback, timeout((int) DISK_CHECK_TIMEOUT*10).times(1)) + .onSuccess(any()); } - @Test (timeout = 1000) + @Test public void testTimeoutExceptionIsNotThrownForGoodDisk() throws Exception { LOG.info("Executing {}", testName.getMethodName()); --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org For additional commands, e-mail: common-commits-help@hadoop.apache.org