You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by "Duo Zhang (JIRA)" <ji...@apache.org> on 2018/02/07 00:44:03 UTC

[jira] [Commented] (HBASE-19948) Since HBASE-19873, HBaseClassTestRule, Small/Medium/Large has different semantic

    [ https://issues.apache.org/jira/browse/HBASE-19948?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16354795#comment-16354795 ] 

Duo Zhang commented on HBASE-19948:
-----------------------------------

I think we could change the javadoc and refguide about these annotations?

If you use @Rule, it will be a limit on method level, as well as @ClassRule which is a limit on class level.

And I believe the old comment for small tests has an implicit background that junit could run test methods in the same class in parallel with multi-thread, so limit on a method is almost the same with limit on class. But for us this is not true, as most developers do not take care about the conflicts between test methods so a parallel run will be easy to cause test failure...

> Since HBASE-19873, HBaseClassTestRule, Small/Medium/Large has different semantic
> --------------------------------------------------------------------------------
>
>                 Key: HBASE-19948
>                 URL: https://issues.apache.org/jira/browse/HBASE-19948
>             Project: HBase
>          Issue Type: Bug
>            Reporter: stack
>            Assignee: stack
>            Priority: Major
>             Fix For: 2.0.0-beta-2
>
>
> I was confused on how SmallTest/MediumTest/LargeTest were being interpreted since HBASE-19873 where we added HBaseClassTestRule enforcing a ClassRule.
> Small/Medium/Large are defined up in the refguide here: http://hbase.apache.org/book.html#hbase.unittests
> E.g: "Small test cases are executed in a shared JVM and individual test cases should run in 15 seconds or less..."
> I've always read the above as each method in a test suite/class should take 15 seconds (see below for finding by [~appy] [1]).
> The old CategoryBasedTimeout annotation used to try and enforce a test method taking only its designated category amount of time.
> The JUnit Timeout Rule talks about enforcing the timeout per test method: https://junit.org/junit4/javadoc/4.12/org/junit/rules/Timeout.html
> The above meant that you could have as many tests as you wanted in a class/suite and it could run as along as you liked as along as each individual test stayed within its category-based elapsed amount of time (and the whole suite completed inside the surefire fork timeout of 15mins).
> Then came HBASE-19873 which addressed an awkward issue around accounting for time spent in startup/shutdown -- i.e. time taken outside of a test method run -- and trying to have a timeout that cuts in before the surefire fork one does. It ended up adding a ClassRule that set a timeout on the whole test *suite/class* -- Good -- but the timeout set varies dependent upon the test category. A suite/class with 60 small tests that each take a second to complete now times out if you add one more test to the suite (61 seconds > 60 seconds timeout -- give or take vagaries of the platform you run the test on).
> This latter change I have trouble with. It changes how small/medium/large have classically been understood. I think it will confuse too as now devs must do careful counting of test methods per class; one fat one (i.e. 'large') is same as N small ones. Could we set a single timeout on the whole test suite/class, one that was well less than the surefire fork kill timeout of 900seconds but keep the old timeout on each method as we used to have with the category-based annotation?
> (Am just looking for agreement that we have a problem here and that we want categories to be per test method as it used be; how to do it doesn't look easy and is for later).
> 1. @appy pointed out that the actual SmallTest annotation says something other than what is in the refguide: "Tag a test as 'small', meaning that the test class has the following characteristics: ....ideally, last less than 15 seconds...." https://github.com/apache/hbase/blob/master/hbase-annotations/src/test/java/org/apache/hadoop/hbase/testclassification/SmallTests.java#L22
> 2. Here is code to show how timeout has changed now... previous the below would have 'run' without timing out.
> @Category({SmallTests.class})
> public class TestTimingOut {
>   @ClassRule
>   public static final HBaseClassTestRule CLASS_RULE =
>       HBaseClassTestRule.forClass(TestTimingOut.class);
>   @Test
>   public void oneTest() {
>     Threads.sleep(14000);
>   }
>   @Test
>   public void twoTest() {
>     Threads.sleep(14000);
>   }
>   @Test
>   public void threeTest() {
>     Threads.sleep(14000);
>   }
>   @Test
>   public void fourTest() {
>     Threads.sleep(14000);
>   }
>   @Test
>   public void fiveTest() {
>     Threads.sleep(14000);
>   }
> }



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)