d-c-manning commented on code in PR #5772:
URL: https://github.com/apache/hbase/pull/5772#discussion_r1544692039


##########
hbase-server/src/test/java/org/apache/hadoop/hbase/master/http/TestHbckMetricsResource.java:
##########
@@ -0,0 +1,422 @@
+/*
+ * 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.master.http;
+
+import static 
org.apache.hadoop.hbase.client.RegionInfoBuilder.FIRST_META_REGIONINFO;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.allOf;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.endsWith;
+import static org.hamcrest.Matchers.startsWith;
+import static org.junit.Assert.assertThrows;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.concurrent.CompletableFuture;
+import java.util.function.Supplier;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hbase.ConnectionRule;
+import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.MiniClusterRule;
+import org.apache.hadoop.hbase.ServerName;
+import org.apache.hadoop.hbase.StartTestingClusterOption;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.AsyncAdmin;
+import org.apache.hadoop.hbase.client.AsyncConnection;
+import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder;
+import org.apache.hadoop.hbase.client.Durability;
+import org.apache.hadoop.hbase.client.RegionInfo;
+import org.apache.hadoop.hbase.client.TableDescriptor;
+import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
+import org.apache.hadoop.hbase.master.HMaster;
+import org.apache.hadoop.hbase.master.hbck.HbckChore;
+import org.apache.hadoop.hbase.master.hbck.HbckReport;
+import org.apache.hadoop.hbase.master.http.hbck.resource.HbckMetricsResource;
+import org.apache.hadoop.hbase.master.janitor.CatalogJanitor;
+import org.apache.hadoop.hbase.master.janitor.CatalogJanitorReport;
+import org.apache.hadoop.hbase.testclassification.LargeTests;
+import org.apache.hadoop.hbase.testclassification.MasterTests;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.Pair;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.ExternalResource;
+import org.junit.rules.RuleChain;
+import org.mockito.Mockito;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.hbase.thirdparty.javax.ws.rs.NotAcceptableException;
+import org.apache.hbase.thirdparty.javax.ws.rs.client.Client;
+import org.apache.hbase.thirdparty.javax.ws.rs.client.ClientBuilder;
+import org.apache.hbase.thirdparty.javax.ws.rs.client.WebTarget;
+import org.apache.hbase.thirdparty.javax.ws.rs.core.MediaType;
+
+/**
+ * Tests for the {@link HbckMetricsResource}.
+ */
+@Category({ MasterTests.class, LargeTests.class })
+public class TestHbckMetricsResource {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(TestHbckMetricsResource.class);
+
+  // Test data for Mock HBCK Report
+  private static final long reportStartTime = 123456789000L;
+  private static final long reportEndTime = 234567890000L;
+  private static final String regionId1 = "regionId1";
+  private static final String regionId2 = "regionId2";
+  private static final String localhost1 = "localhost1";
+  private static final String localhost2 = "localhost2";
+  private static final String port = "16010";
+  private static final String hostStartCode = "123456789";
+  private static final String path1 = "hdfs://path1";
+  private static final String path2 = "hdfs://path2";
+  private static final String metaRegionID = 
FIRST_META_REGIONINFO.getEncodedName();
+  private static final String metaTableName = 
FIRST_META_REGIONINFO.getTable().getNameAsString();
+
+  // Various Keys in HBCK JSON Response.
+  private static final String quoteColon = "\":";
+  private static final String quote = "\"";
+  private static final String regionId = quote + "region_id" + quoteColon;
+  private static final String regionHdfsPath = quote + "region_hdfs_path" + 
quoteColon;
+  private static final String rsName = quote + "rs_name" + quoteColon;
+  private static final String hostName = quote + "host_name" + quoteColon;
+  private static final String hostPort = quote + "host_port" + quoteColon;
+  private static final String startCode = quote + "start_code" + quoteColon;
+  private static final String serverNameInMeta = quote + "server_name_in_meta" 
+ quoteColon;
+  private static final String listOfServers = quote + "list_of_servers" + 
quoteColon;
+  private static final String region1Info = quote + "region1_info" + 
quoteColon;
+  private static final String region2Info = quote + "region2_info" + 
quoteColon;
+  private static final String regionInfo = quote + "region_info" + quoteColon;
+  private static final String serverName = quote + "server_name" + quoteColon;
+  private static final String tableName = quote + "table_name" + quoteColon;
+
+  private static final String dataStartsWith = "{\"data\":[";
+  private static final String dataEndsWith = "]}";
+  private static final String hbckReportStartTime = quote + 
"hbck_report_start_time" + quoteColon;
+  private static final String hbckReportEndTime = quote + 
"hbck_report_end_time" + quoteColon;
+  private static final String hbckOrphanRegionOnFS =
+    quote + "hbck_orphan_regions_on_fs" + quoteColon;
+  private static final String hbckOrphanRegionOnRS =
+    quote + "hbck_orphan_regions_on_rs" + quoteColon;
+  private static final String hbckInconsistentRegion =
+    quote + "hbck_inconsistent_regions" + quoteColon;
+  private static final String hbckHoles = quote + "hbck_holes" + quoteColon;
+  private static final String hbckOverlaps = quote + "hbck_overlaps" + 
quoteColon;
+  private static final String hbckUnknownServers = quote + 
"hbck_unknown_servers" + quoteColon;
+  private static final String hbckEmptyRegionInfo = quote + 
"hbck_empty_region_info" + quoteColon;
+
+  @ClassRule
+  public static final HBaseClassTestRule CLASS_RULE =
+    HBaseClassTestRule.forClass(TestHbckMetricsResource.class);
+
+  private static final MiniClusterRule miniClusterRule = 
MiniClusterRule.newBuilder()
+    .setMiniClusterOption(
+      
StartTestingClusterOption.builder().numZkServers(3).numMasters(3).numDataNodes(3).build())

Review Comment:
   do you need 3 servers, or would the default 1 be good enough?
   ```suggestion
         StartTestingClusterOption.builder().build())
   ```



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to