Apache9 commented on code in PR #8099:
URL: https://github.com/apache/hbase/pull/8099#discussion_r3142138681


##########
hbase-server/src/test/java/org/apache/hadoop/hbase/client/AbstractTestAsyncTableScan.java:
##########
@@ -44,82 +45,66 @@
 import java.util.stream.Collectors;
 import java.util.stream.IntStream;
 import java.util.stream.Stream;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.ConnectionRule;
 import org.apache.hadoop.hbase.HBaseTestingUtil;
 import org.apache.hadoop.hbase.MatcherPredicate;
-import org.apache.hadoop.hbase.MiniClusterRule;
-import org.apache.hadoop.hbase.StartTestingClusterOption;
 import org.apache.hadoop.hbase.TableName;
-import org.apache.hadoop.hbase.Waiter;
 import org.apache.hadoop.hbase.ipc.RemoteWithExtrasException;
 import org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException;
 import org.apache.hadoop.hbase.trace.HBaseSemanticAttributes;
-import org.apache.hadoop.hbase.trace.OpenTelemetryClassRule;
-import org.apache.hadoop.hbase.trace.OpenTelemetryTestRule;
 import org.apache.hadoop.hbase.trace.TraceUtil;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.JVMClusterUtil;
 import org.apache.hadoop.hbase.util.Pair;
 import org.hamcrest.Matcher;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExternalResource;
-import org.junit.rules.RuleChain;
-import org.junit.rules.TestName;
-import org.junit.rules.TestRule;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.TestInfo;
+import org.junit.jupiter.api.TestTemplate;
+import org.junit.jupiter.api.extension.RegisterExtension;
+import org.junit.jupiter.params.provider.Arguments;
 
-public abstract class AbstractTestAsyncTableScan {
+import org.apache.hbase.thirdparty.com.google.common.io.Closeables;
 
-  protected static final OpenTelemetryClassRule OTEL_CLASS_RULE = 
OpenTelemetryClassRule.create();
+public abstract class AbstractTestAsyncTableScan {
 
-  private static Configuration createConfiguration() {
-    Configuration conf = new Configuration();
-    // Disable directory sharing to prevent race conditions when tests run in 
parallel.
-    // Each test instance gets its own isolated directories to avoid one 
test's tearDown()
-    // deleting directories another parallel test is still using.
-    conf.setBoolean("hbase.test.disable-directory-sharing", true);
-    return conf;
-  }
+  @RegisterExtension
+  protected static final OpenTelemetryExtension OTEL_EXT = 
OpenTelemetryExtension.create();
 
-  protected static final MiniClusterRule MINI_CLUSTER_RULE =
-    MiniClusterRule.newBuilder().setConfiguration(createConfiguration())
-      
.setMiniClusterOption(StartTestingClusterOption.builder().numWorkers(3).build()).build();
+  protected static final HBaseTestingUtil UTIL = new HBaseTestingUtil();
 
-  protected static final ConnectionRule CONN_RULE =
-    
ConnectionRule.createAsyncConnectionRule(MINI_CLUSTER_RULE::createAsyncConnection);
+  protected static AsyncConnection CONN;
 
-  private static final class Setup extends ExternalResource {
-    @Override
-    protected void before() throws Throwable {
-      final HBaseTestingUtil testingUtil = 
MINI_CLUSTER_RULE.getTestingUtility();
-      final AsyncConnection conn = CONN_RULE.getAsyncConnection();
+  protected String methodName;
 
-      byte[][] splitKeys = new byte[8][];
-      for (int i = 111; i < 999; i += 111) {
-        splitKeys[i / 111 - 1] = Bytes.toBytes(String.format("%03d", i));
-      }
-      testingUtil.createTable(TABLE_NAME, FAMILY, splitKeys);
-      testingUtil.waitTableAvailable(TABLE_NAME);
-      conn.getTable(TABLE_NAME)
-        .putAll(IntStream.range(0, COUNT)
-          .mapToObj(i -> new Put(Bytes.toBytes(String.format("%03d", i)))
-            .addColumn(FAMILY, CQ1, Bytes.toBytes(i)).addColumn(FAMILY, CQ2, 
Bytes.toBytes(i * i)))
-          .collect(Collectors.toList()))
-        .get();
+  @BeforeAll
+  public static void setUpBeforeClass() throws Exception {
+    UTIL.startMiniCluster(3);
+    byte[][] splitKeys = new byte[8][];
+    for (int i = 111; i < 999; i += 111) {
+      splitKeys[i / 111 - 1] = Bytes.toBytes(String.format("%03d", i));
     }
+    UTIL.createTable(TABLE_NAME, FAMILY, splitKeys);
+    UTIL.waitTableAvailable(TABLE_NAME);
+    try (Table table = UTIL.getConnection().getTable(TABLE_NAME)) {
+      table.put(IntStream.range(0, COUNT)
+        .mapToObj(i -> new Put(Bytes.toBytes(String.format("%03d", i)))
+          .addColumn(FAMILY, CQ1, Bytes.toBytes(i)).addColumn(FAMILY, CQ2, 
Bytes.toBytes(i * i)))
+        .collect(Collectors.toList()));
+    }
+    CONN = 
ConnectionFactory.createAsyncConnection(UTIL.getConfiguration()).get();
   }
 
-  @ClassRule
-  public static final TestRule classRule = RuleChain.outerRule(OTEL_CLASS_RULE)
-    .around(MINI_CLUSTER_RULE).around(CONN_RULE).around(new Setup());
-
-  @Rule
-  public final OpenTelemetryTestRule otelTestRule = new 
OpenTelemetryTestRule(OTEL_CLASS_RULE);
+  @AfterAll
+  public static void tearDownAfterClass() throws Exception {
+    Closeables.close(CONN, true);
+    UTIL.shutdownMiniCluster();
+  }
 
-  @Rule
-  public final TestName testName = new TestName();
+  @BeforeEach
+  public void setUp(TestInfo testInfo) {
+    methodName = testInfo.getTestMethod().get().getName();

Review Comment:
   We need to use methodName here, it is used to get span name.



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