joshelser commented on a change in pull request #56: HBASE-23562 [operator 
tools] Add a RegionsMerge tool that allows for...
URL: 
https://github.com/apache/hbase-operator-tools/pull/56#discussion_r404333327
 
 

 ##########
 File path: hbase-tools/src/test/java/org/apache/hbase/TestRegionsMerger.java
 ##########
 @@ -0,0 +1,118 @@
+/*
+ * 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.hbase;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.client.RegionInfo;
+import org.apache.hadoop.hbase.client.Table;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+public class TestRegionsMerger {
+  private final static HBaseTestingUtility TEST_UTIL = new 
HBaseTestingUtility();
+  private static final TableName TABLE_NAME =
+    TableName.valueOf(TestRegionsMerger.class.getSimpleName());
+  private static final byte[] family = Bytes.toBytes("f");
+  private Table table;
+
+  @BeforeClass
+  public static void beforeClass() throws Exception {
+    TEST_UTIL.getConfiguration().set(HConstants.HREGION_MAX_FILESIZE,
+      Long.toString(1024*1024*3));
+    TEST_UTIL.startMiniCluster(3);
+  }
+
+  @AfterClass
+  public static void afterClass() throws Exception {
+    TEST_UTIL.shutdownMiniCluster();
+  }
+
+  @Before
+  public void setup() throws Exception {
+    table = TEST_UTIL.createMultiRegionTable(TABLE_NAME, family, 15);
+    TEST_UTIL.waitUntilAllRegionsAssigned(TABLE_NAME);
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    TEST_UTIL.deleteTable(TABLE_NAME);
+  }
+
+  @Test
+  public void testMergeRegionsCanMergeToTarget() throws Exception {
+    TEST_UTIL.getConfiguration().setInt(RegionsMerger.MAX_ROUNDS_IDDLE, 10);
+    RegionsMerger merger = new RegionsMerger(TEST_UTIL.getConfiguration());
+    merger.mergeRegions(TABLE_NAME.getNameWithNamespaceInclAsString(), 3);
+    List<RegionInfo> result = TEST_UTIL.getAdmin().getRegions(TABLE_NAME);
+    assertEquals(3, result.size());
 
 Review comment:
   For all of the tests, can you please add a verification step to make sure 
that we can still read all records in the table?

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

Reply via email to