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

Apache9 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/master by this push:
     new a7cafca6561 HBASE-30091 Rewrite CloneSnapshotFromClientTestBase and 
its sub classes (#8102)
a7cafca6561 is described below

commit a7cafca6561bbd02a1cc54e12f8e573875ab5474
Author: Duo Zhang <[email protected]>
AuthorDate: Mon Apr 20 10:52:52 2026 +0800

    HBASE-30091 Rewrite CloneSnapshotFromClientTestBase and its sub classes 
(#8102)
    
    Signed-off-by: Xiao Liu <[email protected]>
---
 ...shotFromClientAfterSplittingRegionTestBase.java | 36 ++++++++++-----
 ...hotFromClientCloneLinksAfterDeleteTestBase.java |  8 ++--
 .../CloneSnapshotFromClientErrorTestBase.java      | 18 +++++---
 .../CloneSnapshotFromClientNormalTestBase.java     | 12 +++--
 .../client/CloneSnapshotFromClientTestBase.java    | 51 +++++++++++-----------
 ...loneSnapshotFromClientAfterSplittingRegion.java | 36 +++++----------
 ...oneSnapshotFromClientCloneLinksAfterDelete.java | 42 ++++++++----------
 .../TestCloneSnapshotFromClientCustomSFT.java      | 26 ++++++-----
 .../client/TestCloneSnapshotFromClientError.java   | 36 +++++----------
 .../client/TestCloneSnapshotFromClientNormal.java  | 36 +++++----------
 ...loneSnapshotFromClientAfterSplittingRegion.java | 22 +++++-----
 ...oneSnapshotFromClientCloneLinksAfterDelete.java | 30 ++++++-------
 .../TestMobCloneSnapshotFromClientError.java       | 21 ++++-----
 .../TestMobCloneSnapshotFromClientNormal.java      | 21 ++++-----
 14 files changed, 195 insertions(+), 200 deletions(-)

diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/CloneSnapshotFromClientAfterSplittingRegionTestBase.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/CloneSnapshotFromClientAfterSplittingRegionTestBase.java
index 7f1b7bd445c..6d74233dd77 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/CloneSnapshotFromClientAfterSplittingRegionTestBase.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/CloneSnapshotFromClientAfterSplittingRegionTestBase.java
@@ -17,10 +17,12 @@
  */
 package org.apache.hadoop.hbase.client;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.awaitility.Awaitility.await;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import java.io.IOException;
+import java.time.Duration;
 import java.util.List;
 import org.apache.hadoop.hbase.MetaTableAccessor;
 import org.apache.hadoop.hbase.TableName;
@@ -28,12 +30,17 @@ import org.apache.hadoop.hbase.master.RegionState;
 import org.apache.hadoop.hbase.master.assignment.RegionStates;
 import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils;
 import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
-import org.junit.Test;
+import org.junit.jupiter.api.TestTemplate;
 
 public class CloneSnapshotFromClientAfterSplittingRegionTestBase
   extends CloneSnapshotFromClientTestBase {
 
+  protected CloneSnapshotFromClientAfterSplittingRegionTestBase(int 
numReplicas) {
+    super(numReplicas);
+  }
+
   private void splitRegion() throws IOException {
+    int numRegions = admin.getRegions(tableName).size();
     try (Table k = TEST_UTIL.getConnection().getTable(tableName);
       ResultScanner scanner = k.getScanner(new Scan())) {
       // Split on the second row to make sure that the snapshot contains 
reference files.
@@ -41,13 +48,17 @@ public class 
CloneSnapshotFromClientAfterSplittingRegionTestBase
       scanner.next();
       admin.split(tableName, scanner.next().getRow());
     }
+    await().atMost(Duration.ofSeconds(30)).untilAsserted(
+      () -> assertEquals(numRegions + numReplicas, 
admin.getRegions(tableName).size()));
   }
 
-  @Test
+  @TestTemplate
   public void testCloneSnapshotAfterSplittingRegion() throws IOException, 
InterruptedException {
     // Turn off the CatalogJanitor
     admin.catalogJanitorSwitch(false);
 
+    TableName clonedTableName =
+      TableName.valueOf(getValidMethodName() + "-" + 
EnvironmentEdgeManager.currentTime());
     try {
       List<RegionInfo> regionInfos = admin.getRegions(tableName);
       RegionReplicaUtil.removeNonDefaultRegions(regionInfos);
@@ -59,8 +70,6 @@ public class 
CloneSnapshotFromClientAfterSplittingRegionTestBase
       admin.snapshot(snapshotName2, tableName);
 
       // Clone the snapshot to another table
-      TableName clonedTableName =
-        TableName.valueOf(getValidMethodName() + "-" + 
EnvironmentEdgeManager.currentTime());
       admin.cloneSnapshot(snapshotName2, clonedTableName);
       SnapshotTestingUtils.waitForTableToBeOnline(TEST_UTIL, clonedTableName);
 
@@ -90,26 +99,26 @@ public class 
CloneSnapshotFromClientAfterSplittingRegionTestBase
           assertNotNull(daughter);
         }
       }
-
-      TEST_UTIL.deleteTable(clonedTableName);
     } finally {
+      if (admin.tableExists(clonedTableName)) {
+        TEST_UTIL.deleteTable(clonedTableName);
+      }
       admin.catalogJanitorSwitch(true);
     }
   }
 
-  @Test
+  @TestTemplate
   public void testCloneSnapshotBeforeSplittingRegionAndDroppingTable()
     throws IOException, InterruptedException {
     // Turn off the CatalogJanitor
     admin.catalogJanitorSwitch(false);
-
+    TableName clonedTableName =
+      TableName.valueOf(getValidMethodName() + "-" + 
EnvironmentEdgeManager.currentTime());
     try {
       // Take a snapshot
       admin.snapshot(snapshotName2, tableName);
 
       // Clone the snapshot to another table
-      TableName clonedTableName =
-        TableName.valueOf(getValidMethodName() + "-" + 
EnvironmentEdgeManager.currentTime());
       admin.cloneSnapshot(snapshotName2, clonedTableName);
       SnapshotTestingUtils.waitForTableToBeOnline(TEST_UTIL, clonedTableName);
 
@@ -129,6 +138,9 @@ public class 
CloneSnapshotFromClientAfterSplittingRegionTestBase
 
       verifyRowCount(TEST_UTIL, clonedTableName, snapshot1Rows);
     } finally {
+      if (admin.tableExists(clonedTableName)) {
+        TEST_UTIL.deleteTable(clonedTableName);
+      }
       admin.catalogJanitorSwitch(true);
     }
   }
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/CloneSnapshotFromClientCloneLinksAfterDeleteTestBase.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/CloneSnapshotFromClientCloneLinksAfterDeleteTestBase.java
index 60f0c64cc22..2dffd502bab 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/CloneSnapshotFromClientCloneLinksAfterDeleteTestBase.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/CloneSnapshotFromClientCloneLinksAfterDeleteTestBase.java
@@ -20,16 +20,18 @@ package org.apache.hadoop.hbase.client;
 import java.io.IOException;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
-import org.junit.Test;
 
 public class CloneSnapshotFromClientCloneLinksAfterDeleteTestBase
   extends CloneSnapshotFromClientTestBase {
 
+  protected CloneSnapshotFromClientCloneLinksAfterDeleteTestBase(int 
numReplicas) {
+    super(numReplicas);
+  }
+
   /**
    * Verify that tables created from the snapshot are still alive after source 
table deletion.
    */
-  @Test
-  public void testCloneLinksAfterDelete() throws IOException, 
InterruptedException {
+  protected void testCloneLinksAfterDelete0() throws IOException, 
InterruptedException {
     // Clone a table from the first snapshot
     final TableName clonedTableName =
       TableName.valueOf(getValidMethodName() + "1-" + 
EnvironmentEdgeManager.currentTime());
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/CloneSnapshotFromClientErrorTestBase.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/CloneSnapshotFromClientErrorTestBase.java
index ac4d1d5c3a3..887b410491e 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/CloneSnapshotFromClientErrorTestBase.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/CloneSnapshotFromClientErrorTestBase.java
@@ -17,26 +17,34 @@
  */
 package org.apache.hadoop.hbase.client;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import java.io.IOException;
 import org.apache.hadoop.hbase.NamespaceNotFoundException;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.snapshot.SnapshotDoesNotExistException;
 import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
-import org.junit.Test;
+import org.junit.jupiter.api.TestTemplate;
 
 public class CloneSnapshotFromClientErrorTestBase extends 
CloneSnapshotFromClientTestBase {
 
-  @Test(expected = SnapshotDoesNotExistException.class)
+  protected CloneSnapshotFromClientErrorTestBase(int numReplicas) {
+    super(numReplicas);
+  }
+
+  @TestTemplate
   public void testCloneNonExistentSnapshot() throws IOException, 
InterruptedException {
     String snapshotName = "random-snapshot-" + 
EnvironmentEdgeManager.currentTime();
     final TableName tableName =
       TableName.valueOf(getValidMethodName() + "-" + 
EnvironmentEdgeManager.currentTime());
-    admin.cloneSnapshot(snapshotName, tableName);
+    assertThrows(SnapshotDoesNotExistException.class,
+      () -> admin.cloneSnapshot(snapshotName, tableName));
   }
 
-  @Test(expected = NamespaceNotFoundException.class)
+  @TestTemplate
   public void testCloneOnMissingNamespace() throws IOException, 
InterruptedException {
     final TableName clonedTableName = TableName.valueOf("unknownNS:" + 
getValidMethodName());
-    admin.cloneSnapshot(snapshotName1, clonedTableName);
+    assertThrows(NamespaceNotFoundException.class,
+      () -> admin.cloneSnapshot(snapshotName1, clonedTableName));
   }
 }
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/CloneSnapshotFromClientNormalTestBase.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/CloneSnapshotFromClientNormalTestBase.java
index a3205875a30..38f0acd1891 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/CloneSnapshotFromClientNormalTestBase.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/CloneSnapshotFromClientNormalTestBase.java
@@ -22,11 +22,15 @@ import org.apache.hadoop.hbase.NamespaceDescriptor;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils;
 import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
-import org.junit.Test;
+import org.junit.jupiter.api.TestTemplate;
 
 public class CloneSnapshotFromClientNormalTestBase extends 
CloneSnapshotFromClientTestBase {
 
-  @Test
+  protected CloneSnapshotFromClientNormalTestBase(int numReplicas) {
+    super(numReplicas);
+  }
+
+  @TestTemplate
   public void testCloneSnapshot() throws IOException, InterruptedException {
     TableName clonedTableName =
       TableName.valueOf(getValidMethodName() + "-" + 
EnvironmentEdgeManager.currentTime());
@@ -46,10 +50,10 @@ public class CloneSnapshotFromClientNormalTestBase extends 
CloneSnapshotFromClie
   }
 
   private void verifyReplicasCameOnline(TableName tableName) throws 
IOException {
-    SnapshotTestingUtils.verifyReplicasCameOnline(tableName, admin, 
getNumReplicas());
+    SnapshotTestingUtils.verifyReplicasCameOnline(tableName, admin, 
numReplicas);
   }
 
-  @Test
+  @TestTemplate
   public void testCloneSnapshotCrossNamespace() throws IOException, 
InterruptedException {
     String nsName = getValidMethodName() + "_ns_" + 
EnvironmentEdgeManager.currentTime();
     admin.createNamespace(NamespaceDescriptor.create(nsName).build());
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/CloneSnapshotFromClientTestBase.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/CloneSnapshotFromClientTestBase.java
index 26d93e27507..4b2ac715c96 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/CloneSnapshotFromClientTestBase.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/CloneSnapshotFromClientTestBase.java
@@ -18,6 +18,7 @@
 package org.apache.hadoop.hbase.client;
 
 import java.io.IOException;
+import java.util.stream.Stream;
 import org.apache.hadoop.hbase.HBaseTestingUtil;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.TableName;
@@ -25,12 +26,11 @@ import 
org.apache.hadoop.hbase.master.snapshot.SnapshotManager;
 import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.rules.TestName;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.TestInfo;
+import org.junit.jupiter.params.provider.Arguments;
 
 /**
  * Base class for testing clone snapsot
@@ -50,8 +50,17 @@ public class CloneSnapshotFromClientTestBase {
   protected int snapshot1Rows;
   protected Admin admin;
 
-  @Rule
-  public TestName name = new TestName();
+  protected int numReplicas;
+
+  private String testName;
+
+  protected CloneSnapshotFromClientTestBase(int numReplicas) {
+    this.numReplicas = numReplicas;
+  }
+
+  public static Stream<Arguments> parameters() {
+    return Stream.of(Arguments.of(1), Arguments.of(3));
+  }
 
   protected static void setupConfiguration() {
     
TEST_UTIL.getConfiguration().setBoolean(SnapshotManager.HBASE_SNAPSHOT_ENABLED, 
true);
@@ -63,19 +72,13 @@ public class CloneSnapshotFromClientTestBase {
     
TEST_UTIL.getConfiguration().setBoolean("hbase.regionserver.compaction.enabled",
 false);
   }
 
-  @BeforeClass
-  public static void setUpBeforeClass() throws Exception {
-    setupConfiguration();
-    TEST_UTIL.startMiniCluster(3);
-  }
-
-  @AfterClass
+  @AfterAll
   public static void tearDownAfterClass() throws Exception {
     TEST_UTIL.shutdownMiniCluster();
   }
 
   protected final String getValidMethodName() {
-    return name.getMethodName().replaceAll("[^0-9A-Za-z_]", "_");
+    return testName;
   }
 
   /**
@@ -83,10 +86,12 @@ public class CloneSnapshotFromClientTestBase {
    * snapshotName1) of different states. The tableName, snapshotNames and the 
number of rows in the
    * snapshot are initialized.
    */
-  @Before
-  public void setup() throws Exception {
+  @BeforeEach
+  public void setUp(TestInfo testInfo) throws Exception {
     this.admin = TEST_UTIL.getAdmin();
     long tid = EnvironmentEdgeManager.currentTime();
+    testName = testInfo.getTestMethod().get().getName()
+      + testInfo.getDisplayName().replaceAll("[^0-9A-Za-z_]", "_");
     tableName = TableName.valueOf(getValidMethodName() + tid);
     emptySnapshot = "emptySnaptb-" + tid;
     snapshotName0 = "snaptb0-" + tid;
@@ -97,7 +102,7 @@ public class CloneSnapshotFromClientTestBase {
   }
 
   protected void createTable() throws IOException, InterruptedException {
-    SnapshotTestingUtils.createTable(TEST_UTIL, tableName, getNumReplicas(), 
FAMILY);
+    SnapshotTestingUtils.createTable(TEST_UTIL, tableName, numReplicas, 
FAMILY);
   }
 
   protected int numRowsToLoad() {
@@ -105,7 +110,7 @@ public class CloneSnapshotFromClientTestBase {
   }
 
   protected int countRows(Table table) throws IOException {
-    return TEST_UTIL.countRows(table);
+    return HBaseTestingUtil.countRows(table);
   }
 
   private void createTableAndSnapshots() throws Exception {
@@ -142,16 +147,12 @@ public class CloneSnapshotFromClientTestBase {
     admin.enableTable(tableName);
   }
 
-  protected int getNumReplicas() {
-    return 1;
-  }
-
   protected void verifyRowCount(final HBaseTestingUtil util, final TableName 
tableName,
     long expectedRows) throws IOException {
     SnapshotTestingUtils.verifyRowCount(util, tableName, expectedRows);
   }
 
-  @After
+  @AfterEach
   public void tearDown() throws Exception {
     if (admin.tableExists(tableName)) {
       TEST_UTIL.deleteTable(tableName);
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestCloneSnapshotFromClientAfterSplittingRegion.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestCloneSnapshotFromClientAfterSplittingRegion.java
index 2a1eedcd3b7..4f037866758 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestCloneSnapshotFromClientAfterSplittingRegion.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestCloneSnapshotFromClientAfterSplittingRegion.java
@@ -17,37 +17,25 @@
  */
 package org.apache.hadoop.hbase.client;
 
-import java.util.Arrays;
-import java.util.List;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HBaseParameterizedTestTemplate;
 import org.apache.hadoop.hbase.testclassification.ClientTests;
 import org.apache.hadoop.hbase.testclassification.LargeTests;
-import org.junit.ClassRule;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameter;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
 
-@RunWith(Parameterized.class)
-@Category({ LargeTests.class, ClientTests.class })
+@Tag(LargeTests.TAG)
+@Tag(ClientTests.TAG)
+@HBaseParameterizedTestTemplate(name = "{index}: regionReplication={0}")
 public class TestCloneSnapshotFromClientAfterSplittingRegion
   extends CloneSnapshotFromClientAfterSplittingRegionTestBase {
 
-  @ClassRule
-  public static final HBaseClassTestRule CLASS_RULE =
-    
HBaseClassTestRule.forClass(TestCloneSnapshotFromClientAfterSplittingRegion.class);
-
-  @Parameter
-  public int numReplicas;
-
-  @Parameters(name = "{index}: regionReplication={0}")
-  public static List<Object[]> params() {
-    return Arrays.asList(new Object[] { 1 }, new Object[] { 3 });
+  public TestCloneSnapshotFromClientAfterSplittingRegion(int numReplicas) {
+    super(numReplicas);
   }
 
-  @Override
-  protected int getNumReplicas() {
-    return numReplicas;
+  @BeforeAll
+  public static void setUpBeforeClass() throws Exception {
+    setupConfiguration();
+    TEST_UTIL.startMiniCluster(3);
   }
 }
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestCloneSnapshotFromClientCloneLinksAfterDelete.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestCloneSnapshotFromClientCloneLinksAfterDelete.java
index c70c58513c6..c6bab38cdbd 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestCloneSnapshotFromClientCloneLinksAfterDelete.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestCloneSnapshotFromClientCloneLinksAfterDelete.java
@@ -17,38 +17,32 @@
  */
 package org.apache.hadoop.hbase.client;
 
-import java.util.Arrays;
-import java.util.List;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import java.io.IOException;
+import org.apache.hadoop.hbase.HBaseParameterizedTestTemplate;
 import org.apache.hadoop.hbase.testclassification.ClientTests;
 import org.apache.hadoop.hbase.testclassification.LargeTests;
-import org.junit.ClassRule;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameter;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.TestTemplate;
 
-@RunWith(Parameterized.class)
-@Category({ LargeTests.class, ClientTests.class })
+@Tag(LargeTests.TAG)
+@Tag(ClientTests.TAG)
+@HBaseParameterizedTestTemplate(name = "{index}: regionReplication={0}")
 public class TestCloneSnapshotFromClientCloneLinksAfterDelete
   extends CloneSnapshotFromClientCloneLinksAfterDeleteTestBase {
 
-  @ClassRule
-  public static final HBaseClassTestRule CLASS_RULE =
-    
HBaseClassTestRule.forClass(TestCloneSnapshotFromClientCloneLinksAfterDelete.class);
-
-  @Parameter
-  public int numReplicas;
-
-  @Parameters(name = "{index}: regionReplication={0}")
-  public static List<Object[]> params() {
-    return Arrays.asList(new Object[] { 1 }, new Object[] { 3 });
+  public TestCloneSnapshotFromClientCloneLinksAfterDelete(int numReplicas) {
+    super(numReplicas);
   }
 
-  @Override
-  protected int getNumReplicas() {
-    return numReplicas;
+  @BeforeAll
+  public static void setUpBeforeClass() throws Exception {
+    setupConfiguration();
+    TEST_UTIL.startMiniCluster(3);
   }
 
+  @TestTemplate
+  public void testCloneLinksAfterDelete() throws IOException, 
InterruptedException {
+    testCloneLinksAfterDelete0();
+  }
 }
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestCloneSnapshotFromClientCustomSFT.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestCloneSnapshotFromClientCustomSFT.java
index f64b75a02ae..7ac7052724c 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestCloneSnapshotFromClientCustomSFT.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestCloneSnapshotFromClientCustomSFT.java
@@ -17,26 +17,32 @@
  */
 package org.apache.hadoop.hbase.client;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import java.io.IOException;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
 import org.apache.hadoop.hbase.TableName;
 import 
org.apache.hadoop.hbase.regionserver.storefiletracker.StoreFileTrackerFactory;
 import org.apache.hadoop.hbase.testclassification.ClientTests;
 import org.apache.hadoop.hbase.testclassification.LargeTests;
 import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
 
-@Category({ LargeTests.class, ClientTests.class })
+@Tag(LargeTests.TAG)
+@Tag(ClientTests.TAG)
 public class TestCloneSnapshotFromClientCustomSFT extends 
CloneSnapshotFromClientTestBase {
 
-  @ClassRule
-  public static final HBaseClassTestRule CLASS_RULE =
-    HBaseClassTestRule.forClass(TestCloneSnapshotFromClientCustomSFT.class);
+  protected TestCloneSnapshotFromClientCustomSFT() {
+    super(1);
+  }
+
+  @BeforeAll
+  public static void setUpBeforeClass() throws Exception {
+    setupConfiguration();
+    TEST_UTIL.startMiniCluster(3);
+  }
 
   public static final String CLONE_SFT = "FILE";
 
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestCloneSnapshotFromClientError.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestCloneSnapshotFromClientError.java
index ea02b7ee0ab..00fe8900405 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestCloneSnapshotFromClientError.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestCloneSnapshotFromClientError.java
@@ -17,36 +17,24 @@
  */
 package org.apache.hadoop.hbase.client;
 
-import java.util.Arrays;
-import java.util.List;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HBaseParameterizedTestTemplate;
 import org.apache.hadoop.hbase.testclassification.ClientTests;
 import org.apache.hadoop.hbase.testclassification.LargeTests;
-import org.junit.ClassRule;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameter;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
 
-@RunWith(Parameterized.class)
-@Category({ LargeTests.class, ClientTests.class })
+@Tag(LargeTests.TAG)
+@Tag(ClientTests.TAG)
+@HBaseParameterizedTestTemplate(name = "{index}: regionReplication={0}")
 public class TestCloneSnapshotFromClientError extends 
CloneSnapshotFromClientErrorTestBase {
 
-  @ClassRule
-  public static final HBaseClassTestRule CLASS_RULE =
-    HBaseClassTestRule.forClass(TestCloneSnapshotFromClientError.class);
-
-  @Parameter
-  public int numReplicas;
-
-  @Parameters(name = "{index}: regionReplication={0}")
-  public static List<Object[]> params() {
-    return Arrays.asList(new Object[] { 1 }, new Object[] { 3 });
+  public TestCloneSnapshotFromClientError(int numReplicas) {
+    super(numReplicas);
   }
 
-  @Override
-  protected int getNumReplicas() {
-    return numReplicas;
+  @BeforeAll
+  public static void setUpBeforeClass() throws Exception {
+    setupConfiguration();
+    TEST_UTIL.startMiniCluster(3);
   }
 }
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestCloneSnapshotFromClientNormal.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestCloneSnapshotFromClientNormal.java
index d52d7a2ce53..1acb63c4765 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestCloneSnapshotFromClientNormal.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestCloneSnapshotFromClientNormal.java
@@ -17,36 +17,24 @@
  */
 package org.apache.hadoop.hbase.client;
 
-import java.util.Arrays;
-import java.util.List;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HBaseParameterizedTestTemplate;
 import org.apache.hadoop.hbase.testclassification.ClientTests;
 import org.apache.hadoop.hbase.testclassification.LargeTests;
-import org.junit.ClassRule;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameter;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
 
-@RunWith(Parameterized.class)
-@Category({ LargeTests.class, ClientTests.class })
+@Tag(LargeTests.TAG)
+@Tag(ClientTests.TAG)
+@HBaseParameterizedTestTemplate(name = "{index}: regionReplication={0}")
 public class TestCloneSnapshotFromClientNormal extends 
CloneSnapshotFromClientNormalTestBase {
 
-  @ClassRule
-  public static final HBaseClassTestRule CLASS_RULE =
-    HBaseClassTestRule.forClass(TestCloneSnapshotFromClientNormal.class);
-
-  @Parameter
-  public int numReplicas;
-
-  @Parameters(name = "{index}: regionReplication={0}")
-  public static List<Object[]> params() {
-    return Arrays.asList(new Object[] { 1 }, new Object[] { 3 });
+  public TestCloneSnapshotFromClientNormal(int numReplicas) {
+    super(numReplicas);
   }
 
-  @Override
-  protected int getNumReplicas() {
-    return numReplicas;
+  @BeforeAll
+  public static void setUpBeforeClass() throws Exception {
+    setupConfiguration();
+    TEST_UTIL.startMiniCluster(3);
   }
 }
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMobCloneSnapshotFromClientAfterSplittingRegion.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMobCloneSnapshotFromClientAfterSplittingRegion.java
index 9c7cbd8380d..96f7f5490e4 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMobCloneSnapshotFromClientAfterSplittingRegion.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMobCloneSnapshotFromClientAfterSplittingRegion.java
@@ -18,32 +18,34 @@
 package org.apache.hadoop.hbase.client;
 
 import java.io.IOException;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HBaseParameterizedTestTemplate;
 import org.apache.hadoop.hbase.master.cleaner.TimeToLiveHFileCleaner;
 import org.apache.hadoop.hbase.mob.MobConstants;
 import org.apache.hadoop.hbase.snapshot.MobSnapshotTestingUtils;
 import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils;
 import org.apache.hadoop.hbase.testclassification.ClientTests;
 import org.apache.hadoop.hbase.testclassification.LargeTests;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
 
-@Category({ LargeTests.class, ClientTests.class })
+@Tag(LargeTests.TAG)
+@Tag(ClientTests.TAG)
+@HBaseParameterizedTestTemplate(name = "{index}: regionReplication={0}")
 public class TestMobCloneSnapshotFromClientAfterSplittingRegion
   extends CloneSnapshotFromClientAfterSplittingRegionTestBase {
 
-  @ClassRule
-  public static final HBaseClassTestRule CLASS_RULE =
-    
HBaseClassTestRule.forClass(TestMobCloneSnapshotFromClientAfterSplittingRegion.class);
+  public TestMobCloneSnapshotFromClientAfterSplittingRegion(int numReplicas) {
+    super(numReplicas);
+  }
 
   protected static void setupConfiguration() {
     CloneSnapshotFromClientTestBase.setupConfiguration();
+
     TEST_UTIL.getConfiguration().setLong(TimeToLiveHFileCleaner.TTL_CONF_KEY, 
0);
     TEST_UTIL.getConfiguration().setInt(MobConstants.MOB_FILE_CACHE_SIZE_KEY, 
0);
   }
 
-  @BeforeClass
+  @BeforeAll
   public static void setUpBeforeClass() throws Exception {
     setupConfiguration();
     TEST_UTIL.startMiniCluster(3);
@@ -52,7 +54,7 @@ public class 
TestMobCloneSnapshotFromClientAfterSplittingRegion
   @Override
   protected void createTable() throws IOException, InterruptedException {
     MobSnapshotTestingUtils.createMobTable(TEST_UTIL, tableName,
-      SnapshotTestingUtils.getSplitKeys(), getNumReplicas(), FAMILY);
+      SnapshotTestingUtils.getSplitKeys(), numReplicas, FAMILY);
   }
 
   @Override
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMobCloneSnapshotFromClientCloneLinksAfterDelete.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMobCloneSnapshotFromClientCloneLinksAfterDelete.java
index e50be218747..34cc3a179db 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMobCloneSnapshotFromClientCloneLinksAfterDelete.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMobCloneSnapshotFromClientCloneLinksAfterDelete.java
@@ -20,7 +20,7 @@ package org.apache.hadoop.hbase.client;
 import java.io.IOException;
 import java.io.InterruptedIOException;
 import java.util.Optional;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HBaseParameterizedTestTemplate;
 import org.apache.hadoop.hbase.HBaseTestingUtil;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.TableName;
@@ -38,18 +38,19 @@ import 
org.apache.hadoop.hbase.testclassification.ClientTests;
 import org.apache.hadoop.hbase.testclassification.LargeTests;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.TestTemplate;
 
-@Category({ LargeTests.class, ClientTests.class })
+@Tag(LargeTests.TAG)
+@Tag(ClientTests.TAG)
+@HBaseParameterizedTestTemplate(name = "{index}: regionReplication={0}")
 public class TestMobCloneSnapshotFromClientCloneLinksAfterDelete
   extends CloneSnapshotFromClientCloneLinksAfterDeleteTestBase {
 
-  @ClassRule
-  public static final HBaseClassTestRule CLASS_RULE =
-    
HBaseClassTestRule.forClass(TestMobCloneSnapshotFromClientCloneLinksAfterDelete.class);
+  public TestMobCloneSnapshotFromClientCloneLinksAfterDelete(int numReplicas) {
+    super(numReplicas);
+  }
 
   private static boolean delayFlush = false;
 
@@ -87,7 +88,7 @@ public class 
TestMobCloneSnapshotFromClientCloneLinksAfterDelete
     TEST_UTIL.getConfiguration().setInt(MobConstants.MOB_FILE_CACHE_SIZE_KEY, 
0);
   }
 
-  @BeforeClass
+  @BeforeAll
   public static void setUpBeforeClass() throws Exception {
     setupConfiguration();
     TEST_UTIL.startMiniCluster(3);
@@ -96,7 +97,7 @@ public class 
TestMobCloneSnapshotFromClientCloneLinksAfterDelete
   @Override
   protected void createTable() throws IOException, InterruptedException {
     MobSnapshotTestingUtils.createMobTable(TEST_UTIL, tableName,
-      SnapshotTestingUtils.getSplitKeys(), getNumReplicas(),
+      SnapshotTestingUtils.getSplitKeys(), numReplicas,
       StoreFileTrackerFactory.Trackers.DEFAULT.name(), 
DelayFlushCoprocessor.class.getName(),
       FAMILY);
   }
@@ -111,8 +112,7 @@ public class 
TestMobCloneSnapshotFromClientCloneLinksAfterDelete
     return MobSnapshotTestingUtils.countMobRows(table);
   }
 
-  @Test
-  @Override
+  @TestTemplate
   public void testCloneLinksAfterDelete() throws IOException, 
InterruptedException {
     // delay the flush to make sure
     delayFlush = true;
@@ -120,7 +120,7 @@ public class 
TestMobCloneSnapshotFromClientCloneLinksAfterDelete
     long tid = EnvironmentEdgeManager.currentTime();
     String snapshotName3 = "snaptb3-" + tid;
     TableName clonedTableName3 =
-      TableName.valueOf(name.getMethodName() + 
EnvironmentEdgeManager.currentTime());
+      TableName.valueOf(getValidMethodName() + 
EnvironmentEdgeManager.currentTime());
     admin.snapshot(snapshotName3, tableName);
     delayFlush = false;
     int snapshot3Rows = -1;
@@ -129,7 +129,7 @@ public class 
TestMobCloneSnapshotFromClientCloneLinksAfterDelete
     }
     admin.cloneSnapshot(snapshotName3, clonedTableName3);
     admin.deleteSnapshot(snapshotName3);
-    super.testCloneLinksAfterDelete();
+    testCloneLinksAfterDelete0();
     verifyRowCount(TEST_UTIL, clonedTableName3, snapshot3Rows);
     admin.disableTable(clonedTableName3);
     admin.deleteTable(clonedTableName3);
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMobCloneSnapshotFromClientError.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMobCloneSnapshotFromClientError.java
index 0de32ddf4f5..54b7bb3ab5b 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMobCloneSnapshotFromClientError.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMobCloneSnapshotFromClientError.java
@@ -18,23 +18,24 @@
 package org.apache.hadoop.hbase.client;
 
 import java.io.IOException;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HBaseParameterizedTestTemplate;
 import org.apache.hadoop.hbase.master.cleaner.TimeToLiveHFileCleaner;
 import org.apache.hadoop.hbase.mob.MobConstants;
 import org.apache.hadoop.hbase.snapshot.MobSnapshotTestingUtils;
 import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils;
 import org.apache.hadoop.hbase.testclassification.ClientTests;
 import org.apache.hadoop.hbase.testclassification.LargeTests;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
 
-@Category({ LargeTests.class, ClientTests.class })
+@Tag(LargeTests.TAG)
+@Tag(ClientTests.TAG)
+@HBaseParameterizedTestTemplate(name = "{index}: regionReplication={0}")
 public class TestMobCloneSnapshotFromClientError extends 
CloneSnapshotFromClientErrorTestBase {
 
-  @ClassRule
-  public static final HBaseClassTestRule CLASS_RULE =
-    HBaseClassTestRule.forClass(TestMobCloneSnapshotFromClientError.class);
+  public TestMobCloneSnapshotFromClientError(int numReplicas) {
+    super(numReplicas);
+  }
 
   protected static void setupConfiguration() {
     CloneSnapshotFromClientTestBase.setupConfiguration();
@@ -42,7 +43,7 @@ public class TestMobCloneSnapshotFromClientError extends 
CloneSnapshotFromClient
     TEST_UTIL.getConfiguration().setInt(MobConstants.MOB_FILE_CACHE_SIZE_KEY, 
0);
   }
 
-  @BeforeClass
+  @BeforeAll
   public static void setUpBeforeClass() throws Exception {
     setupConfiguration();
     TEST_UTIL.startMiniCluster(3);
@@ -51,7 +52,7 @@ public class TestMobCloneSnapshotFromClientError extends 
CloneSnapshotFromClient
   @Override
   protected void createTable() throws IOException, InterruptedException {
     MobSnapshotTestingUtils.createMobTable(TEST_UTIL, tableName,
-      SnapshotTestingUtils.getSplitKeys(), getNumReplicas(), FAMILY);
+      SnapshotTestingUtils.getSplitKeys(), numReplicas, FAMILY);
   }
 
   @Override
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMobCloneSnapshotFromClientNormal.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMobCloneSnapshotFromClientNormal.java
index c5a33eedd03..8133718b2b5 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMobCloneSnapshotFromClientNormal.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMobCloneSnapshotFromClientNormal.java
@@ -18,7 +18,7 @@
 package org.apache.hadoop.hbase.client;
 
 import java.io.IOException;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HBaseParameterizedTestTemplate;
 import org.apache.hadoop.hbase.HBaseTestingUtil;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.master.cleaner.TimeToLiveHFileCleaner;
@@ -27,16 +27,17 @@ import 
org.apache.hadoop.hbase.snapshot.MobSnapshotTestingUtils;
 import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils;
 import org.apache.hadoop.hbase.testclassification.ClientTests;
 import org.apache.hadoop.hbase.testclassification.LargeTests;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
 
-@Category({ LargeTests.class, ClientTests.class })
+@Tag(LargeTests.TAG)
+@Tag(ClientTests.TAG)
+@HBaseParameterizedTestTemplate(name = "{index}: regionReplication={0}")
 public class TestMobCloneSnapshotFromClientNormal extends 
CloneSnapshotFromClientNormalTestBase {
 
-  @ClassRule
-  public static final HBaseClassTestRule CLASS_RULE =
-    HBaseClassTestRule.forClass(TestMobCloneSnapshotFromClientNormal.class);
+  public TestMobCloneSnapshotFromClientNormal(int numReplicas) {
+    super(numReplicas);
+  }
 
   protected static void setupConfiguration() {
     CloneSnapshotFromClientTestBase.setupConfiguration();
@@ -44,7 +45,7 @@ public class TestMobCloneSnapshotFromClientNormal extends 
CloneSnapshotFromClien
     TEST_UTIL.getConfiguration().setInt(MobConstants.MOB_FILE_CACHE_SIZE_KEY, 
0);
   }
 
-  @BeforeClass
+  @BeforeAll
   public static void setUpBeforeClass() throws Exception {
     setupConfiguration();
     TEST_UTIL.startMiniCluster(3);
@@ -53,7 +54,7 @@ public class TestMobCloneSnapshotFromClientNormal extends 
CloneSnapshotFromClien
   @Override
   protected void createTable() throws IOException, InterruptedException {
     MobSnapshotTestingUtils.createMobTable(TEST_UTIL, tableName,
-      SnapshotTestingUtils.getSplitKeys(), getNumReplicas(), FAMILY);
+      SnapshotTestingUtils.getSplitKeys(), numReplicas, FAMILY);
   }
 
   @Override


Reply via email to