From commits-return-91274-archive-asf-public=cust-asf.ponee.io@hbase.apache.org Fri Jan 17 18:03:27 2020 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 955B3180663 for ; Fri, 17 Jan 2020 19:03:27 +0100 (CET) Received: (qmail 4793 invoked by uid 500); 17 Jan 2020 18:03:26 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 4735 invoked by uid 99); 17 Jan 2020 18:03:26 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Jan 2020 18:03:26 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 67751819A1; Fri, 17 Jan 2020 18:03:26 +0000 (UTC) Date: Fri, 17 Jan 2020 18:03:28 +0000 To: "commits@hbase.apache.org" Subject: [hbase] branch master updated: HBASE-23701 Try to converge automated checks around Category MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <157928420553.23040.2951358773229507030@gitbox.apache.org> From: elserj@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: hbase X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: c4395b52c9d134a6f6c99ea226042f62d18d4123 X-Git-Newrev: df8f80a8198d1dde5e235749a65d83483e3f6dac X-Git-Rev: df8f80a8198d1dde5e235749a65d83483e3f6dac X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. elserj pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/hbase.git The following commit(s) were added to refs/heads/master by this push: new df8f80a HBASE-23701 Try to converge automated checks around Category df8f80a is described below commit df8f80a8198d1dde5e235749a65d83483e3f6dac Author: Josh Elser AuthorDate: Thu Jan 16 15:57:42 2020 -0500 HBASE-23701 Try to converge automated checks around Category We have a compile-time guarantee to either have a category array of length zero or one because the category annotation is non-repeatable. Also tries to clean up the checking for unit-test annotations. Closes #1057 Signed-off-by: Viraj Jasani Signed-off-by: Bharath Vissapragada --- .../apache/hadoop/hbase/HBaseClassTestRule.java | 24 +++++++++++++++------- .../hadoop/hbase/HBaseClassTestRuleChecker.java | 5 +++-- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/HBaseClassTestRule.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/HBaseClassTestRule.java index 155bd92..00374c1 100644 --- a/hbase-common/src/test/java/org/apache/hadoop/hbase/HBaseClassTestRule.java +++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/HBaseClassTestRule.java @@ -17,6 +17,8 @@ */ package org.apache.hadoop.hbase; +import java.util.Collections; +import java.util.Set; import java.util.concurrent.TimeUnit; import org.apache.hadoop.hbase.testclassification.IntegrationTests; @@ -30,6 +32,8 @@ import org.junit.rules.Timeout; import org.junit.runner.Description; import org.junit.runners.model.Statement; +import org.apache.hbase.thirdparty.com.google.common.collect.Sets; + /** * The class level TestRule for all the tests. Every test class should have a {@code ClassRule} with * it. @@ -39,6 +43,8 @@ import org.junit.runners.model.Statement; */ @InterfaceAudience.Private public final class HBaseClassTestRule implements TestRule { + public static final Set> UNIT_TEST_CLASSES = Collections.unmodifiableSet( + Sets.> newHashSet(SmallTests.class, MediumTests.class, LargeTests.class)); private final Class clazz; @@ -59,13 +65,17 @@ public final class HBaseClassTestRule implements TestRule { private static long getTimeoutInSeconds(Class clazz) { Category[] categories = clazz.getAnnotationsByType(Category.class); - for (Class c : categories[0].value()) { - if (c == SmallTests.class || c == MediumTests.class || c == LargeTests.class) { - // All tests have a 13 minutes timeout. - return TimeUnit.MINUTES.toSeconds(13); - } - if (c == IntegrationTests.class) { - return TimeUnit.MINUTES.toSeconds(Long.MAX_VALUE); + + // @Category is not repeatable -- it is only possible to get an array of length zero or one. + if (categories.length == 1) { + for (Class c : categories[0].value()) { + if (UNIT_TEST_CLASSES.contains(c)) { + // All tests have a 13 minutes timeout. + return TimeUnit.MINUTES.toSeconds(13); + } + if (c == IntegrationTests.class) { + return TimeUnit.MINUTES.toSeconds(Long.MAX_VALUE); + } } } throw new IllegalArgumentException( diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/HBaseClassTestRuleChecker.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/HBaseClassTestRuleChecker.java index 45884eb..d38b36f 100644 --- a/hbase-common/src/test/java/org/apache/hadoop/hbase/HBaseClassTestRuleChecker.java +++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/HBaseClassTestRuleChecker.java @@ -41,8 +41,9 @@ public class HBaseClassTestRuleChecker extends RunListener { @Override public void testStarted(Description description) throws Exception { Category[] categories = description.getTestClass().getAnnotationsByType(Category.class); - // Don't fail if there is a missing category - if (categories.length > 0) { + + // @Category is not repeatable -- it is only possible to get an array of length zero or one. + if (categories.length == 1) { for (Class c : categories[0].value()) { if (c == IntegrationTests.class) { return;