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

stack commented on HBASE-13127:
-------------------------------

[~ndimiduk] Policy is a bit hard but I could add this to every TestClass:

  @Rule
  public CategoryBasedTimeout defaultGlobalTestTimeout =
    new CategoryBasedTimeout(this.getClass());

It is a new rule of our own writing that takes 'this' and reads the test 
category and then sets the global test timeout accordingly.

Here is the implementation:

{code}
/**
 * Set a test method timeout based off the test categories small, medium, large.
 * Based on junit Timeout TestRule; see 
https://github.com/junit-team/junit/wiki/Rules
 */
public class CategoryBasedTimeout implements TestRule {
  private final int fMillis;

  public CategoryBasedTimeout(Class <?> clazz) {
    int timeout = Integer.MAX_VALUE;
    Annotation annotation = clazz.getAnnotation(Category.class);
    if (annotation != null) {
      Category category = (Category)annotation;
      for (Class<?> c: category.value()) {
        if (c == SmallTests.class) {
          // See SmallTests. Supposed to run 15 seconds.  If 30 seconds, its 
been going on too long
          timeout = 30000;
          break;
        } else if (c == MediumTests.class) {
          // See MediumTests. Supposed to run 50 seconds.
          timeout = 180000;
          break;
        } else if (c == LargeTests.class) {
          // Let large tests have a ten minute timeout.
          timeout = 600000;
          break;
        }
      }
    }
    this.fMillis = timeout;
  }

  @Override
  public Statement apply(Statement base, Description description) {
    return new FailOnTimeout(base, fMillis);
  }
}
{code}

Seems to work in rough testing.





> Add timeouts on all tests so less zombie sightings
> --------------------------------------------------
>
>                 Key: HBASE-13127
>                 URL: https://issues.apache.org/jira/browse/HBASE-13127
>             Project: HBase
>          Issue Type: Improvement
>          Components: test
>            Reporter: stack
>            Assignee: stack
>         Attachments: 13127.txt, 13127v2.txt
>
>
> [~Apache9] and [~octo47] have been working hard at trying to get our builds 
> passing again. They are almost there. TRUNK just failed with a zombie 
> TestMasterObserver. Help the lads out by adding timeouts on all tests so less 
> zombie incidence... will help identify the frequent failing issues.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to