Copilot commented on code in PR #8200:
URL: https://github.com/apache/hbase/pull/8200#discussion_r3202185408
##########
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSecureBulkloadListener.java:
##########
@@ -35,29 +39,22 @@
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hdfs.DistributedFileSystem;
import org.apache.hadoop.hdfs.MiniDFSCluster;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TemporaryFolder;
-import org.junit.rules.TestName;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
+import org.junit.jupiter.api.io.TempDir;
/**
* Tests for failedBulkLoad logic to make sure staged files are returned to
their original location
* if the bulkload have failed.
*/
-@Category({ MiscTests.class, LargeTests.class })
+@Tag(MiscTests.TAG)
+@Tag(LargeTests.TAG)
public class TestSecureBulkloadListener {
-
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestSecureBulkloadListener.class);
-
- @ClassRule
- public static TemporaryFolder testFolder = new TemporaryFolder();
+ @TempDir
+ public static File testFolder;
private Configuration conf;
Review Comment:
`@TempDir` field `testFolder` is declared but never used. Please remove it
(and the related import) or use it to back any filesystem paths you intend to
keep isolated per test.
##########
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestWALMonotonicallyIncreasingSeqId.java:
##########
@@ -184,22 +177,27 @@ public void run() {
}
}
- @Before
- public void setUp() throws IOException {
+ @BeforeEach
+ public void setUp(TestInfo testInfo) throws IOException {
+ this.name = testInfo.getTestMethod().get().getName();
byte[][] families = new byte[][] { Bytes.toBytes("cf") };
- TableDescriptor htd = getTableDesc(
- TableName.valueOf(name.getMethodName().replaceAll("[^0-9A-Za-z_]",
"_")), families);
+ TableDescriptor htd =
+ getTableDesc(TableName.valueOf(name.replaceAll("[^0-9A-Za-z_]", "_")),
families);
region = initHRegion(htd, HConstants.EMPTY_START_ROW,
HConstants.EMPTY_END_ROW, 0);
Review Comment:
In this `@TestTemplate` (parameterized) test, `name` is derived only from
`testInfo.getTestMethod().get().getName()`, so both parameter invocations will
use the same table name and therefore the same on-disk table directory under
the static `testDir`. Because cleanup only happens in `@AfterAll`, the second
parameter run can see leftover data/files from the first run, making the test
order-dependent/flaky. Use a per-invocation unique identifier (e.g.,
`testInfo.getDisplayName()` or append `walProvider`/parameter index) when
constructing the `TableName`/paths, or clean the testDir in `@AfterEach`.
##########
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSyncTimeRangeTracker.java:
##########
@@ -17,23 +17,12 @@
*/
package org.apache.hadoop.hbase.regionserver;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.concurrent.ThreadLocalRandom;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
-import org.apache.hadoop.hbase.testclassification.MediumTests;
-import org.apache.hadoop.hbase.testclassification.RegionServerTests;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-@Category({ RegionServerTests.class, MediumTests.class })
-public class TestSyncTimeRangeTracker extends TestSimpleTimeRangeTracker {
-
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestSyncTimeRangeTracker.class);
+import org.junit.jupiter.api.Test;
+public class TestSyncTimeRangeTracker extends TestSimpleTimeRangeTracker {
private static final int NUM_KEYS = 8000000;
Review Comment:
This test lost its RegionServer/Medium test classification annotations
during the JUnit5 migration. Without `@Tag(RegionServerTests.TAG)` and
`@Tag(MediumTests.TAG)`, it will no longer be selected/filtered consistently by
the existing test suites.
--
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]