This is an automated email from the ASF dual-hosted git repository.

taklwu pushed a commit to branch branch-2.6
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2.6 by this push:
     new c4869ea277a HBASE-29316 Backport HBASE-29292 to branch-2 (#6992)
c4869ea277a is described below

commit c4869ea277afa4ef9afb54a23cd7af42c3ff4d93
Author: Tak Lon (Stephen) Wu <[email protected]>
AuthorDate: Mon May 19 16:31:47 2025 -0700

    HBASE-29316 Backport HBASE-29292 to branch-2 (#6992)
    
    - use StartMiniClusterOption in branch-2
    
    (cherry picked from commit 902067d)
    
    Signed-off-by: Wellington Chevreuil <[email protected]>
---
 .../hadoop/hbase/master/TestRecreateCluster.java   | 68 ++++++++--------------
 1 file changed, 25 insertions(+), 43 deletions(-)

diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRecreateCluster.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRecreateCluster.java
index ebc83df5c00..c3c04112c39 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRecreateCluster.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRecreateCluster.java
@@ -28,22 +28,21 @@ import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hbase.Cell;
 import org.apache.hadoop.hbase.HBaseClassTestRule;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
-import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.MiniHBaseCluster;
 import org.apache.hadoop.hbase.ServerName;
+import org.apache.hadoop.hbase.StartMiniClusterOption;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.client.RegionInfo;
 import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.client.Table;
-import org.apache.hadoop.hbase.master.region.MasterRegionFactory;
-import org.apache.hadoop.hbase.procedure2.store.wal.WALProcedureStore;
 import org.apache.hadoop.hbase.regionserver.HRegionServer;
 import org.apache.hadoop.hbase.testclassification.LargeTests;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.CommonFSUtils;
 import org.apache.hadoop.hbase.zookeeper.ZKUtil;
+import org.junit.After;
 import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Rule;
@@ -71,9 +70,16 @@ public class TestRecreateCluster {
   private static final long MASTER_INIT_TIMEOUT_MS = 
Duration.ofSeconds(45).toMillis();
 
   @Before
-  public void setup() {
+  public void setup() throws Exception {
     
TEST_UTIL.getConfiguration().setLong("hbase.master.init.timeout.localHBaseCluster",
       MASTER_INIT_TIMEOUT_MS);
+    
TEST_UTIL.startMiniCluster(StartMiniClusterOption.builder().numRegionServers(NUM_RS)
+      .numDataNodes(NUM_RS).createWALDir(true).build());
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    TEST_UTIL.shutdownMiniCluster();
   }
 
   @Test
@@ -88,45 +94,33 @@ public class TestRecreateCluster {
 
   @Test
   public void testRecreateCluster_UserTableEnabled_CleanupZNodes() throws 
Exception {
-    // new InitMetaProcedure are not submitted and reused the existing SUCCESS 
InitMetaProcedure
-    // initMetaProc.await() hangs forever.
+    // this is no longer failing because master region stores the information 
the region servers
+    // as long as it's gracefully flushed before shutdown
     validateRecreateClusterWithUserTableEnabled(false, true);
   }
 
-  @Test(expected = IOException.class)
+  @Test
   public void testRecreateCluster_UserTableEnabled_CleanupWALAndZNodes() 
throws Exception {
-    // master fails with InitMetaProcedure because it cannot delete existing 
meta table directory,
-    // region server cannot join and time-out the cluster starts.
     validateRecreateClusterWithUserTableEnabled(true, true);
   }
 
   private void validateRecreateClusterWithUserDisabled(boolean cleanupWALs, 
boolean cleanUpZNodes)
     throws Exception {
-    TEST_UTIL.startMiniCluster(NUM_RS);
-    try {
-      TableName tableName = TableName.valueOf("t1");
-      prepareDataBeforeRecreate(TEST_UTIL, tableName);
-      TEST_UTIL.getAdmin().disableTable(tableName);
-      TEST_UTIL.waitTableDisabled(tableName.getName());
-      restartHBaseCluster(cleanupWALs, cleanUpZNodes);
-      TEST_UTIL.getAdmin().enableTable(tableName);
-      validateDataAfterRecreate(TEST_UTIL, tableName);
-    } finally {
-      TEST_UTIL.shutdownMiniCluster();
-    }
+    TableName tableName = TableName.valueOf("t1");
+    prepareDataBeforeRecreate(TEST_UTIL, tableName);
+    TEST_UTIL.getAdmin().disableTable(tableName);
+    TEST_UTIL.waitTableDisabled(tableName.getName());
+    restartHBaseCluster(cleanupWALs, cleanUpZNodes);
+    TEST_UTIL.getAdmin().enableTable(tableName);
+    validateDataAfterRecreate(TEST_UTIL, tableName);
   }
 
   private void validateRecreateClusterWithUserTableEnabled(boolean cleanupWALs,
     boolean cleanUpZNodes) throws Exception {
-    TEST_UTIL.startMiniCluster(NUM_RS);
-    try {
-      TableName tableName = TableName.valueOf("t1");
-      prepareDataBeforeRecreate(TEST_UTIL, tableName);
-      restartHBaseCluster(cleanupWALs, cleanUpZNodes);
-      validateDataAfterRecreate(TEST_UTIL, tableName);
-    } finally {
-      TEST_UTIL.shutdownMiniCluster();
-    }
+    TableName tableName = TableName.valueOf("t1");
+    prepareDataBeforeRecreate(TEST_UTIL, tableName);
+    restartHBaseCluster(cleanupWALs, cleanUpZNodes);
+    validateDataAfterRecreate(TEST_UTIL, tableName);
   }
 
   private void restartHBaseCluster(boolean cleanUpWALs, boolean cleanUpZnodes) 
throws Exception {
@@ -147,17 +141,7 @@ public class TestRecreateCluster {
     TEST_UTIL.shutdownMiniHBaseCluster();
 
     if (cleanUpWALs) {
-      TEST_UTIL.getDFSCluster().getFileSystem()
-        .delete(new Path(rootDirPath, MasterRegionFactory.MASTER_STORE_DIR), 
true);
-      TEST_UTIL.getDFSCluster().getFileSystem()
-        .delete(new Path(walRootDirPath, 
MasterRegionFactory.MASTER_STORE_DIR), true);
-      TEST_UTIL.getDFSCluster().getFileSystem()
-        .delete(new Path(walRootDirPath, 
WALProcedureStore.MASTER_PROCEDURE_LOGDIR), true);
-
-      TEST_UTIL.getDFSCluster().getFileSystem()
-        .delete(new Path(walRootDirPath, HConstants.HREGION_LOGDIR_NAME), 
true);
-      TEST_UTIL.getDFSCluster().getFileSystem()
-        .delete(new Path(walRootDirPath, HConstants.HREGION_OLDLOGDIR_NAME), 
true);
+      TEST_UTIL.getDFSCluster().getFileSystem().delete(walRootDirPath, true);
     }
 
     if (cleanUpZnodes) {
@@ -196,7 +180,6 @@ public class TestRecreateCluster {
     MiniHBaseCluster hbaseCluster = TEST_UTIL.getHBaseCluster();
     assertTrue("Please start more than 1 regionserver",
       hbaseCluster.getRegionServerThreads().size() > 1);
-
     int userTableServerNum = getServerNumForTableWithOnlyOneRegion(userTable);
     int systemTableServerNum = 
getServerNumForTableWithOnlyOneRegion(systemTable);
 
@@ -237,5 +220,4 @@ public class TestRecreateCluster {
       Bytes.toString(cell.getValueArray(), cell.getValueOffset(), 
cell.getValueLength()));
     assertFalse(result.advance());
   }
-
 }

Reply via email to