GeorryHuang commented on a change in pull request #1292: HBASE-23994:Add WebUI to Canary URL: https://github.com/apache/hbase/pull/1292#discussion_r406766233
########## File path: hbase-server/src/test/java/org/apache/hadoop/hbase/tool/TestCanaryStatusServlet.java ########## @@ -0,0 +1,95 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.tool; + +import org.apache.hadoop.hbase.HBaseClassTestRule; +import org.apache.hadoop.hbase.ServerName; +import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.client.RegionInfo; +import org.apache.hadoop.hbase.client.RegionInfoBuilder; +import org.apache.hadoop.hbase.testclassification.SmallTests; +import org.apache.hadoop.hbase.tmpl.tool.CanaryStatusTmpl; +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import java.io.IOException; +import java.io.StringWriter; + +@Category({ SmallTests.class }) +public class TestCanaryStatusServlet { + @ClassRule + public static final HBaseClassTestRule CLASS_RULE = + HBaseClassTestRule.forClass(TestCanaryStatusServlet.class); + + @Test + public void testFailures() throws IOException { + CanaryTool.RegionStdOutSink regionStdOutSink = new CanaryTool.RegionStdOutSink(); + + ServerName serverName1 = ServerName.valueOf("staging-st04.server:22600", + 1584180761635L); + TableName fakeTableName1 = TableName.valueOf("fakeTableName1"); + RegionInfo regionInfo1 = RegionInfoBuilder.newBuilder(fakeTableName1).build(); + + ServerName serverName2 = ServerName.valueOf("staging-st05.server:22600", + 1584180761636L); + TableName fakeTableName2 = TableName.valueOf("fakeTableName2"); + RegionInfo regionInfo2 = RegionInfoBuilder.newBuilder(fakeTableName2).build(); + + regionStdOutSink.publishReadFailure(serverName1, regionInfo1, new IOException()); + regionStdOutSink.publishWriteFailure(serverName2, regionInfo2, new IOException()); + CanaryStatusTmpl tmpl = new CanaryStatusTmpl(); + tmpl.render(new StringWriter(), regionStdOutSink); Review comment: > No assertions at all? Is there nothing to verify within the rendered template output? I just refer to the code of TestMasterStatusServlet. TestMasterStatusServlet also has no assertions. I am not sure how to test these html pages, any good suggestions? I can modify it as suggested ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
