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 1576D92C3 for ; Wed, 30 Nov 2011 22:46:05 +0000 (UTC) Received: (qmail 45972 invoked by uid 500); 30 Nov 2011 22:46:05 -0000 Delivered-To: apmail-hbase-issues-archive@hbase.apache.org Received: (qmail 45919 invoked by uid 500); 30 Nov 2011 22:46:04 -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 45911 invoked by uid 99); 30 Nov 2011 22:46:04 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Nov 2011 22:46:04 +0000 X-ASF-Spam-Status: No, hits=-2001.2 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Nov 2011 22:46:02 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id E3491AA1A1 for ; Wed, 30 Nov 2011 22:45:40 +0000 (UTC) Date: Wed, 30 Nov 2011 22:45:40 +0000 (UTC) From: "stack (Commented) (JIRA)" To: issues@hbase.apache.org Message-ID: <915413491.28238.1322693140932.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <1196495104.44970.1320135872772.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Commented] (HBASE-4712) Document rules for writing tests MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/HBASE-4712?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13160415#comment-13160415 ] stack commented on HBASE-4712: ------------------------------ I am +1 on this patch/doc. Will commit in a while (will ping Jesse first to make sure he is cool w/ it). Jesse's IntegrationTest* stuff in failsafe is something distinct. We can add a section later making it clear the diff between this work here and Jesse's. > Document rules for writing tests > -------------------------------- > > Key: HBASE-4712 > URL: https://issues.apache.org/jira/browse/HBASE-4712 > Project: HBase > Issue Type: Task > Components: test > Affects Versions: 0.92.0 > Reporter: nkeywal > Assignee: nkeywal > Priority: Minor > > We saw that some tests could be improved. Documenting the general rules could help. > Proposal: > HBase tests are divided in three categories: small, medium and large, with corresponding JUnit categories: SmallTest, MediumTest, LargeTest > Small tests are executed in parallel in a shared JVM. They must last less than 15 seconds. They must NOT use a cluster. > Medium tests are executed in separate JVM. They must last less than 50 seconds. They can use a cluster. They must not fail occasionally. > Small and medium tests must not need more than 30 minutes to run altogether. > Small and medium tests should be executed by the developers before submitting a patch. > Large tests are everything else. They are typically integration tests, non-regression tests for specific bugs, timeout tests, performance tests. > Tests rules & hints are: > - As most as possible, tests should be written as small tests. > - All tests should be written to support parallel execution on the same machine, hence should not use shared resources as fixed ports or fixed file names. > - All tests should be written to be as fast as possible. > - Tests should not overlog. More than 100 lines/second makes the logs complex to read and use i/o that are hence not available for the other tests. > - Tests can be written with HBaseTestingUtility . This class offers helper function to create a temp directory and do the cleanup, or to start a cluster. > - Sleeps: > - Tests should not do a 'Thread.sleep' without testing an ending condition. This allows understanding what the test is waiting for. Moreover, the test will work whatever the machine performances. > - Sleep should be minimal to be as fast as possible. Waiting for a variable should be done in a 40ms sleep loop. Waiting for a socket operation should be done in a 200 ms sleep loop. > - Tests using cluster: > - Tests using a HRegion do not have to start a cluster: A region can use the local file system. > - Start/stopping a cluster cost around 10 seconds. They should not be started per test method but per class. > - Started cluster must be shutdown using HBaseTestingUtility#shutdownMiniCluster, which cleans the directories. > - As most as possible, tests should use the default settings for the cluster. When they don't, they should document it. This will allow to share the cluster later. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira