Repository: hbase Updated Branches: refs/heads/branch-1 91422357f -> aa7c93c65 refs/heads/branch-1.4 2f6205753 -> ae5da908b
Amend HBASE-18813 TestCanaryTool fails on branch-1 / branch-1.4 Skip tests where mocking with custom matchers fails unexpectedly on older JREs. Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/aa7c93c6 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/aa7c93c6 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/aa7c93c6 Branch: refs/heads/branch-1 Commit: aa7c93c6597f378fe4bed1ec7f9094ac9f4aa356 Parents: 9142235 Author: Andrew Purtell <apurt...@apache.org> Authored: Thu Sep 14 14:33:26 2017 -0700 Committer: Andrew Purtell <apurt...@apache.org> Committed: Thu Sep 14 14:38:56 2017 -0700 ---------------------------------------------------------------------- .../org/apache/hadoop/hbase/tool/TestCanaryTool.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/aa7c93c6/hbase-server/src/test/java/org/apache/hadoop/hbase/tool/TestCanaryTool.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/tool/TestCanaryTool.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/tool/TestCanaryTool.java index f186281..3e714b0 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/tool/TestCanaryTool.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/tool/TestCanaryTool.java @@ -120,6 +120,7 @@ public class TestCanaryTool { @Test public void testReadTableTimeouts() throws Exception { + if (skipOldJREs()) return; final TableName [] tableNames = new TableName[2]; tableNames[0] = TableName.valueOf("testReadTableTimeouts1"); tableNames[1] = TableName.valueOf("testReadTableTimeouts2"); @@ -163,6 +164,7 @@ public class TestCanaryTool { @Test public void testWriteTableTimeout() throws Exception { + if (skipOldJREs()) return; ExecutorService executor = new ScheduledThreadPoolExecutor(1); Canary.RegionStdOutSink sink = spy(new Canary.RegionStdOutSink()); Canary canary = new Canary(executor, sink); @@ -181,6 +183,7 @@ public class TestCanaryTool { //no table created, so there should be no regions @Test public void testRegionserverNoRegions() throws Exception { + if (skipOldJREs()) return; runRegionserverCanary(); verify(mockAppender).doAppend(argThat(new ArgumentMatcher<LoggingEvent>() { @Override @@ -193,6 +196,7 @@ public class TestCanaryTool { //by creating a table, there shouldn't be any region servers not serving any regions @Test public void testRegionserverWithRegions() throws Exception { + if (skipOldJREs()) return; TableName tableName = TableName.valueOf("testTable"); testingUtility.createTable(tableName, new byte[][] { FAMILY }); runRegionserverCanary(); @@ -227,6 +231,15 @@ public class TestCanaryTool { assertEquals("verify no read error count", 0, canary.getReadFailures().size()); } + // We have unexpected trouble asserting with custom matchers using Mockito on Java < 8, + // so skip the relevant tests if running on an older JRE. + private static boolean skipOldJREs() { + String specVersion[] = System.getProperty("java.specification.version").split("\\."); + int majorVersion = Integer.valueOf(specVersion[0]); + int minorVersion = Integer.valueOf(specVersion[1]); + return !(majorVersion > 1 || (majorVersion == 1 && minorVersion > 7)); + } + private void runRegionserverCanary() throws Exception { ExecutorService executor = new ScheduledThreadPoolExecutor(1); Canary canary = new Canary(executor, new Canary.RegionServerStdOutSink());