[
https://issues.apache.org/jira/browse/HBASE-19948?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16356316#comment-16356316
]
Duo Zhang commented on HBASE-19948:
-----------------------------------
If we define category by the largest method in the tests, then the time limit
is meaningless for the small test right? And what's more, if there is a timeout
on a method then usually the whole test sucks... Because the state is incorrect
so the latter test methods will also fail. We see this all over the time.
And I believe that, the only concern of you guys is that, you want to combine a
lot of small test methods into one class but it seems that the ClassRule
prevents you do this. I would say no, the ClassRule is not the criminal. The
most 'small' tests that timed out after the ClassRule are because they start a
mini cluster. I do not think a test with a mini cluster should be declared as
'small'. If you do not start mini cluster, then usually the method can finish
within several ms and you can combine hundreds of test in one class and they
can still finish within 10 seconds...
Thanks.
> 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
>
> Attachments: HBASE-19948.branch-2.001.patch
>
>
> 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.
> {noformat}
> @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); }
> }
> {noformat}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)