Return-Path: X-Original-To: apmail-hbase-issues-archive@www.apache.org Delivered-To: apmail-hbase-issues-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 82A89DD54 for ; Sat, 12 Jan 2013 04:16:13 +0000 (UTC) Received: (qmail 2401 invoked by uid 500); 12 Jan 2013 04:16:13 -0000 Delivered-To: apmail-hbase-issues-archive@hbase.apache.org Received: (qmail 2365 invoked by uid 500); 12 Jan 2013 04:16:13 -0000 Mailing-List: contact issues-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list issues@hbase.apache.org Received: (qmail 2341 invoked by uid 99); 12 Jan 2013 04:16:12 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 12 Jan 2013 04:16:12 +0000 Date: Sat, 12 Jan 2013 04:16:12 +0000 (UTC) From: "Hudson (JIRA)" To: issues@hbase.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (HBASE-7384) Introducing waitForCondition function into test cases MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HBASE-7384?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13551799#comment-13551799 ] Hudson commented on HBASE-7384: ------------------------------- Integrated in HBase-TRUNK #3735 (See [https://builds.apache.org/job/HBase-TRUNK/3735/]) HBASE-7384 Introducing waitForCondition function into test cases (Jeffrey Zhong) (Revision 1432358) Result = FAILURE enis : Files : * /hbase/trunk/hbase-common/src/test/java/org/apache/hadoop/hbase/Waiter.java * /hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java * /hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestSplitLogManager.java * /hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitLogWorker.java > Introducing waitForCondition function into test cases > ----------------------------------------------------- > > Key: HBASE-7384 > URL: https://issues.apache.org/jira/browse/HBASE-7384 > Project: HBase > Issue Type: Test > Components: test > Reporter: Jeffrey Zhong > Assignee: Jeffrey Zhong > Labels: test > Fix For: 0.96.0 > > Attachments: hbase-7384_1.0.patch, hbase-7384_2.4.patch, hbase-7384.patch, Waiter.java > > > Recently I'm working on flaky test cases and found we have many places using while loop and sleep to wait for a condition to be true. There are several issues in existing ways: > 1) Many similar code doing the same thing > 2) When time out happens, different errors are reported without explicitly indicating a time out situation > 3) When we want to increase the max timeout value to verify if a test case fails due to a not-enough time out value, we have to recompile & redeploy code > I propose to create a waitForCondition function as a test utility function like the following: > {code} > public interface WaitCheck { > public boolean Check() ; > } > public boolean waitForCondition(int timeOutInMilliSeconds, int checkIntervalInMilliSeconds, WaitCheck s) > throws InterruptedException { > int multiplier = 1; > String multiplierProp = System.getProperty("extremeWaitMultiplier"); > if(multiplierProp != null) { > multiplier = Integer.parseInt(multiplierProp); > if(multiplier < 1) { > LOG.warn(String.format("Invalid extremeWaitMultiplier property value:%s. is ignored.", multiplierProp)); > multiplier = 1; > } > } > int timeElapsed = 0; > while(timeElapsed < timeOutInMilliSeconds * multiplier) { > if(s.Check()) { > return true; > } > Thread.sleep(checkIntervalInMilliSeconds); > timeElapsed += checkIntervalInMilliSeconds; > } > assertTrue("WaitForCondition failed due to time out(" + timeOutInMilliSeconds + " milliseconds expired)", > false); > return false; > } > {code} > By doing the above way, there are several advantages: > 1) Clearly report time out error when such situation happens > 2) Use System property extremeWaitMultiplier to increase max time out dynamically for a quick verification > 3) Standardize current wait situations > Pleas let me know what your thoughts on this. > Thanks, > -Jeffrey -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira