HBASE-18830 TestCanaryTool does not check Canary monitor's error code Added assertion checks to make sure that the error code for the ToolRunner run() method is used.
Testing Done: Checked that TestCanaryTool unit tests fail when there is an error code in the current Canary run. Signed-off-by: Andrew Purtell <apurt...@apache.org> Conflicts: hbase-server/src/test/java/org/apache/hadoop/hbase/tool/TestCanaryTool.java Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/9d68535e Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/9d68535e Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/9d68535e Branch: refs/heads/branch-1 Commit: 9d68535e8ecf58c879f880c227233e408c0fd32f Parents: 414e0ca Author: Chinmay Kulkarni <chinmayskulka...@gmail.com> Authored: Fri Sep 15 17:06:52 2017 -0700 Committer: Andrew Purtell <apurt...@apache.org> Committed: Mon Sep 25 19:17:22 2017 -0700 ---------------------------------------------------------------------- .../org/apache/hadoop/hbase/tool/TestCanaryTool.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/9d68535e/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 0204582..2206a16 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 @@ -90,7 +90,7 @@ public class TestCanaryTool { Canary.ZookeeperStdOutSink sink = spy(new Canary.ZookeeperStdOutSink()); Canary canary = new Canary(executor, sink); String[] args = { "-t", "10000", "-zookeeper" }; - ToolRunner.run(testingUtility.getConfiguration(), canary, args); + assertEquals(0, ToolRunner.run(testingUtility.getConfiguration(), canary, args)); String baseZnode = testingUtility.getConfiguration() .get(HConstants.ZOOKEEPER_ZNODE_PARENT, HConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT); @@ -113,7 +113,7 @@ public class TestCanaryTool { Canary.RegionStdOutSink sink = spy(new Canary.RegionStdOutSink()); Canary canary = new Canary(executor, sink); String[] args = { "-writeSniffing", "-t", "10000", "testTable" }; - ToolRunner.run(testingUtility.getConfiguration(), canary, args); + assertEquals(0, ToolRunner.run(testingUtility.getConfiguration(), canary, args)); assertEquals("verify no read error count", 0, canary.getReadFailures().size()); assertEquals("verify no write error count", 0, canary.getWriteFailures().size()); verify(sink, atLeastOnce()).publishReadTiming(isA(ServerName.class), isA(HRegionInfo.class), isA(HColumnDescriptor.class), anyLong()); @@ -142,7 +142,7 @@ public class TestCanaryTool { String configuredTimeoutStr = tableNames[0].getNameAsString() + "=" + Long.MAX_VALUE + "," + tableNames[1].getNameAsString() + "=0"; String[] args = { "-readTableTimeouts", configuredTimeoutStr, tableNames[0].getNameAsString(), tableNames[1].getNameAsString()}; - ToolRunner.run(testingUtility.getConfiguration(), canary, args); + assertEquals(0, ToolRunner.run(testingUtility.getConfiguration(), canary, args)); verify(sink, times(tableNames.length)).initializeAndGetReadLatencyForTable(isA(String.class)); for (int i=0; i<2; i++) { assertNotEquals("verify non-null read latency", null, sink.getReadLatencyMap().get(tableNames[i].getNameAsString())); @@ -170,7 +170,7 @@ public class TestCanaryTool { Canary.RegionStdOutSink sink = spy(new Canary.RegionStdOutSink()); Canary canary = new Canary(executor, sink); String[] args = { "-writeSniffing", "-writeTableTimeout", String.valueOf(Long.MAX_VALUE)}; - ToolRunner.run(testingUtility.getConfiguration(), canary, args); + assertEquals(0, ToolRunner.run(testingUtility.getConfiguration(), canary, args)); assertNotEquals("verify non-null write latency", null, sink.getWriteLatency()); assertNotEquals("verify non-zero write latency", 0L, sink.getWriteLatency()); verify(mockAppender, times(1)).doAppend(argThat(new ArgumentMatcher<LoggingEvent>() { @@ -224,7 +224,7 @@ public class TestCanaryTool { String[] args = { "-t", "10000", "testTableRawScan" }; org.apache.hadoop.conf.Configuration conf = new org.apache.hadoop.conf.Configuration(testingUtility.getConfiguration()); conf.setBoolean(HConstants.HBASE_CANARY_READ_RAW_SCAN_KEY, true); - ToolRunner.run(conf, canary, args); + assertEquals(0, ToolRunner.run(conf, canary, args)); verify(sink, atLeastOnce()) .publishReadTiming(isA(ServerName.class), isA(HRegionInfo.class), isA(HColumnDescriptor.class), anyLong()); assertEquals("verify no read error count", 0, canary.getReadFailures().size()); @@ -234,7 +234,7 @@ public class TestCanaryTool { ExecutorService executor = new ScheduledThreadPoolExecutor(1); Canary canary = new Canary(executor, new Canary.RegionServerStdOutSink()); String[] args = { "-t", "10000", "-regionserver"}; - ToolRunner.run(testingUtility.getConfiguration(), canary, args); + assertEquals(0, ToolRunner.run(testingUtility.getConfiguration(), canary, args)); assertEquals("verify no read error count", 0, canary.getReadFailures().size()); }