From c2b74ca869a5410d8295dc1478188104a563d639 Mon Sep 17 00:00:00 2001 From: liuxiaocs7 Date: Tue, 28 Apr 2026 11:26:30 +0800 Subject: [PATCH 1/4] HBASE-30124 Upgrade hbase-server to use junit5 Part14 # Conflicts: # hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestLogRollAbort.java --- .../PerfTestCompactionPolicies.java | 31 +-- .../compactions/TestCloseChecker.java | 16 +- .../TestCompactedHFilesDischarger.java | 45 ++-- .../compactions/TestCompactor.java | 16 +- .../compactions/TestCurrentHourProvider.java | 15 +- .../TestCustomCellTieredCompactor.java | 27 +-- .../compactions/TestDateTieredCompactor.java | 44 ++-- .../compactions/TestFIFOCompactionPolicy.java | 63 +++-- .../compactions/TestOffPeakHours.java | 25 +- .../TestRowKeyDateTieringValueProvider.java | 87 ++++--- .../TestStripeCompactionPolicy.java | 80 +++---- .../compactions/TestStripeCompactor.java | 44 ++-- .../regionserver/http/TestRSStatusPage.java | 37 ++- .../TestMetricsThrottleExceptions.java | 39 ++- .../AbstractTestScanQueryMatcher.java | 4 +- .../TestCompactionScanQueryMatcher.java | 17 +- .../TestExplicitColumnTracker.java | 15 +- .../TestNewVersionBehaviorTracker.java | 15 +- .../querymatcher/TestScanDeleteTracker.java | 19 +- .../TestScanWildcardColumnTracker.java | 17 +- .../TestUserScanQueryMatcher.java | 40 ++-- .../TestRegionReplicationBufferManager.java | 25 +- .../TestRegionReplicationFlushRequester.java | 17 +- .../TestRegionReplicationForFlushMarker.java | 25 +- .../TestRegionReplicationForSkipWAL.java | 25 +- ...estRegionReplicationForWriteException.java | 29 +-- .../TestRegionReplicationSink.java | 31 +-- ...ationSinkCallbackAndFlushConcurrently.java | 24 +- ...upWithLegacyRegionReplicationEndpoint.java | 27 +-- .../TestChangeStoreFileTracker.java | 226 ++++++++++-------- .../TestMigrationStoreFileTracker.java | 70 +++--- ...stRegionWithFileBasedStoreFileTracker.java | 35 ++- .../TestStoreFileListFile.java | 40 ++-- .../TestStoreFileListFilePrinter.java | 31 +-- .../TestStoreFileTrackerFactory.java | 15 +- .../TestStoreFileTrackerValidationUtils.java | 15 +- ...estCompactionWithThroughputController.java | 17 +- .../TestFlushWithThroughputController.java | 37 ++- .../throttle/TestStoreHotnessProtector.java | 30 +-- .../regionserver/wal/AbstractTestFSWAL.java | 102 ++++---- .../wal/AbstractTestLogRollPeriod.java | 10 +- .../wal/AbstractTestLogRolling.java | 63 ++--- .../wal/AbstractTestProtobufLog.java | 33 ++- .../wal/AbstractTestWALReplay.java | 57 ++--- .../wal/ProtobufLogTestHelper.java | 12 +- .../regionserver/wal/TestAsyncFSWAL.java | 25 +- .../wal/TestAsyncFSWALDurability.java | 21 +- .../wal/TestAsyncFSWALRollStuck.java | 21 +- .../wal/TestAsyncLogRollPeriod.java | 15 +- .../regionserver/wal/TestAsyncLogRolling.java | 19 +- .../wal/TestAsyncProtobufLog.java | 18 +- .../regionserver/wal/TestAsyncWALReplay.java | 26 +- .../wal/TestAsyncWALReplayCompressed.java | 15 +- .../TestAsyncWALReplayValueCompression.java | 15 +- .../wal/TestCombinedAsyncWriter.java | 35 ++- .../regionserver/wal/TestCompressor.java | 28 +-- .../wal/TestCustomWALCellCodec.java | 34 ++- .../regionserver/wal/TestDurability.java | 72 +++--- .../hbase/regionserver/wal/TestFSHLog.java | 46 ++-- .../wal/TestFSHLogDurability.java | 13 +- .../regionserver/wal/TestFSWALEntry.java | 15 +- .../regionserver/wal/TestHBaseWalOnEC.java | 58 ++--- .../regionserver/wal/TestLogRollAbort.java | 62 +++-- .../regionserver/wal/TestLogRollPeriod.java | 15 +- .../regionserver/wal/TestLogRolling.java | 78 +++--- .../wal/TestLogRollingNoCluster.java | 17 +- .../regionserver/wal/TestMetricsWAL.java | 29 ++- .../regionserver/wal/TestProtobufLog.java | 11 +- .../wal/TestSecureAsyncWALReplay.java | 15 +- .../regionserver/wal/TestSecureWALReplay.java | 27 ++- .../wal/TestSequenceIdAccounting.java | 22 +- .../regionserver/wal/TestSyncFuture.java | 32 ++- .../regionserver/wal/TestSyncFutureCache.java | 19 +- .../wal/TestWALActionsListener.java | 27 +-- .../wal/TestWALCellCodecWithCompression.java | 57 ++--- .../wal/TestWALConfiguration.java | 51 ++-- .../hbase/regionserver/wal/TestWALEdit.java | 15 +- .../hbase/regionserver/wal/TestWALReplay.java | 24 +- ...TestWALReplayBoundedLogWriterCreation.java | 25 +- .../wal/TestWALReplayCompressed.java | 25 +- .../wal/TestWALReplayValueCompression.java | 25 +- .../wal/TestWALSyncTimeoutException.java | 25 +- .../wal/WALDurabilityTestBase.java | 29 ++- 83 files changed, 1263 insertions(+), 1535 deletions(-) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/PerfTestCompactionPolicies.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/PerfTestCompactionPolicies.java index a5545e26fb3e..7bb2458618be 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/PerfTestCompactionPolicies.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/PerfTestCompactionPolicies.java @@ -25,9 +25,10 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseConfiguration; +import org.apache.hadoop.hbase.HBaseParameterizedTestTemplate; import org.apache.hadoop.hbase.client.RegionInfoBuilder; import org.apache.hadoop.hbase.logging.Log4jUtils; import org.apache.hadoop.hbase.regionserver.HStore; @@ -36,25 +37,20 @@ import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.util.ReflectionUtils; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.TestTemplate; +import org.junit.jupiter.params.provider.Arguments; /** * This is not a unit test. It is not run as part of the general unit test suite. It is for * comparing compaction policies. You must run it explicitly; e.g. mvn test * -Dtest=PerfTestCompactionPolicies */ -@Category({ RegionServerTests.class, MediumTests.class }) -@RunWith(Parameterized.class) +@Tag(RegionServerTests.TAG) +@Tag(MediumTests.TAG) +@HBaseParameterizedTestTemplate public class PerfTestCompactionPolicies extends MockStoreFileGenerator { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(PerfTestCompactionPolicies.class); - private final RatioBasedCompactionPolicy cp; private final StoreFileListGenerator generator; private final HStore store; @@ -64,8 +60,7 @@ public class PerfTestCompactionPolicies extends MockStoreFileGenerator { private final float ratio; private long written = 0; - @Parameterized.Parameters - public static Collection data() { + public static Stream parameters() { Class[] policyClasses = new Class[] { EverythingPolicy.class, RatioBasedCompactionPolicy.class, ExploringCompactionPolicy.class, }; @@ -79,7 +74,7 @@ public static Collection data() { int[] minFilesValues = new int[] { 3 }; float[] ratioValues = new float[] { 1.2f }; - List params = new ArrayList<>(maxFileValues.length * minFilesValues.length + List params = new ArrayList<>(maxFileValues.length * minFilesValues.length * fileListGenClasses.length * policyClasses.length); for (Class policyClass : policyClasses) { @@ -87,14 +82,14 @@ public static Collection data() { for (int maxFile : maxFileValues) { for (int minFile : minFilesValues) { for (float ratio : ratioValues) { - params.add(new Object[] { policyClass, genClass, maxFile, minFile, ratio }); + params.add(Arguments.of(policyClass, genClass, maxFile, minFile, ratio)); } } } } } - return params; + return params.stream(); } /** @@ -134,7 +129,7 @@ public PerfTestCompactionPolicies(final Class cpClas // Used for making paths } - @Test + @TestTemplate public final void testSelection() throws Exception { long fileDiff = 0; for (List storeFileList : generator) { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestCloseChecker.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestCloseChecker.java index 77cec11c0b2a..deeea6a91f24 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestCloseChecker.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestCloseChecker.java @@ -19,27 +19,21 @@ import static org.apache.hadoop.hbase.regionserver.compactions.CloseChecker.SIZE_LIMIT_KEY; import static org.apache.hadoop.hbase.regionserver.compactions.CloseChecker.TIME_LIMIT_KEY; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.regionserver.Store; import org.apache.hadoop.hbase.testclassification.SmallTests; 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.Tag; +import org.junit.jupiter.api.Test; -@Category(SmallTests.class) +@Tag(SmallTests.TAG) public class TestCloseChecker { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestCloseChecker.class); - @Test public void testIsClosed() { Store enableWrite = mock(Store.class); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestCompactedHFilesDischarger.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestCompactedHFilesDischarger.java index d9dd52952764..f5154c958c44 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestCompactedHFilesDischarger.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestCompactedHFilesDischarger.java @@ -17,9 +17,9 @@ */ package org.apache.hadoop.hbase.regionserver.compactions; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; import java.io.IOException; @@ -31,7 +31,6 @@ import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.CellUtil; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseTestingUtil; import org.apache.hadoop.hbase.Stoppable; import org.apache.hadoop.hbase.TableName; @@ -51,20 +50,16 @@ import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.util.Bytes; -import org.junit.After; -import org.junit.Before; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.experimental.categories.Category; +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.mockito.Mockito; -@Category({ MediumTests.class, RegionServerTests.class }) +@Tag(MediumTests.TAG) +@Tag(RegionServerTests.TAG) public class TestCompactedHFilesDischarger { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestCompactedHFilesDischarger.class); - private final HBaseTestingUtil testUtil = new HBaseTestingUtil(); private HRegion region; private final static byte[] fam = Bytes.toBytes("cf_1"); @@ -75,7 +70,7 @@ public class TestCompactedHFilesDischarger { private static AtomicInteger scanCompletedCounter = new AtomicInteger(0); private RegionServerServices rss; - @Before + @BeforeEach public void setUp() throws Exception { TableName tableName = TableName.valueOf(getClass().getSimpleName()); TableDescriptor tableDescriptor = TableDescriptorBuilder.newBuilder(tableName) @@ -90,7 +85,7 @@ public void setUp() throws Exception { Mockito.doReturn(regions).when(rss).getRegions(); } - @After + @AfterEach public void tearDown() throws IOException { counter.set(0); scanCompletedCounter.set(0); @@ -217,12 +212,12 @@ public void testCleanerWithParallelScannersAfterCompaction() throws Exception { } compactedfiles = ((HStore) store).getStoreEngine().getStoreFileManager().getCompactedfiles(); for (HStoreFile file : compactedfiles) { - assertEquals("Refcount should be 3", 0, ((HStoreFile) file).getRefCount()); + assertEquals(0, ((HStoreFile) file).getRefCount(), "Refcount should be 3"); unusedReaderCount++; } // Though there are files we are not using them for reads - assertEquals("unused reader count should be 3", 3, unusedReaderCount); - assertEquals("used reader count should be 1", 1, usedReaderCount); + assertEquals(3, unusedReaderCount, "unused reader count should be 3"); + assertEquals(1, usedReaderCount, "used reader count should be 1"); // now run the cleaner cleaner.chore(); countDown(); @@ -288,12 +283,12 @@ public void testCleanerWithParallelScanners() throws Exception { } compactedfiles = store.getStoreEngine().getStoreFileManager().getCompactedfiles(); for (HStoreFile file : compactedfiles) { - assertEquals("Refcount should be 3", 3, ((HStoreFile) file).getRefCount()); + assertEquals(3, ((HStoreFile) file).getRefCount(), "Refcount should be 3"); usedReaderCount++; } // The newly compacted file will not be used by any scanner - assertEquals("unused reader count should be 1", 1, unusedReaderCount); - assertEquals("used reader count should be 3", 3, usedReaderCount); + assertEquals(1, unusedReaderCount, "unused reader count should be 1"); + assertEquals(3, usedReaderCount, "used reader count should be 3"); // now run the cleaner cleaner.chore(); countDown(); @@ -320,12 +315,12 @@ public void testCleanerWithParallelScanners() throws Exception { } compactedfiles = ((HStore) store).getStoreEngine().getStoreFileManager().getCompactedfiles(); for (HStoreFile file : compactedfiles) { - assertEquals("Refcount should be 0", 0, file.getRefCount()); + assertEquals(0, file.getRefCount(), "Refcount should be 0"); unusedReaderCount++; } // Though there are files we are not using them for reads - assertEquals("unused reader count should be 3", 3, unusedReaderCount); - assertEquals("used reader count should be 1", 1, usedReaderCount); + assertEquals(3, unusedReaderCount, "unused reader count should be 3"); + assertEquals(1, usedReaderCount, "used reader count should be 1"); countDown(); while (scanCompletedCounter.get() != 3) { Thread.sleep(100); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestCompactor.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestCompactor.java index 94f27d24492e..c3725b017cdf 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestCompactor.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestCompactor.java @@ -19,12 +19,12 @@ import static org.apache.hadoop.hbase.regionserver.StripeStoreFileManager.STRIPE_END_KEY; import static org.apache.hadoop.hbase.regionserver.StripeStoreFileManager.STRIPE_START_KEY; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyCollection; @@ -162,8 +162,8 @@ public void verifyKvs(KeyValue[][] kvss, boolean allFiles, boolean requireMetada public void verifyBoundaries(byte[][] boundaries) { assertEquals(boundaries.length - 1, writers.size()); for (int i = 0; i < writers.size(); ++i) { - assertArrayEquals("i = " + i, boundaries[i], writers.get(i).data.get(STRIPE_START_KEY)); - assertArrayEquals("i = " + i, boundaries[i + 1], writers.get(i).data.get(STRIPE_END_KEY)); + assertArrayEquals(boundaries[i], writers.get(i).data.get(STRIPE_START_KEY), "i = " + i); + assertArrayEquals(boundaries[i + 1], writers.get(i).data.get(STRIPE_END_KEY), "i = " + i); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestCurrentHourProvider.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestCurrentHourProvider.java index 55819f133de6..633f36d9bae2 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestCurrentHourProvider.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestCurrentHourProvider.java @@ -17,28 +17,23 @@ */ package org.apache.hadoop.hbase.regionserver.compactions; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Date; import java.util.List; import java.util.TimeZone; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.testclassification.SmallTests; 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.Tag; +import org.junit.jupiter.api.Test; import org.apache.hbase.thirdparty.com.google.common.collect.Lists; -@Category({ RegionServerTests.class, SmallTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(SmallTests.TAG) public class TestCurrentHourProvider { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestCurrentHourProvider.class); - private static final List ZONE_IDS = Lists.newArrayList("UTC", "US/Pacific", "Etc/GMT+8"); /** diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestCustomCellTieredCompactor.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestCustomCellTieredCompactor.java index b727916d4070..5b6b0dbaf2a0 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestCustomCellTieredCompactor.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestCustomCellTieredCompactor.java @@ -22,16 +22,15 @@ import static org.apache.hadoop.hbase.regionserver.compactions.CustomTieredCompactor.TIERING_VALUE_PROVIDER; import static org.apache.hadoop.hbase.regionserver.compactions.RowKeyDateTieringValueProvider.TIERING_KEY_DATE_FORMAT; import static org.apache.hadoop.hbase.regionserver.compactions.RowKeyDateTieringValueProvider.TIERING_KEY_DATE_PATTERN; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseTestingUtil; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.Waiter; @@ -46,33 +45,29 @@ import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.testclassification.SmallTests; import org.apache.hadoop.hbase.util.Bytes; -import org.junit.After; -import org.junit.Before; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category({ RegionServerTests.class, SmallTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(SmallTests.TAG) public class TestCustomCellTieredCompactor { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestCustomCellTieredCompactor.class); - public static final byte[] FAMILY = Bytes.toBytes("cf"); protected HBaseTestingUtil utility; protected Admin admin; - @Before + @BeforeEach public void setUp() throws Exception { utility = new HBaseTestingUtil(); utility.getConfiguration().setInt("hbase.hfile.compaction.discharger.interval", 10); utility.startMiniCluster(); } - @After + @AfterEach public void tearDown() throws Exception { utility.shutdownMiniCluster(); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestDateTieredCompactor.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestDateTieredCompactor.java index bc638ad13f3a..9339b864747d 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestDateTieredCompactor.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestDateTieredCompactor.java @@ -19,8 +19,8 @@ import static org.apache.hadoop.hbase.regionserver.compactions.TestCompactor.createDummyRequest; import static org.apache.hadoop.hbase.regionserver.compactions.TestCompactor.createDummyStoreFile; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -31,12 +31,13 @@ import java.util.HashMap; import java.util.List; import java.util.OptionalLong; +import java.util.stream.Stream; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.CellComparatorImpl; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseConfiguration; +import org.apache.hadoop.hbase.HBaseParameterizedTestTemplate; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor; @@ -57,21 +58,14 @@ import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.testclassification.SmallTests; import org.apache.hadoop.hbase.util.Bytes; -import org.junit.ClassRule; -import org.junit.Test; -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; - -@RunWith(Parameterized.class) -@Category({ RegionServerTests.class, SmallTests.class }) -public class TestDateTieredCompactor { +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.TestTemplate; +import org.junit.jupiter.params.provider.Arguments; - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestDateTieredCompactor.class); +@Tag(RegionServerTests.TAG) +@Tag(SmallTests.TAG) +@HBaseParameterizedTestTemplate(name = "{index}: usePrivateReaders={0}") +public class TestDateTieredCompactor { private static final byte[] NAME_OF_THINGS = Bytes.toBytes("foo"); @@ -85,13 +79,15 @@ public class TestDateTieredCompactor { private static final KeyValue KV_D = new KeyValue(Bytes.toBytes("ddd"), 400L); - @Parameters(name = "{index}: usePrivateReaders={0}") - public static Iterable data() { - return Arrays.asList(new Object[] { true }, new Object[] { false }); + public static Stream parameters() { + return Stream.of(Arguments.of(true), Arguments.of(false)); } - @Parameter - public boolean usePrivateReaders; + private final boolean usePrivateReaders; + + public TestDateTieredCompactor(boolean usePrivateReaders) { + this.usePrivateReaders = usePrivateReaders; + } private DateTieredCompactor createCompactor(StoreFileWritersCapture writers, final KeyValue[] input, List storefiles) throws Exception { @@ -153,7 +149,7 @@ private static T[] a(T... a) { return a; } - @Test + @TestTemplate public void test() throws Exception { verify(a(KV_A, KV_B, KV_C, KV_D), Arrays.asList(100L, 200L, 300L, 400L, 500L), a(a(KV_A), a(KV_B), a(KV_C), a(KV_D)), true); @@ -163,7 +159,7 @@ public void test() throws Exception { new KeyValue[][] { a(KV_A, KV_B, KV_C, KV_D) }, false); } - @Test + @TestTemplate public void testEmptyOutputFile() throws Exception { StoreFileWritersCapture writers = new StoreFileWritersCapture(); CompactionRequestImpl request = createDummyRequest(); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestFIFOCompactionPolicy.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestFIFOCompactionPolicy.java index 38e1872bb994..2a1dd2edcea8 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestFIFOCompactionPolicy.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestFIFOCompactionPolicy.java @@ -17,13 +17,14 @@ */ package org.apache.hadoop.hbase.regionserver.compactions; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; import java.util.List; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.DoNotRetryIOException; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseTestingUtil; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.SingleProcessHBaseCluster; @@ -49,24 +50,17 @@ import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; import org.apache.hadoop.hbase.util.JVMClusterUtil; import org.apache.hadoop.hbase.util.TimeOffsetEnvironmentEdge; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import org.apache.hbase.thirdparty.com.google.common.base.Preconditions; -@Category({ RegionServerTests.class, MediumTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(MediumTests.TAG) public class TestFIFOCompactionPolicy { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestFIFOCompactionPolicy.class); - private static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil(); private final TableName tableName = TableName.valueOf(getClass().getSimpleName()); @@ -75,9 +69,6 @@ public class TestFIFOCompactionPolicy { private final byte[] qualifier = Bytes.toBytes("q"); - @Rule - public ExpectedException error = ExpectedException.none(); - private HStore getStoreWithName(TableName tableName) { SingleProcessHBaseCluster cluster = TEST_UTIL.getMiniHBaseCluster(); List rsts = cluster.getRegionServerThreads(); @@ -114,7 +105,7 @@ private HStore prepareData() throws IOException { return getStoreWithName(tableName); } - @BeforeClass + @BeforeAll public static void setEnvironmentEdge() throws Exception { EnvironmentEdge ee = new TimeOffsetEnvironmentEdge(); EnvironmentEdgeManager.injectEdge(ee); @@ -128,7 +119,7 @@ public static void setEnvironmentEdge() throws Exception { TEST_UTIL.startMiniCluster(1); } - @AfterClass + @AfterAll public static void resetEnvironmentEdge() throws Exception { TEST_UTIL.shutdownMiniCluster(); EnvironmentEdgeManager.reset(); @@ -155,21 +146,19 @@ public String explainFailure() throws Exception { @Test public void testSanityCheckTTL() throws IOException { - error.expect(DoNotRetryIOException.class); - error.expectMessage("Default TTL is not supported"); TableName tableName = TableName.valueOf(getClass().getSimpleName() + "-TTL"); TableDescriptor desc = TableDescriptorBuilder.newBuilder(tableName) .setValue(DefaultStoreEngine.DEFAULT_COMPACTION_POLICY_CLASS_KEY, FIFOCompactionPolicy.class.getName()) .setValue(HConstants.HBASE_REGION_SPLIT_POLICY_KEY, DisabledRegionSplitPolicy.class.getName()) .setColumnFamily(ColumnFamilyDescriptorBuilder.of(family)).build(); - TEST_UTIL.getAdmin().createTable(desc); + DoNotRetryIOException e = + assertThrows(DoNotRetryIOException.class, () -> TEST_UTIL.getAdmin().createTable(desc)); + assertTrue(e.getMessage().contains("Default TTL is not supported")); } @Test public void testSanityCheckMinVersion() throws IOException { - error.expect(DoNotRetryIOException.class); - error.expectMessage("MIN_VERSION > 0 is not supported for FIFO compaction"); TableName tableName = TableName.valueOf(getClass().getSimpleName() + "-MinVersion"); TableDescriptor desc = TableDescriptorBuilder.newBuilder(tableName) .setValue(DefaultStoreEngine.DEFAULT_COMPACTION_POLICY_CLASS_KEY, @@ -178,14 +167,13 @@ public void testSanityCheckMinVersion() throws IOException { .setColumnFamily( ColumnFamilyDescriptorBuilder.newBuilder(family).setTimeToLive(1).setMinVersions(1).build()) .build(); - TEST_UTIL.getAdmin().createTable(desc); + DoNotRetryIOException e = + assertThrows(DoNotRetryIOException.class, () -> TEST_UTIL.getAdmin().createTable(desc)); + assertTrue(e.getMessage().contains("MIN_VERSION > 0 is not supported for FIFO compaction")); } @Test public void testSanityCheckBlockingStoreFiles() throws IOException { - error.expect(DoNotRetryIOException.class); - error.expectMessage("Blocking file count 'hbase.hstore.blockingStoreFiles'"); - error.expectMessage("is below recommended minimum of 1000 for column family"); TableName tableName = TableName.valueOf(getClass().getSimpleName() + "-BlockingStoreFiles"); TableDescriptor desc = TableDescriptorBuilder.newBuilder(tableName) .setValue(DefaultStoreEngine.DEFAULT_COMPACTION_POLICY_CLASS_KEY, @@ -194,7 +182,10 @@ public void testSanityCheckBlockingStoreFiles() throws IOException { .setValue(HStore.BLOCKING_STOREFILES_KEY, "10") .setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(family).setTimeToLive(1).build()) .build(); - TEST_UTIL.getAdmin().createTable(desc); + DoNotRetryIOException e = + assertThrows(DoNotRetryIOException.class, () -> TEST_UTIL.getAdmin().createTable(desc)); + assertTrue(e.getMessage().contains("Blocking file count 'hbase.hstore.blockingStoreFiles'")); + assertTrue(e.getMessage().contains("is below recommended minimum of 1000 for column family")); } /** @@ -221,27 +212,27 @@ public void testFIFOCompactionPolicyExpiredEmptyHFiles() throws Exception { TEST_UTIL.getAdmin().flush(tableName); // HFile-1 HStore store = Preconditions.checkNotNull(getStoreWithName(tableName)); - Assert.assertEquals(2, store.getStorefilesCount()); + assertEquals(2, store.getStorefilesCount()); TEST_UTIL.getAdmin().majorCompact(tableName); TEST_UTIL.waitFor(testWaitTimeoutMs, (Waiter.Predicate) () -> store.getStorefilesCount() == 1); - Assert.assertEquals(1, store.getStorefilesCount()); + assertEquals(1, store.getStorefilesCount()); HStoreFile sf = Preconditions.checkNotNull(store.getStorefiles().iterator().next()); - Assert.assertEquals(0, sf.getReader().getEntries()); + assertEquals(0, sf.getReader().getEntries()); put = new Put(Bytes.toBytes("row3")).addColumn(family, qualifier, ts, Bytes.toBytes("value1")); table.put(put); TEST_UTIL.getAdmin().flush(tableName); // HFile-2 - Assert.assertEquals(2, store.getStorefilesCount()); + assertEquals(2, store.getStorefilesCount()); TEST_UTIL.getAdmin().majorCompact(tableName); TEST_UTIL.waitFor(testWaitTimeoutMs, (Waiter.Predicate) () -> store.getStorefilesCount() == 1); - Assert.assertEquals(1, store.getStorefilesCount()); + assertEquals(1, store.getStorefilesCount()); sf = Preconditions.checkNotNull(store.getStorefiles().iterator().next()); - Assert.assertEquals(0, sf.getReader().getEntries()); + assertEquals(0, sf.getReader().getEntries()); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestOffPeakHours.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestOffPeakHours.java index 56534ed3a348..80c6b565fb3e 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestOffPeakHours.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestOffPeakHours.java @@ -17,30 +17,25 @@ */ package org.apache.hadoop.hbase.regionserver.compactions; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseTestingUtil; import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.testclassification.SmallTests; -import org.junit.Before; -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.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category({ RegionServerTests.class, SmallTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(SmallTests.TAG) public class TestOffPeakHours { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestOffPeakHours.class); - private static HBaseTestingUtil testUtil; - @BeforeClass + @BeforeAll public static void setUpClass() { testUtil = new HBaseTestingUtil(); } @@ -51,7 +46,7 @@ public static void setUpClass() { private int hourMinusTwo; private Configuration conf; - @Before + @BeforeEach public void setUp() { hourOfDay = 15; hourPlusOne = ((hourOfDay + 1) % 24); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestRowKeyDateTieringValueProvider.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestRowKeyDateTieringValueProvider.java index 0123729e1a69..baee99f01fba 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestRowKeyDateTieringValueProvider.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestRowKeyDateTieringValueProvider.java @@ -17,38 +17,35 @@ */ package org.apache.hadoop.hbase.regionserver.compactions; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.text.SimpleDateFormat; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.ExtendedCell; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.PrivateCellUtil; import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.testclassification.SmallTests; import org.apache.hadoop.hbase.util.Bytes; -import org.junit.After; -import org.junit.Before; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category({ RegionServerTests.class, SmallTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(SmallTests.TAG) public class TestRowKeyDateTieringValueProvider { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestRowKeyDateTieringValueProvider.class); private RowKeyDateTieringValueProvider provider; private Configuration conf; - @Before + @BeforeEach public void setUp() { conf = new Configuration(); provider = new RowKeyDateTieringValueProvider(); } - @After + @AfterEach public void tearDown() { provider = null; conf = null; @@ -65,40 +62,50 @@ public void testInitWithValidConfig() throws Exception { assertEquals(Integer.valueOf(1), provider.getRowKeyRegexExtractGroup()); } - @Test(expected = IllegalArgumentException.class) + @Test public void testInitWithMissingRegexPattern() throws Exception { - conf.set(RowKeyDateTieringValueProvider.TIERING_KEY_DATE_FORMAT, "yyyy-MM-dd"); - provider.init(conf); + assertThrows(IllegalArgumentException.class, () -> { + conf.set(RowKeyDateTieringValueProvider.TIERING_KEY_DATE_FORMAT, "yyyy-MM-dd"); + provider.init(conf); + }); } - @Test(expected = IllegalArgumentException.class) + @Test public void testInitWithMissingDateFormat() throws Exception { - conf.set(RowKeyDateTieringValueProvider.TIERING_KEY_DATE_PATTERN, "(\\d{4}-\\d{2}-\\d{2})"); - provider.init(conf); + assertThrows(IllegalArgumentException.class, () -> { + conf.set(RowKeyDateTieringValueProvider.TIERING_KEY_DATE_PATTERN, "(\\d{4}-\\d{2}-\\d{2})"); + provider.init(conf); + }); } - @Test(expected = IllegalArgumentException.class) + @Test public void testInitWithInvalidDateFormat() throws Exception { - conf.set(RowKeyDateTieringValueProvider.TIERING_KEY_DATE_PATTERN, "(\\d{4}-\\d{2}-\\d{2})"); - conf.set(RowKeyDateTieringValueProvider.TIERING_KEY_DATE_FORMAT, "invalid-format"); - provider.init(conf); + assertThrows(IllegalArgumentException.class, () -> { + conf.set(RowKeyDateTieringValueProvider.TIERING_KEY_DATE_PATTERN, "(\\d{4}-\\d{2}-\\d{2})"); + conf.set(RowKeyDateTieringValueProvider.TIERING_KEY_DATE_FORMAT, "invalid-format"); + provider.init(conf); + }); } - @Test(expected = IllegalArgumentException.class) + @Test public void testInitWithInvalidExtractGroup() throws Exception { - conf.set(RowKeyDateTieringValueProvider.TIERING_KEY_DATE_PATTERN, "(\\d{4}-\\d{2}-\\d{2})"); - conf.set(RowKeyDateTieringValueProvider.TIERING_KEY_DATE_FORMAT, "yyyy-MM-dd"); - conf.set(RowKeyDateTieringValueProvider.TIERING_KEY_DATE_GROUP, "-1"); - provider.init(conf); + assertThrows(IllegalArgumentException.class, () -> { + conf.set(RowKeyDateTieringValueProvider.TIERING_KEY_DATE_PATTERN, "(\\d{4}-\\d{2}-\\d{2})"); + conf.set(RowKeyDateTieringValueProvider.TIERING_KEY_DATE_FORMAT, "yyyy-MM-dd"); + conf.set(RowKeyDateTieringValueProvider.TIERING_KEY_DATE_GROUP, "-1"); + provider.init(conf); + }); } - @Test(expected = IllegalArgumentException.class) + @Test public void testInitWithExtractGroupExceedingPatternGroups() throws Exception { - conf.set(RowKeyDateTieringValueProvider.TIERING_KEY_DATE_PATTERN, "(\\d{4}-\\d{2}-\\d{2})"); - conf.set(RowKeyDateTieringValueProvider.TIERING_KEY_DATE_FORMAT, "yyyy-MM-dd"); - conf.set(RowKeyDateTieringValueProvider.TIERING_KEY_DATE_GROUP, "2"); // Only 1 group in - // pattern - provider.init(conf); + assertThrows(IllegalArgumentException.class, () -> { + conf.set(RowKeyDateTieringValueProvider.TIERING_KEY_DATE_PATTERN, "(\\d{4}-\\d{2}-\\d{2})"); + conf.set(RowKeyDateTieringValueProvider.TIERING_KEY_DATE_FORMAT, "yyyy-MM-dd"); + conf.set(RowKeyDateTieringValueProvider.TIERING_KEY_DATE_GROUP, "2"); // Only 1 group in + // pattern + provider.init(conf); + }); } @Test @@ -167,11 +174,13 @@ public void testGetTieringValueWithNonUTF8RowKey() throws Exception { assertEquals(Long.MAX_VALUE, timestamp); } - @Test(expected = IllegalStateException.class) + @Test public void testGetTieringValueWithoutInitialization() { - String rowKeyStr = "order_9999999999999999_date"; - byte[] rowKey = Bytes.toBytes(rowKeyStr); - ExtendedCell cell = PrivateCellUtil.createFirstOnRow(rowKey); - provider.getTieringValue(cell); + assertThrows(IllegalStateException.class, () -> { + String rowKeyStr = "order_9999999999999999_date"; + byte[] rowKey = Bytes.toBytes(rowKeyStr); + ExtendedCell cell = PrivateCellUtil.createFirstOnRow(rowKey); + provider.getTieringValue(cell); + }); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestStripeCompactionPolicy.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestStripeCompactionPolicy.java index d598d0cfdb77..e42249bb7181 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestStripeCompactionPolicy.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestStripeCompactionPolicy.java @@ -21,11 +21,11 @@ import static org.apache.hadoop.hbase.regionserver.StripeStoreConfig.MIN_FILES_KEY; import static org.apache.hadoop.hbase.regionserver.StripeStoreFileManager.OPEN_KEY; import static org.apache.hadoop.hbase.regionserver.compactions.CompactionConfiguration.HBASE_HSTORE_COMPACTION_MAX_SIZE_KEY; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.AdditionalMatchers.aryEq; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; @@ -47,12 +47,13 @@ import java.util.Iterator; import java.util.List; import java.util.OptionalLong; +import java.util.stream.Stream; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.CellComparatorImpl; import org.apache.hadoop.hbase.ExtendedCell; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseConfiguration; +import org.apache.hadoop.hbase.HBaseParameterizedTestTemplate; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor; import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder; @@ -85,26 +86,19 @@ import org.apache.hadoop.hbase.util.ConcatenatedLists; import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; import org.apache.hadoop.hbase.util.ManualEnvironmentEdge; -import org.junit.ClassRule; -import org.junit.Test; -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.Tag; +import org.junit.jupiter.api.TestTemplate; +import org.junit.jupiter.params.provider.Arguments; import org.mockito.ArgumentMatcher; import org.apache.hbase.thirdparty.com.google.common.collect.ImmutableList; import org.apache.hbase.thirdparty.com.google.common.collect.Lists; -@RunWith(Parameterized.class) -@Category({ RegionServerTests.class, MediumTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(MediumTests.TAG) +@HBaseParameterizedTestTemplate(name = "{index}: usePrivateReaders={0}") public class TestStripeCompactionPolicy { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestStripeCompactionPolicy.class); - private static final byte[] KEY_A = Bytes.toBytes("aaa"); private static final byte[] KEY_B = Bytes.toBytes("bbb"); private static final byte[] KEY_C = Bytes.toBytes("ccc"); @@ -121,15 +115,17 @@ public class TestStripeCompactionPolicy { private final static int defaultInitialCount = 1; private static long defaultTtl = 1000 * 1000; - @Parameters(name = "{index}: usePrivateReaders={0}") - public static Iterable data() { - return Arrays.asList(new Object[] { true }, new Object[] { false }); + public static Stream parameters() { + return Stream.of(Arguments.of(true), Arguments.of(false)); } - @Parameter - public boolean usePrivateReaders; + private final boolean usePrivateReaders; + + public TestStripeCompactionPolicy(boolean usePrivateReaders) { + this.usePrivateReaders = usePrivateReaders; + } - @Test + @TestTemplate public void testNoStripesFromFlush() throws Exception { Configuration conf = HBaseConfiguration.create(); conf.setBoolean(StripeStoreConfig.FLUSH_TO_L0_KEY, true); @@ -141,7 +137,7 @@ public void testNoStripesFromFlush() throws Exception { verifyFlush(policy, si, input, expected, null); } - @Test + @TestTemplate public void testOldStripesFromFlush() throws Exception { StripeCompactionPolicy policy = createPolicy(HBaseConfiguration.create()); StripeInformationProvider si = createStripes(0, KEY_C, KEY_D); @@ -152,7 +148,7 @@ public void testOldStripesFromFlush() throws Exception { verifyFlush(policy, si, input, expected, new byte[][] { OPEN_KEY, KEY_C, KEY_D, OPEN_KEY }); } - @Test + @TestTemplate public void testNewStripesFromFlush() throws Exception { StripeCompactionPolicy policy = createPolicy(HBaseConfiguration.create()); StripeInformationProvider si = createStripesL0Only(0, 0); @@ -162,7 +158,7 @@ public void testNewStripesFromFlush() throws Exception { verifyFlush(policy, si, input, expected, new byte[][] { OPEN_KEY, OPEN_KEY }); } - @Test + @TestTemplate public void testSingleStripeCompaction() throws Exception { // Create a special policy that only compacts single stripes, using standard methods. Configuration conf = HBaseConfiguration.create(); @@ -229,7 +225,7 @@ public boolean needsCompactions(StripeInformationProvider si, verifyCompaction(policy, si, sfs, null, 1, null, si.getStartRow(1), si.getEndRow(1), true); } - @Test + @TestTemplate public void testWithParallelCompaction() throws Exception { // TODO: currently only one compaction at a time per store is allowed. If this changes, // the appropriate file exclusion testing would need to be done in respective tests. @@ -237,7 +233,7 @@ public void testWithParallelCompaction() throws Exception { .selectCompaction(mock(StripeInformationProvider.class), al(createFile()), false)); } - @Test + @TestTemplate public void testWithReferences() throws Exception { StripeCompactionPolicy policy = createPolicy(HBaseConfiguration.create()); StripeCompactor sc = mock(StripeCompactor.class); @@ -257,7 +253,7 @@ public void testWithReferences() throws Exception { aryEq(OPEN_KEY), aryEq(OPEN_KEY), aryEq(OPEN_KEY), any(), any()); } - @Test + @TestTemplate public void testInitialCountFromL0() throws Exception { Configuration conf = HBaseConfiguration.create(); conf.setInt(StripeStoreConfig.MIN_FILES_L0_KEY, 2); @@ -271,7 +267,7 @@ public void testInitialCountFromL0() throws Exception { verifyCompaction(policy, si, si.getStoreFiles(), true, 6, 5L, OPEN_KEY, OPEN_KEY, true); } - @Test + @TestTemplate public void testSelectL0Compaction() throws Exception { // test select ALL L0 files when L0 files count > MIN_FILES_L0_KEY Configuration conf = HBaseConfiguration.create(); @@ -306,7 +302,7 @@ public void testSelectL0Compaction() throws Exception { verifyCollectionsEqual(si.getLevel0Files().subList(0, 6), cr.getRequest().getFiles()); } - @Test + @TestTemplate public void testExistingStripesFromL0() throws Exception { Configuration conf = HBaseConfiguration.create(); conf.setInt(StripeStoreConfig.MIN_FILES_L0_KEY, 3); @@ -315,7 +311,7 @@ public void testExistingStripesFromL0() throws Exception { si.getStripeBoundaries()); } - @Test + @TestTemplate public void testNothingToCompactFromL0() throws Exception { Configuration conf = HBaseConfiguration.create(); conf.setInt(StripeStoreConfig.MIN_FILES_L0_KEY, 4); @@ -327,7 +323,7 @@ public void testNothingToCompactFromL0() throws Exception { verifyNoCompaction(policy, si); } - @Test + @TestTemplate public void testCheckExpiredStripeCompaction() throws Exception { Configuration conf = HBaseConfiguration.create(); conf.setInt(StripeStoreConfig.MIN_FILES_L0_KEY, 5); @@ -356,7 +352,7 @@ public void testCheckExpiredStripeCompaction() throws Exception { assertTrue(policy.needsCompactions(si, al())); } - @Test + @TestTemplate public void testSplitOffStripe() throws Exception { Configuration conf = HBaseConfiguration.create(); // Test depends on this not being set to pass. Default breaks test. TODO: Revisit. @@ -387,7 +383,7 @@ public void testSplitOffStripe() throws Exception { verifySingleStripeCompaction(specPolicy, si, 1, null); } - @Test + @TestTemplate public void testSplitOffStripeOffPeak() throws Exception { // for HBASE-11439 Configuration conf = HBaseConfiguration.create(); @@ -407,7 +403,7 @@ public void testSplitOffStripeOffPeak() throws Exception { createPolicy(conf).selectCompaction(si, al(), true).getRequest().getFiles().size()); } - @Test + @TestTemplate public void testSplitOffStripeDropDeletes() throws Exception { Configuration conf = HBaseConfiguration.create(); conf.setInt(StripeStoreConfig.MIN_FILES_KEY, 2); @@ -426,7 +422,7 @@ public void testSplitOffStripeDropDeletes() throws Exception { } @SuppressWarnings("unchecked") - @Test + @TestTemplate public void testMergeExpiredFiles() throws Exception { ManualEnvironmentEdge edge = new ManualEnvironmentEdge(); long now = defaultTtl + 2; @@ -465,7 +461,7 @@ public void testMergeExpiredFiles() throws Exception { } @SuppressWarnings("unchecked") - @Test + @TestTemplate public void testMergeExpiredStripes() throws Exception { // HBASE-11397 ManualEnvironmentEdge edge = new ManualEnvironmentEdge(); @@ -502,7 +498,7 @@ public void testMergeExpiredStripes() throws Exception { Lists.newArrayList(stripeFiles), new ArrayList<>()); } - @Test + @TestTemplate public void testSingleStripeDropDeletes() throws Exception { Configuration conf = HBaseConfiguration.create(); // Test depends on this not being set to pass. Default breaks test. TODO: Revisit. @@ -538,7 +534,7 @@ public void testSingleStripeDropDeletes() throws Exception { true); } - @Test + @TestTemplate public void testCheckExpiredL0Compaction() throws Exception { Configuration conf = HBaseConfiguration.create(); int minL0 = 100; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestStripeCompactor.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestStripeCompactor.java index 6c1c176d36c8..23ab0ead6d37 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestStripeCompactor.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestStripeCompactor.java @@ -19,7 +19,7 @@ import static org.apache.hadoop.hbase.regionserver.StripeStoreFileManager.OPEN_KEY; import static org.apache.hadoop.hbase.regionserver.compactions.TestCompactor.createDummyRequest; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -28,13 +28,14 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.stream.Stream; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.CellComparatorImpl; import org.apache.hadoop.hbase.CellUtil; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseConfiguration; +import org.apache.hadoop.hbase.HBaseParameterizedTestTemplate; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor; @@ -53,21 +54,14 @@ import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.testclassification.SmallTests; import org.apache.hadoop.hbase.util.Bytes; -import org.junit.ClassRule; -import org.junit.Test; -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; - -@RunWith(Parameterized.class) -@Category({ RegionServerTests.class, SmallTests.class }) -public class TestStripeCompactor { +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.TestTemplate; +import org.junit.jupiter.params.provider.Arguments; - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestStripeCompactor.class); +@Tag(RegionServerTests.TAG) +@Tag(SmallTests.TAG) +@HBaseParameterizedTestTemplate(name = "{index}: usePrivateReaders={0}") +public class TestStripeCompactor { private static final byte[] NAME_OF_THINGS = Bytes.toBytes("foo"); private static final TableName TABLE_NAME = TableName.valueOf(NAME_OF_THINGS, NAME_OF_THINGS); @@ -81,13 +75,15 @@ public class TestStripeCompactor { private static final KeyValue KV_C = kvAfter(KEY_C); private static final KeyValue KV_D = kvAfter(KEY_D); - @Parameters(name = "{index}: usePrivateReaders={0}") - public static Iterable data() { - return Arrays.asList(new Object[] { true }, new Object[] { false }); + public static Stream parameters() { + return Stream.of(Arguments.of(true), Arguments.of(false)); } - @Parameter - public boolean usePrivateReaders; + private final boolean usePrivateReaders; + + public TestStripeCompactor(boolean usePrivateReaders) { + this.usePrivateReaders = usePrivateReaders; + } private static KeyValue kvAfter(byte[] key) { return new KeyValue(Arrays.copyOf(key, key.length + 1), 0L); @@ -102,7 +98,7 @@ private static KeyValue[] e() { return TestStripeCompactor. a(); } - @Test + @TestTemplate public void testBoundaryCompactions() throws Exception { // General verification verifyBoundaryCompaction(a(KV_A, KV_A, KV_B, KV_B, KV_C, KV_D), @@ -111,7 +107,7 @@ public void testBoundaryCompactions() throws Exception { verifyBoundaryCompaction(a(KV_B, KV_C), a(KEY_B, KEY_D), new KeyValue[][] { a(KV_B, KV_C) }); } - @Test + @TestTemplate public void testBoundaryCompactionEmptyFiles() throws Exception { // No empty file if there're already files. verifyBoundaryCompaction(a(KV_B), a(KEY_B, KEY_C, KEY_D, OPEN_KEY), a(a(KV_B), null, null), @@ -152,7 +148,7 @@ private void verifyBoundaryCompaction(KeyValue[] input, byte[][] boundaries, Key } } - @Test + @TestTemplate public void testSizeCompactions() throws Exception { // General verification with different sizes. verifySizeCompaction(a(KV_A, KV_A, KV_B, KV_C, KV_D), 3, 2, OPEN_KEY, OPEN_KEY, diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/http/TestRSStatusPage.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/http/TestRSStatusPage.java index 12b7e0d78579..735760c689d4 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/http/TestRSStatusPage.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/http/TestRSStatusPage.java @@ -17,15 +17,14 @@ */ package org.apache.hadoop.hbase.regionserver.http; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; import java.net.URL; import java.util.List; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseTestingUtil; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.LocalHBaseCluster; @@ -41,34 +40,34 @@ import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.util.CommonFSUtils; import org.apache.hadoop.hbase.util.TestServerHttpUtils; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.rules.TestName; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; /** * Tests for the region server status page and its template. */ -@Category({ RegionServerTests.class, MediumTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(MediumTests.TAG) public class TestRSStatusPage { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestRSStatusPage.class); - private static LocalHBaseCluster CLUSTER; private final static HBaseTestingUtil UTIL = new HBaseTestingUtil(); public static final String TEST_TABLE_NAME_1 = "TEST_TABLE_1"; public static final String TEST_TABLE_NAME_2 = "TEST_TABLE_2"; - @Rule - public TestName name = new TestName(); + private String name; + + @BeforeEach + public void initTestName(TestInfo testInfo) { + name = testInfo.getTestMethod().get().getName(); + } - @BeforeClass + @BeforeAll public static void beforeClass() throws Exception { Configuration conf = UTIL.getConfiguration(); UTIL.startMiniZKCluster(); @@ -91,7 +90,7 @@ public static void beforeClass() throws Exception { /** * Helper method to shut down the cluster (if running) */ - @AfterClass + @AfterAll public static void shutDownMiniCluster() throws Exception { if (CLUSTER != null) { CLUSTER.shutdown(); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/metrics/TestMetricsThrottleExceptions.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/metrics/TestMetricsThrottleExceptions.java index 0fa02c42a325..0a5d2b126287 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/metrics/TestMetricsThrottleExceptions.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/metrics/TestMetricsThrottleExceptions.java @@ -17,8 +17,8 @@ */ package org.apache.hadoop.hbase.regionserver.metrics; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Optional; import java.util.concurrent.CountDownLatch; @@ -26,7 +26,6 @@ import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.metrics.Counter; import org.apache.hadoop.hbase.metrics.Metric; import org.apache.hadoop.hbase.metrics.MetricRegistries; @@ -35,22 +34,18 @@ import org.apache.hadoop.hbase.quotas.RpcThrottlingException; import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.testclassification.SmallTests; -import org.junit.After; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category({ RegionServerTests.class, SmallTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(SmallTests.TAG) public class TestMetricsThrottleExceptions { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestMetricsThrottleExceptions.class); - private MetricRegistry testRegistry; private MetricsThrottleExceptions throttleMetrics; - @After + @AfterEach public void cleanup() { // Clean up global registries after each test to avoid interference MetricRegistries.global().clear(); @@ -67,11 +62,11 @@ public void testBasicThrottleMetricsRecording() { // Verify the counter exists and has correct value Optional metric = testRegistry.get("RpcThrottlingException_Type_NumRequestsExceeded_User_alice_Table_users"); - assertTrue("Counter metric should be present", metric.isPresent()); - assertTrue("Metric should be a counter", metric.get() instanceof Counter); + assertTrue(metric.isPresent(), "Counter metric should be present"); + assertTrue(metric.get() instanceof Counter, "Metric should be a counter"); Counter counter = (Counter) metric.get(); - assertEquals("Counter should have count of 1", 1, counter.getCount()); + assertEquals(1, counter.getCount(), "Counter should have count of 1"); } @Test @@ -188,8 +183,8 @@ public void testConcurrentAccess() throws InterruptedException { // Wait for all threads to complete boolean completed = doneLatch.await(30, TimeUnit.SECONDS); - assertTrue("All threads should complete within timeout", completed); - assertEquals("No exceptions should occur during concurrent access", 0, exceptions.get()); + assertTrue(completed, "All threads should complete within timeout"); + assertEquals(0, exceptions.get(), "No exceptions should occur during concurrent access"); // Verify the final counter value verifyCounter(testRegistry, @@ -276,12 +271,12 @@ private void setupTestMetrics() { */ private void verifyCounter(MetricRegistry registry, String metricName, long expectedCount) { Optional metric = registry.get(metricName); - assertTrue("Counter metric '" + metricName + "' should be present", metric.isPresent()); - assertTrue("Metric should be a counter", metric.get() instanceof Counter); + assertTrue(metric.isPresent(), "Counter metric '" + metricName + "' should be present"); + assertTrue(metric.get() instanceof Counter, "Metric should be a counter"); Counter counter = (Counter) metric.get(); - assertEquals("Counter '" + metricName + "' should have expected count", expectedCount, - counter.getCount()); + assertEquals(expectedCount, counter.getCount(), + "Counter '" + metricName + "' should have expected count"); } /** diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/querymatcher/AbstractTestScanQueryMatcher.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/querymatcher/AbstractTestScanQueryMatcher.java index a707d79415e9..5e5d122f5b65 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/querymatcher/AbstractTestScanQueryMatcher.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/querymatcher/AbstractTestScanQueryMatcher.java @@ -23,7 +23,7 @@ import org.apache.hadoop.hbase.client.Get; import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.util.Bytes; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; public class AbstractTestScanQueryMatcher { @@ -48,7 +48,7 @@ public class AbstractTestScanQueryMatcher { protected CellComparator rowComparator; protected Scan scan; - @Before + @BeforeEach public void setUp() throws Exception { this.conf = HBaseConfiguration.create(); row1 = Bytes.toBytes("row1"); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/querymatcher/TestCompactionScanQueryMatcher.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/querymatcher/TestCompactionScanQueryMatcher.java index 17681d2f0149..784305730289 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/querymatcher/TestCompactionScanQueryMatcher.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/querymatcher/TestCompactionScanQueryMatcher.java @@ -20,12 +20,11 @@ import static org.apache.hadoop.hbase.regionserver.querymatcher.ScanQueryMatcher.MatchCode.INCLUDE; import static org.apache.hadoop.hbase.regionserver.querymatcher.ScanQueryMatcher.MatchCode.SEEK_NEXT_COL; import static org.apache.hadoop.hbase.regionserver.querymatcher.ScanQueryMatcher.MatchCode.SKIP; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; import java.util.ArrayList; import java.util.List; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.KeepDeletedCells; import org.apache.hadoop.hbase.KeyValue; @@ -39,19 +38,15 @@ import org.apache.hadoop.hbase.testclassification.SmallTests; import org.apache.hadoop.hbase.util.Bytes; 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.Tag; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -@Category({ RegionServerTests.class, SmallTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(SmallTests.TAG) public class TestCompactionScanQueryMatcher extends AbstractTestScanQueryMatcher { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestCompactionScanQueryMatcher.class); - private static final Logger LOG = LoggerFactory.getLogger(TestCompactionScanQueryMatcher.class); @Test @@ -187,7 +182,7 @@ private void assertRetainDeletes(KeepDeletedCells keepDeletedCells, byte[] quali ts--; } for (int i = 0; i < expected.length; i++) { - assertEquals("Mismatch at index " + i, expected[i], actual.get(i)); + assertEquals(expected[i], actual.get(i), "Mismatch at index " + i); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/querymatcher/TestExplicitColumnTracker.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/querymatcher/TestExplicitColumnTracker.java index 8eb95b03eab7..7eb0c9c114ed 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/querymatcher/TestExplicitColumnTracker.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/querymatcher/TestExplicitColumnTracker.java @@ -17,30 +17,25 @@ */ package org.apache.hadoop.hbase.regionserver.querymatcher; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.TreeSet; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.regionserver.querymatcher.ScanQueryMatcher.MatchCode; import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.testclassification.SmallTests; import org.apache.hadoop.hbase.util.Bytes; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category({ RegionServerTests.class, SmallTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(SmallTests.TAG) public class TestExplicitColumnTracker { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestExplicitColumnTracker.class); - private final byte[] col1 = Bytes.toBytes("col1"); private final byte[] col2 = Bytes.toBytes("col2"); private final byte[] col3 = Bytes.toBytes("col3"); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/querymatcher/TestNewVersionBehaviorTracker.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/querymatcher/TestNewVersionBehaviorTracker.java index 4bd8c5983e79..b3c039f18921 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/querymatcher/TestNewVersionBehaviorTracker.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/querymatcher/TestNewVersionBehaviorTracker.java @@ -17,30 +17,25 @@ */ package org.apache.hadoop.hbase.regionserver.querymatcher; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; import java.util.TreeSet; import org.apache.hadoop.hbase.CellComparator; import org.apache.hadoop.hbase.CellComparatorImpl; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.regionserver.querymatcher.DeleteTracker.DeleteResult; import org.apache.hadoop.hbase.regionserver.querymatcher.ScanQueryMatcher.MatchCode; import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.testclassification.SmallTests; import org.apache.hadoop.hbase.util.Bytes; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category({ RegionServerTests.class, SmallTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(SmallTests.TAG) public class TestNewVersionBehaviorTracker { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestNewVersionBehaviorTracker.class); - private final byte[] col0 = Bytes.toBytes("col0"); private final byte[] col1 = Bytes.toBytes("col1"); private final byte[] col2 = Bytes.toBytes("col2"); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/querymatcher/TestScanDeleteTracker.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/querymatcher/TestScanDeleteTracker.java index 1d7d5e7e2f2e..199a8f943b80 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/querymatcher/TestScanDeleteTracker.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/querymatcher/TestScanDeleteTracker.java @@ -17,32 +17,27 @@ */ package org.apache.hadoop.hbase.regionserver.querymatcher; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.apache.hadoop.hbase.CellComparatorImpl; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.regionserver.querymatcher.DeleteTracker.DeleteResult; import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.testclassification.SmallTests; import org.apache.hadoop.hbase.util.Bytes; -import org.junit.Before; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category({ RegionServerTests.class, SmallTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(SmallTests.TAG) public class TestScanDeleteTracker { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestScanDeleteTracker.class); - private ScanDeleteTracker sdt; private long timestamp = 10L; - @Before + @BeforeEach public void setUp() throws Exception { sdt = new ScanDeleteTracker(CellComparatorImpl.COMPARATOR); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/querymatcher/TestScanWildcardColumnTracker.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/querymatcher/TestScanWildcardColumnTracker.java index 851649658e0c..8a3d046636f2 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/querymatcher/TestScanWildcardColumnTracker.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/querymatcher/TestScanWildcardColumnTracker.java @@ -17,30 +17,25 @@ */ package org.apache.hadoop.hbase.regionserver.querymatcher; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import java.io.IOException; import java.util.ArrayList; import java.util.List; import org.apache.hadoop.hbase.CellComparatorImpl; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.regionserver.querymatcher.ScanQueryMatcher.MatchCode; import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.testclassification.SmallTests; import org.apache.hadoop.hbase.util.Bytes; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category({ RegionServerTests.class, SmallTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(SmallTests.TAG) public class TestScanWildcardColumnTracker { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestScanWildcardColumnTracker.class); - final static int VERSIONS = 2; @Test diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/querymatcher/TestUserScanQueryMatcher.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/querymatcher/TestUserScanQueryMatcher.java index 36dbd213bbe2..d9df7c08a93d 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/querymatcher/TestUserScanQueryMatcher.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/querymatcher/TestUserScanQueryMatcher.java @@ -17,16 +17,15 @@ */ package org.apache.hadoop.hbase.regionserver.querymatcher; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import java.io.IOException; import java.util.ArrayList; import java.util.List; import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.ExtendedCell; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.KeepDeletedCells; import org.apache.hadoop.hbase.KeyValue; @@ -39,19 +38,15 @@ import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.testclassification.SmallTests; 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.Tag; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -@Category({ RegionServerTests.class, SmallTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(SmallTests.TAG) public class TestUserScanQueryMatcher extends AbstractTestScanQueryMatcher { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestUserScanQueryMatcher.class); - private static final Logger LOG = LoggerFactory.getLogger(TestUserScanQueryMatcher.class); /** @@ -437,8 +432,8 @@ public void testDeleteColumnEmptyQualifierDoesNotSkipDeleteFamily() throws IOExc qm.setToNewRow(new KeyValue(row1, fam1, e, now, Type.DeleteColumn)); for (int i = 0; i < n + 1; i++) { // Empty qualifier DCs should never trigger seek, regardless of threshold - assertEquals("DC at i=" + i, MatchCode.SKIP, - qm.match(new KeyValue(row1, fam1, e, now - i, Type.DeleteColumn))); + assertEquals(MatchCode.SKIP, + qm.match(new KeyValue(row1, fam1, e, now - i, Type.DeleteColumn)), "DC at i=" + i); } KeyValue df = new KeyValue(row1, fam1, e, now - n - 1, Type.DeleteFamily); KeyValue put = new KeyValue(row1, fam1, col1, now - n - 1, Type.Put, data); @@ -493,8 +488,8 @@ public void testSeekOnRangeDeleteOutsideTimeRange() throws IOException { // All DCs have timestamps below the time range, so includeDeleteMarker is false. // The seek counter should still accumulate. for (int i = 0; i < n - 1; i++) { - assertEquals("DC at i=" + i, MatchCode.SKIP, - qm.match(new KeyValue(row1, fam1, col1, now - i, Type.DeleteColumn))); + assertEquals(MatchCode.SKIP, + qm.match(new KeyValue(row1, fam1, col1, now - i, Type.DeleteColumn)), "DC at i=" + i); } assertEquals(MatchCode.SEEK_NEXT_COL, qm.match(new KeyValue(row1, fam1, col1, now - n + 1, Type.DeleteColumn))); @@ -517,11 +512,12 @@ private void assertSeekAfterThreshold(KeepDeletedCells keepDeletedCells, Type ty byte[] qual = familyLevel ? HConstants.EMPTY_BYTE_ARRAY : col1; qm.setToNewRow(new KeyValue(row1, fam1, qual, now, type)); for (int i = 0; i < n - 1; i++) { - assertEquals("Mismatch at index " + i, MatchCode.SKIP, - qm.match(new KeyValue(row1, fam1, qual, now - i, type))); + assertEquals(MatchCode.SKIP, qm.match(new KeyValue(row1, fam1, qual, now - i, type)), + "Mismatch at index " + i); } - assertEquals("Expected SEEK_NEXT_COL at index " + (n - 1), MatchCode.SEEK_NEXT_COL, - qm.match(new KeyValue(row1, fam1, qual, now - n + 1, type))); + assertEquals(MatchCode.SEEK_NEXT_COL, + qm.match(new KeyValue(row1, fam1, qual, now - n + 1, type)), + "Expected SEEK_NEXT_COL at index " + (n - 1)); } /** All markers should SKIP regardless of count. */ @@ -533,8 +529,8 @@ private void assertAllSkip(KeepDeletedCells keepDeletedCells, Type type, int cou byte[] qual = familyLevel ? HConstants.EMPTY_BYTE_ARRAY : col1; qm.setToNewRow(new KeyValue(row1, fam1, qual, now, type)); for (int i = 0; i < count; i++) { - assertEquals("Mismatch at index " + i, MatchCode.SKIP, - qm.match(new KeyValue(row1, fam1, qual, now - i, type))); + assertEquals(MatchCode.SKIP, qm.match(new KeyValue(row1, fam1, qual, now - i, type)), + "Mismatch at index " + i); } } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/regionreplication/TestRegionReplicationBufferManager.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/regionreplication/TestRegionReplicationBufferManager.java index b75e9c060a99..dcc05a11f287 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/regionreplication/TestRegionReplicationBufferManager.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/regionreplication/TestRegionReplicationBufferManager.java @@ -17,8 +17,8 @@ */ package org.apache.hadoop.hbase.regionserver.regionreplication; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.Mockito.mock; @@ -31,7 +31,6 @@ import java.util.Optional; import java.util.concurrent.CountDownLatch; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.RegionInfo; @@ -41,33 +40,29 @@ import org.apache.hadoop.hbase.regionserver.RegionServerServices; import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.testclassification.RegionServerTests; -import org.junit.After; -import org.junit.Before; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category({ RegionServerTests.class, MediumTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(MediumTests.TAG) public class TestRegionReplicationBufferManager { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestRegionReplicationBufferManager.class); - private Configuration conf; private RegionServerServices rsServices; private RegionReplicationBufferManager manager; - @Before + @BeforeEach public void setUp() { conf = HBaseConfiguration.create(); rsServices = mock(RegionServerServices.class); when(rsServices.getConfiguration()).thenReturn(conf); } - @After + @AfterEach public void tearDown() { if (manager != null) { manager.stop(); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/regionreplication/TestRegionReplicationFlushRequester.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/regionreplication/TestRegionReplicationFlushRequester.java index 949cfb34b845..ec1a30eddc06 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/regionreplication/TestRegionReplicationFlushRequester.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/regionreplication/TestRegionReplicationFlushRequester.java @@ -22,29 +22,24 @@ import static org.mockito.Mockito.verify; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.testclassification.RegionServerTests; -import org.junit.Before; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category({ RegionServerTests.class, MediumTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(MediumTests.TAG) public class TestRegionReplicationFlushRequester { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestRegionReplicationFlushRequester.class); - private Configuration conf; private Runnable requester; private RegionReplicationFlushRequester flushRequester; - @Before + @BeforeEach public void setUp() { conf = HBaseConfiguration.create(); conf.setInt(RegionReplicationFlushRequester.MIN_INTERVAL_SECS, 1); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/regionreplication/TestRegionReplicationForFlushMarker.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/regionreplication/TestRegionReplicationForFlushMarker.java index e0fca04309f4..4059d0b15944 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/regionreplication/TestRegionReplicationForFlushMarker.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/regionreplication/TestRegionReplicationForFlushMarker.java @@ -17,8 +17,8 @@ */ package org.apache.hadoop.hbase.regionserver.regionreplication; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; import java.util.Collection; @@ -31,7 +31,6 @@ import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.DoNotRetryIOException; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseTestingUtil; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.NotServingRegionException; @@ -59,11 +58,10 @@ import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.ServerRegionReplicaUtil; import org.apache.hadoop.hbase.wal.WAL; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import org.apache.hbase.thirdparty.com.google.protobuf.ByteString; import org.apache.hbase.thirdparty.com.google.protobuf.RpcController; @@ -75,13 +73,10 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.WALEntry; import org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor.FlushAction; -@Category({ RegionServerTests.class, LargeTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(LargeTests.TAG) public class TestRegionReplicationForFlushMarker { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestRegionReplicationForFlushMarker.class); - private static final byte[] FAMILY = Bytes.toBytes("family_test"); private static final byte[] QUAL = Bytes.toBytes("qualifier_test"); @@ -92,7 +87,7 @@ public class TestRegionReplicationForFlushMarker { private static TableName tableName = TableName.valueOf("TestRegionReplicationForFlushMarker"); private static volatile boolean startTest = false; - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Configuration conf = HTU.getConfiguration(); conf.setBoolean(ServerRegionReplicaUtil.REGION_REPLICA_REPLICATION_CONF_KEY, true); @@ -109,7 +104,7 @@ public static void setUp() throws Exception { } - @AfterClass + @AfterAll public static void tearDown() throws Exception { HTU.shutdownMiniCluster(); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/regionreplication/TestRegionReplicationForSkipWAL.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/regionreplication/TestRegionReplicationForSkipWAL.java index e8880267118f..13d61c89c1a0 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/regionreplication/TestRegionReplicationForSkipWAL.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/regionreplication/TestRegionReplicationForSkipWAL.java @@ -17,14 +17,13 @@ */ package org.apache.hadoop.hbase.regionserver.regionreplication; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; import java.util.Arrays; import java.util.List; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseTestingUtil; import org.apache.hadoop.hbase.StartTestingClusterOption; import org.apache.hadoop.hbase.TableName; @@ -46,19 +45,15 @@ import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.ServerRegionReplicaUtil; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category({ RegionServerTests.class, LargeTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(LargeTests.TAG) public class TestRegionReplicationForSkipWAL { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestRegionReplicationForSkipWAL.class); - private static final byte[] FAM1 = Bytes.toBytes("family_test1"); private static final byte[] QUAL1 = Bytes.toBytes("qualifier_test1"); @@ -88,7 +83,7 @@ public class TestRegionReplicationForSkipWAL { private static final String strTableName = "TestRegionReplicationForSkipWAL"; - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Configuration conf = HTU.getConfiguration(); conf.setBoolean(ServerRegionReplicaUtil.REGION_REPLICA_REPLICATION_CONF_KEY, true); @@ -96,7 +91,7 @@ public static void setUp() throws Exception { HTU.startMiniCluster(StartTestingClusterOption.builder().numRegionServers(NB_SERVERS).build()); } - @AfterClass + @AfterAll public static void tearDown() throws Exception { HTU.shutdownMiniCluster(); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/regionreplication/TestRegionReplicationForWriteException.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/regionreplication/TestRegionReplicationForWriteException.java index 59b9ae9349da..a7fe2f48c610 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/regionreplication/TestRegionReplicationForWriteException.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/regionreplication/TestRegionReplicationForWriteException.java @@ -17,10 +17,10 @@ */ package org.apache.hadoop.hbase.regionserver.regionreplication; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.io.IOException; import java.util.Arrays; @@ -32,7 +32,6 @@ import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.Abortable; import org.apache.hadoop.hbase.DoNotRetryIOException; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseTestingUtil; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.StartTestingClusterOption; @@ -73,23 +72,19 @@ import org.apache.hadoop.hbase.wal.WALFactory; import org.apache.hadoop.hbase.wal.WALKeyImpl; import org.apache.hadoop.hbase.wal.WALProvider; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.apache.hbase.thirdparty.io.netty.channel.Channel; import org.apache.hbase.thirdparty.io.netty.channel.EventLoopGroup; -@Category({ RegionServerTests.class, LargeTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(LargeTests.TAG) public class TestRegionReplicationForWriteException { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestRegionReplicationForWriteException.class); - private static final byte[] FAMILY = Bytes.toBytes("family_test"); private static final byte[] QUAL = Bytes.toBytes("qualifier_test"); @@ -103,7 +98,7 @@ public class TestRegionReplicationForWriteException { private static final long timeoutMIlliseconds = 3000; private static final String USER_THREAD_NAME = tableName.getNameAsString(); - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Configuration conf = HTU.getConfiguration(); conf.setBoolean(ServerRegionReplicaUtil.REGION_REPLICA_REPLICATION_CONF_KEY, true); @@ -121,7 +116,7 @@ public static void setUp() throws Exception { } - @AfterClass + @AfterAll public static void tearDown() throws Exception { HTU.shutdownMiniCluster(); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/regionreplication/TestRegionReplicationSink.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/regionreplication/TestRegionReplicationSink.java index cf86872444fe..05d8773cccc6 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/regionreplication/TestRegionReplicationSink.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/regionreplication/TestRegionReplicationSink.java @@ -17,7 +17,7 @@ */ package org.apache.hadoop.hbase.regionserver.regionreplication; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyList; @@ -41,9 +41,8 @@ import org.apache.commons.lang3.mutable.MutableInt; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseConfiguration; -import org.apache.hadoop.hbase.TableNameTestRule; +import org.apache.hadoop.hbase.TableNameTestExtension; import org.apache.hadoop.hbase.client.AsyncClusterConnection; import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder; import org.apache.hadoop.hbase.client.RegionInfo; @@ -56,24 +55,20 @@ import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.wal.WALEdit; import org.apache.hadoop.hbase.wal.WALKeyImpl; -import org.junit.After; -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.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.extension.RegisterExtension; import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil; import org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor; import org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor.FlushAction; -@Category({ RegionServerTests.class, MediumTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(MediumTests.TAG) public class TestRegionReplicationSink { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestRegionReplicationSink.class); - private Configuration conf; private TableDescriptor td; @@ -88,10 +83,10 @@ public class TestRegionReplicationSink { private RegionReplicationSink sink; - @Rule - public final TableNameTestRule name = new TableNameTestRule(); + @RegisterExtension + public final TableNameTestExtension name = new TableNameTestExtension(); - @Before + @BeforeEach public void setUp() { conf = HBaseConfiguration.create(); conf.setLong(RegionReplicationSink.BATCH_COUNT_CAPACITY, 5); @@ -105,7 +100,7 @@ public void setUp() { sink = new RegionReplicationSink(conf, primary, td, manager, flushRequester, conn); } - @After + @AfterEach public void tearDown() throws InterruptedException { sink.stop(); sink.waitUntilStopped(); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/regionreplication/TestRegionReplicationSinkCallbackAndFlushConcurrently.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/regionreplication/TestRegionReplicationSinkCallbackAndFlushConcurrently.java index 7e113a27e29c..8a206ed9e77d 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/regionreplication/TestRegionReplicationSinkCallbackAndFlushConcurrently.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/regionreplication/TestRegionReplicationSinkCallbackAndFlushConcurrently.java @@ -17,8 +17,8 @@ */ package org.apache.hadoop.hbase.regionserver.regionreplication; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; import java.util.Collection; @@ -31,7 +31,6 @@ import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.DoNotRetryIOException; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseTestingUtil; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.NotServingRegionException; @@ -58,11 +57,10 @@ import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.ServerRegionReplicaUtil; import org.apache.hadoop.hbase.wal.WAL; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.apache.hbase.thirdparty.com.google.protobuf.ByteString; @@ -74,11 +72,9 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.ReplicateWALEntryResponse; import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.WALEntry; -@Category({ RegionServerTests.class, LargeTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(LargeTests.TAG) public class TestRegionReplicationSinkCallbackAndFlushConcurrently { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestRegionReplicationSinkCallbackAndFlushConcurrently.class); private static final byte[] FAMILY = Bytes.toBytes("family_test"); @@ -90,7 +86,7 @@ public class TestRegionReplicationSinkCallbackAndFlushConcurrently { private static TableName tableName = TableName.valueOf("testRegionReplicationSinkSuspend"); private static volatile boolean startTest = false; - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Configuration conf = HTU.getConfiguration(); conf.setBoolean(ServerRegionReplicaUtil.REGION_REPLICA_REPLICATION_CONF_KEY, true); @@ -106,7 +102,7 @@ public static void setUp() throws Exception { } - @AfterClass + @AfterAll public static void tearDown() throws Exception { HTU.shutdownMiniCluster(); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/regionreplication/TestStartupWithLegacyRegionReplicationEndpoint.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/regionreplication/TestStartupWithLegacyRegionReplicationEndpoint.java index ef04b97aadaa..c510fae08eb3 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/regionreplication/TestStartupWithLegacyRegionReplicationEndpoint.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/regionreplication/TestStartupWithLegacyRegionReplicationEndpoint.java @@ -17,13 +17,12 @@ */ package org.apache.hadoop.hbase.regionserver.regionreplication; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThrows; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; import java.util.Collections; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseTestingUtil; import org.apache.hadoop.hbase.ReplicationPeerNotFoundException; import org.apache.hadoop.hbase.ServerName; @@ -40,25 +39,21 @@ import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread; import org.apache.hadoop.hbase.util.ServerRegionReplicaUtil; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; /** * Make sure we could start the cluster with RegionReplicaReplicationEndpoint configured. */ -@Category({ RegionServerTests.class, MediumTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(MediumTests.TAG) public class TestStartupWithLegacyRegionReplicationEndpoint { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestStartupWithLegacyRegionReplicationEndpoint.class); - private static final HBaseTestingUtil UTIL = new HBaseTestingUtil(); - @BeforeClass + @BeforeAll public static void setUp() throws Exception { UTIL.startMiniCluster(1); // add a peer to force initialize the replication storage @@ -67,7 +62,7 @@ public static void setUp() throws Exception { UTIL.getAdmin().removeReplicationPeer("1"); } - @AfterClass + @AfterAll public static void tearDown() throws IOException { UTIL.shutdownMiniCluster(); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/storefiletracker/TestChangeStoreFileTracker.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/storefiletracker/TestChangeStoreFileTracker.java index ade8e1ff58ed..b2e7beb29af1 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/storefiletracker/TestChangeStoreFileTracker.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/storefiletracker/TestChangeStoreFileTracker.java @@ -17,16 +17,15 @@ */ package org.apache.hadoop.hbase.regionserver.storefiletracker; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +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.DoNotRetryIOException; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseTestingUtil; import org.apache.hadoop.hbase.TableName; -import org.apache.hadoop.hbase.TableNameTestRule; +import org.apache.hadoop.hbase.TableNameTestExtension; import org.apache.hadoop.hbase.TableNotEnabledException; import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder; import org.apache.hadoop.hbase.client.Get; @@ -37,89 +36,97 @@ import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.util.Bytes; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.hbase.thirdparty.com.google.common.collect.Iterables; /** * Test changing store file tracker implementation by altering table. */ -@Category({ RegionServerTests.class, MediumTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(MediumTests.TAG) public class TestChangeStoreFileTracker { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestChangeStoreFileTracker.class); - private static final HBaseTestingUtil UTIL = new HBaseTestingUtil(); - @Rule - public final TableNameTestRule tableName = new TableNameTestRule(); + @RegisterExtension + public final TableNameTestExtension tableName = new TableNameTestExtension(); - @BeforeClass + @BeforeAll public static void setUp() throws Exception { UTIL.startMiniCluster(1); } - @AfterClass + @AfterAll public static void tearDown() throws IOException { UTIL.shutdownMiniCluster(); } - @Test(expected = DoNotRetryIOException.class) + @Test public void testCreateError() throws IOException { - TableDescriptor td = TableDescriptorBuilder.newBuilder(tableName.getTableName()) - .setColumnFamily(ColumnFamilyDescriptorBuilder.of("family")) - .setValue(StoreFileTrackerFactory.TRACKER_IMPL, - StoreFileTrackerFactory.Trackers.MIGRATION.name()) - .setValue(MigrationStoreFileTracker.SRC_IMPL, StoreFileTrackerFactory.Trackers.DEFAULT.name()) - .setValue(MigrationStoreFileTracker.DST_IMPL, StoreFileTrackerFactory.Trackers.FILE.name()) - .build(); - UTIL.getAdmin().createTable(td); + assertThrows(DoNotRetryIOException.class, () -> { + TableDescriptor td = TableDescriptorBuilder.newBuilder(tableName.getTableName()) + .setColumnFamily(ColumnFamilyDescriptorBuilder.of("family")) + .setValue(StoreFileTrackerFactory.TRACKER_IMPL, + StoreFileTrackerFactory.Trackers.MIGRATION.name()) + .setValue(MigrationStoreFileTracker.SRC_IMPL, + StoreFileTrackerFactory.Trackers.DEFAULT.name()) + .setValue(MigrationStoreFileTracker.DST_IMPL, StoreFileTrackerFactory.Trackers.FILE.name()) + .build(); + UTIL.getAdmin().createTable(td); + }); } - @Test(expected = DoNotRetryIOException.class) + @Test public void testModifyError1() throws IOException { - TableDescriptor td = TableDescriptorBuilder.newBuilder(tableName.getTableName()) - .setColumnFamily(ColumnFamilyDescriptorBuilder.of("family")).build(); - UTIL.getAdmin().createTable(td); - TableDescriptor newTd = TableDescriptorBuilder.newBuilder(td) - .setValue(StoreFileTrackerFactory.TRACKER_IMPL, StoreFileTrackerFactory.Trackers.FILE.name()) - .build(); - UTIL.getAdmin().modifyTable(newTd); + assertThrows(DoNotRetryIOException.class, () -> { + TableDescriptor td = TableDescriptorBuilder.newBuilder(tableName.getTableName()) + .setColumnFamily(ColumnFamilyDescriptorBuilder.of("family")).build(); + UTIL.getAdmin().createTable(td); + TableDescriptor newTd = + TableDescriptorBuilder.newBuilder(td).setValue(StoreFileTrackerFactory.TRACKER_IMPL, + StoreFileTrackerFactory.Trackers.FILE.name()).build(); + UTIL.getAdmin().modifyTable(newTd); + }); } - @Test(expected = DoNotRetryIOException.class) + @Test public void testModifyError2() throws IOException { - TableDescriptor td = TableDescriptorBuilder.newBuilder(tableName.getTableName()) - .setColumnFamily(ColumnFamilyDescriptorBuilder.of("family")).build(); - UTIL.getAdmin().createTable(td); - TableDescriptor newTd = TableDescriptorBuilder.newBuilder(td) - .setValue(StoreFileTrackerFactory.TRACKER_IMPL, - StoreFileTrackerFactory.Trackers.MIGRATION.name()) - .setValue(MigrationStoreFileTracker.SRC_IMPL, StoreFileTrackerFactory.Trackers.FILE.name()) - .setValue(MigrationStoreFileTracker.DST_IMPL, StoreFileTrackerFactory.Trackers.DEFAULT.name()) - .build(); - UTIL.getAdmin().modifyTable(newTd); + assertThrows(DoNotRetryIOException.class, () -> { + TableDescriptor td = TableDescriptorBuilder.newBuilder(tableName.getTableName()) + .setColumnFamily(ColumnFamilyDescriptorBuilder.of("family")).build(); + UTIL.getAdmin().createTable(td); + TableDescriptor newTd = TableDescriptorBuilder.newBuilder(td) + .setValue(StoreFileTrackerFactory.TRACKER_IMPL, + StoreFileTrackerFactory.Trackers.MIGRATION.name()) + .setValue(MigrationStoreFileTracker.SRC_IMPL, StoreFileTrackerFactory.Trackers.FILE.name()) + .setValue(MigrationStoreFileTracker.DST_IMPL, + StoreFileTrackerFactory.Trackers.DEFAULT.name()) + .build(); + UTIL.getAdmin().modifyTable(newTd); + }); } - @Test(expected = DoNotRetryIOException.class) + @Test public void testModifyError3() throws IOException { - TableDescriptor td = TableDescriptorBuilder.newBuilder(tableName.getTableName()) - .setColumnFamily(ColumnFamilyDescriptorBuilder.of("family")).build(); - UTIL.getAdmin().createTable(td); - TableDescriptor newTd = TableDescriptorBuilder.newBuilder(td) - .setValue(StoreFileTrackerFactory.TRACKER_IMPL, - StoreFileTrackerFactory.Trackers.MIGRATION.name()) - .setValue(MigrationStoreFileTracker.SRC_IMPL, StoreFileTrackerFactory.Trackers.DEFAULT.name()) - .setValue(MigrationStoreFileTracker.DST_IMPL, StoreFileTrackerFactory.Trackers.DEFAULT.name()) - .build(); - UTIL.getAdmin().modifyTable(newTd); + assertThrows(DoNotRetryIOException.class, () -> { + TableDescriptor td = TableDescriptorBuilder.newBuilder(tableName.getTableName()) + .setColumnFamily(ColumnFamilyDescriptorBuilder.of("family")).build(); + UTIL.getAdmin().createTable(td); + TableDescriptor newTd = TableDescriptorBuilder.newBuilder(td) + .setValue(StoreFileTrackerFactory.TRACKER_IMPL, + StoreFileTrackerFactory.Trackers.MIGRATION.name()) + .setValue(MigrationStoreFileTracker.SRC_IMPL, + StoreFileTrackerFactory.Trackers.DEFAULT.name()) + .setValue(MigrationStoreFileTracker.DST_IMPL, + StoreFileTrackerFactory.Trackers.DEFAULT.name()) + .build(); + UTIL.getAdmin().modifyTable(newTd); + }); } // return the TableDescriptor for creating table @@ -137,64 +144,77 @@ private TableDescriptor createTableAndChangeToMigrationTracker() throws IOExcept return td; } - @Test(expected = DoNotRetryIOException.class) + @Test public void testModifyError4() throws IOException { - TableDescriptor td = createTableAndChangeToMigrationTracker(); - TableDescriptor newTd = TableDescriptorBuilder.newBuilder(td) - .setValue(StoreFileTrackerFactory.TRACKER_IMPL, - StoreFileTrackerFactory.Trackers.MIGRATION.name()) - .setValue(MigrationStoreFileTracker.SRC_IMPL, StoreFileTrackerFactory.Trackers.FILE.name()) - .setValue(MigrationStoreFileTracker.DST_IMPL, StoreFileTrackerFactory.Trackers.DEFAULT.name()) - .build(); - UTIL.getAdmin().modifyTable(newTd); + assertThrows(DoNotRetryIOException.class, () -> { + TableDescriptor td = createTableAndChangeToMigrationTracker(); + TableDescriptor newTd = TableDescriptorBuilder.newBuilder(td) + .setValue(StoreFileTrackerFactory.TRACKER_IMPL, + StoreFileTrackerFactory.Trackers.MIGRATION.name()) + .setValue(MigrationStoreFileTracker.SRC_IMPL, StoreFileTrackerFactory.Trackers.FILE.name()) + .setValue(MigrationStoreFileTracker.DST_IMPL, + StoreFileTrackerFactory.Trackers.DEFAULT.name()) + .build(); + UTIL.getAdmin().modifyTable(newTd); + }); } - @Test(expected = DoNotRetryIOException.class) + @Test public void testModifyError5() throws IOException { - TableDescriptor td = createTableAndChangeToMigrationTracker(); - TableDescriptor newTd = TableDescriptorBuilder.newBuilder(td) - .setValue(StoreFileTrackerFactory.TRACKER_IMPL, - StoreFileTrackerFactory.Trackers.MIGRATION.name()) - .setValue(MigrationStoreFileTracker.SRC_IMPL, StoreFileTrackerFactory.Trackers.DEFAULT.name()) - .setValue(MigrationStoreFileTracker.DST_IMPL, StoreFileTrackerFactory.Trackers.DEFAULT.name()) - .build(); - UTIL.getAdmin().modifyTable(newTd); + assertThrows(DoNotRetryIOException.class, () -> { + TableDescriptor td = createTableAndChangeToMigrationTracker(); + TableDescriptor newTd = TableDescriptorBuilder.newBuilder(td) + .setValue(StoreFileTrackerFactory.TRACKER_IMPL, + StoreFileTrackerFactory.Trackers.MIGRATION.name()) + .setValue(MigrationStoreFileTracker.SRC_IMPL, + StoreFileTrackerFactory.Trackers.DEFAULT.name()) + .setValue(MigrationStoreFileTracker.DST_IMPL, + StoreFileTrackerFactory.Trackers.DEFAULT.name()) + .build(); + UTIL.getAdmin().modifyTable(newTd); + }); } - @Test(expected = DoNotRetryIOException.class) + @Test public void testModifyError6() throws IOException { - TableDescriptor td = createTableAndChangeToMigrationTracker(); - TableDescriptor newTd = - TableDescriptorBuilder.newBuilder(td).setValue(StoreFileTrackerFactory.TRACKER_IMPL, - StoreFileTrackerFactory.Trackers.DEFAULT.name()).build(); - UTIL.getAdmin().modifyTable(newTd); + assertThrows(DoNotRetryIOException.class, () -> { + TableDescriptor td = createTableAndChangeToMigrationTracker(); + TableDescriptor newTd = + TableDescriptorBuilder.newBuilder(td).setValue(StoreFileTrackerFactory.TRACKER_IMPL, + StoreFileTrackerFactory.Trackers.DEFAULT.name()).build(); + UTIL.getAdmin().modifyTable(newTd); + }); } - @Test(expected = DoNotRetryIOException.class) + @Test public void testModifyError7() throws IOException { - TableDescriptor td = TableDescriptorBuilder.newBuilder(tableName.getTableName()) - .setColumnFamily(ColumnFamilyDescriptorBuilder.of("family")).build(); - UTIL.getAdmin().createTable(td); - TableDescriptor newTd = TableDescriptorBuilder.newBuilder(tableName.getTableName()) - .setColumnFamily(ColumnFamilyDescriptorBuilder.of("family")) - .setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes("family1")) - .setConfiguration(StoreFileTrackerFactory.TRACKER_IMPL, - StoreFileTrackerFactory.Trackers.MIGRATION.name()) - .build()) - .build(); - UTIL.getAdmin().modifyTable(newTd); + assertThrows(DoNotRetryIOException.class, () -> { + TableDescriptor td = TableDescriptorBuilder.newBuilder(tableName.getTableName()) + .setColumnFamily(ColumnFamilyDescriptorBuilder.of("family")).build(); + UTIL.getAdmin().createTable(td); + TableDescriptor newTd = TableDescriptorBuilder.newBuilder(tableName.getTableName()) + .setColumnFamily(ColumnFamilyDescriptorBuilder.of("family")) + .setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes("family1")) + .setConfiguration(StoreFileTrackerFactory.TRACKER_IMPL, + StoreFileTrackerFactory.Trackers.MIGRATION.name()) + .build()) + .build(); + UTIL.getAdmin().modifyTable(newTd); + }); } // actually a NPE as we do not specify the src and dst impl for migration store file tracker - @Test(expected = IOException.class) + @Test public void testModifyError8() throws IOException { - TableDescriptor td = TableDescriptorBuilder.newBuilder(tableName.getTableName()) - .setColumnFamily(ColumnFamilyDescriptorBuilder.of("family")).build(); - UTIL.getAdmin().createTable(td); - TableDescriptor newTd = - TableDescriptorBuilder.newBuilder(td).setValue(StoreFileTrackerFactory.TRACKER_IMPL, - StoreFileTrackerFactory.Trackers.MIGRATION.name()).build(); - UTIL.getAdmin().modifyTable(newTd); + assertThrows(IOException.class, () -> { + TableDescriptor td = TableDescriptorBuilder.newBuilder(tableName.getTableName()) + .setColumnFamily(ColumnFamilyDescriptorBuilder.of("family")).build(); + UTIL.getAdmin().createTable(td); + TableDescriptor newTd = + TableDescriptorBuilder.newBuilder(td).setValue(StoreFileTrackerFactory.TRACKER_IMPL, + StoreFileTrackerFactory.Trackers.MIGRATION.name()).build(); + UTIL.getAdmin().modifyTable(newTd); + }); } @Test diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/storefiletracker/TestMigrationStoreFileTracker.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/storefiletracker/TestMigrationStoreFileTracker.java index 67d2dc4e3bca..91de67629b11 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/storefiletracker/TestMigrationStoreFileTracker.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/storefiletracker/TestMigrationStoreFileTracker.java @@ -19,15 +19,16 @@ import static org.hamcrest.CoreMatchers.hasItems; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; +import java.util.stream.Stream; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; -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.client.ColumnFamilyDescriptorBuilder; @@ -45,30 +46,22 @@ import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.wal.WAL; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.rules.TestName; -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.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.TestTemplate; +import org.junit.jupiter.params.provider.Arguments; import org.apache.hbase.thirdparty.com.google.common.collect.Iterables; import org.apache.hbase.thirdparty.com.google.common.io.Closeables; -@RunWith(Parameterized.class) -@Category({ RegionServerTests.class, MediumTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(MediumTests.TAG) +@HBaseParameterizedTestTemplate(name = "{index}: src={0}, dst={1}") public class TestMigrationStoreFileTracker { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestMigrationStoreFileTracker.class); - private static final HBaseTestingUtil UTIL = new HBaseTestingUtil(); private static final byte[] CF = Bytes.toBytes("cf"); @@ -81,14 +74,17 @@ public class TestMigrationStoreFileTracker { private static final RegionInfo RI = RegionInfoBuilder.newBuilder(TD.getTableName()).build(); - @Rule - public TestName name = new TestName(); + private String name; + + private final StoreFileTrackerFactory.Trackers srcImpl; - @Parameter(0) - public StoreFileTrackerFactory.Trackers srcImpl; + private final StoreFileTrackerFactory.Trackers dstImpl; - @Parameter(1) - public StoreFileTrackerFactory.Trackers dstImpl; + public TestMigrationStoreFileTracker(StoreFileTrackerFactory.Trackers srcImpl, + StoreFileTrackerFactory.Trackers dstImpl) { + this.srcImpl = srcImpl; + this.dstImpl = dstImpl; + } private HRegion region; @@ -96,9 +92,8 @@ public class TestMigrationStoreFileTracker { private WAL wal; - @Parameters(name = "{index}: src={0}, dst={1}") - public static List params() { - List params = new ArrayList<>(); + public static Stream parameters() { + List params = new ArrayList<>(); for (StoreFileTrackerFactory.Trackers src : StoreFileTrackerFactory.Trackers.values()) { for (StoreFileTrackerFactory.Trackers dst : StoreFileTrackerFactory.Trackers.values()) { if ( @@ -110,28 +105,29 @@ public static List params() { if (src.equals(dst)) { continue; } - params.add(new Object[] { src, dst }); + params.add(Arguments.of(src, dst)); } } - return params; + return params.stream(); } - @BeforeClass + @BeforeAll public static void setUpBeforeClass() { ChunkCreator.initialize(MemStoreLAB.CHUNK_SIZE_DEFAULT, false, 0, 0, 0, null, MemStoreLAB.INDEX_CHUNK_SIZE_PERCENTAGE_DEFAULT); } - @Before - public void setUp() throws IOException { + @BeforeEach + public void setUp(TestInfo testInfo) throws IOException { + name = testInfo.getTestMethod().get().getName(); Configuration conf = UTIL.getConfiguration(); conf.set(MigrationStoreFileTracker.SRC_IMPL, srcImpl.name().toLowerCase()); conf.set(MigrationStoreFileTracker.DST_IMPL, dstImpl.name().toLowerCase()); - rootDir = UTIL.getDataTestDir(name.getMethodName().replaceAll("[=:\\[ ]", "_")); + rootDir = UTIL.getDataTestDir(name.replaceAll("[=:\\[ ]", "_")); wal = HBaseTestingUtil.createWal(conf, rootDir, RI); } - @After + @AfterEach public void tearDown() throws IOException { if (region != null) { region.close(); @@ -181,7 +177,7 @@ private void verifyData(int start, int end) throws IOException { } } - @Test + @TestTemplate public void testMigration() throws IOException { region = createRegion(srcImpl.clazz.asSubclass(StoreFileTrackerBase.class)); putData(0, 100); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/storefiletracker/TestRegionWithFileBasedStoreFileTracker.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/storefiletracker/TestRegionWithFileBasedStoreFileTracker.java index e1bafb5fffed..d6cce049a21c 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/storefiletracker/TestRegionWithFileBasedStoreFileTracker.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/storefiletracker/TestRegionWithFileBasedStoreFileTracker.java @@ -17,11 +17,10 @@ */ package org.apache.hadoop.hbase.regionserver.storefiletracker; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseTestingUtil; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder; @@ -36,21 +35,16 @@ import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.util.Bytes; -import org.junit.After; -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.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; -@Category({ RegionServerTests.class, MediumTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(MediumTests.TAG) public class TestRegionWithFileBasedStoreFileTracker { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestRegionWithFileBasedStoreFileTracker.class); - private static final HBaseTestingUtil UTIL = new HBaseTestingUtil(); private static final byte[] CF = Bytes.toBytes("cf"); @@ -63,20 +57,19 @@ public class TestRegionWithFileBasedStoreFileTracker { private static final RegionInfo RI = RegionInfoBuilder.newBuilder(TD.getTableName()).build(); - @Rule - public TestName name = new TestName(); + private String name; private HRegion region; - @Before - public void setUp() throws IOException { + @BeforeEach + public void setUp(TestInfo testInfo) throws IOException { + name = testInfo.getTestMethod().get().getName(); Configuration conf = new Configuration(UTIL.getConfiguration()); conf.set(StoreFileTrackerFactory.TRACKER_IMPL, StoreFileTrackerFactory.Trackers.FILE.name()); - region = - HBaseTestingUtil.createRegionAndWAL(RI, UTIL.getDataTestDir(name.getMethodName()), conf, TD); + region = HBaseTestingUtil.createRegionAndWAL(RI, UTIL.getDataTestDir(name), conf, TD); } - @After + @AfterEach public void tearDown() throws IOException { if (region != null) { HBaseTestingUtil.closeRegionAndWAL(region); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/storefiletracker/TestStoreFileListFile.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/storefiletracker/TestStoreFileListFile.java index 64865caac1e3..54db419ef897 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/storefiletracker/TestStoreFileListFile.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/storefiletracker/TestStoreFileListFile.java @@ -17,10 +17,10 @@ */ package org.apache.hadoop.hbase.regionserver.storefiletracker; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThrows; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.mock; @@ -33,7 +33,6 @@ import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseCommonTestingUtil; import org.apache.hadoop.hbase.io.Reference; import org.apache.hadoop.hbase.regionserver.HRegionFileSystem; @@ -43,13 +42,11 @@ import org.apache.hadoop.hbase.testclassification.SmallTests; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; -import org.junit.AfterClass; -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.TestName; +import org.junit.jupiter.api.AfterAll; +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.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -58,13 +55,10 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.StoreFileTrackerProtos.StoreFileEntry; import org.apache.hadoop.hbase.shaded.protobuf.generated.StoreFileTrackerProtos.StoreFileList; -@Category({ RegionServerTests.class, SmallTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(SmallTests.TAG) public class TestStoreFileListFile { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestStoreFileListFile.class); - private static final Logger LOG = LoggerFactory.getLogger(TestStoreFileListFile.class); private static final HBaseCommonTestingUtil UTIL = new HBaseCommonTestingUtil(); @@ -73,8 +67,7 @@ public class TestStoreFileListFile { private StoreFileListFile storeFileListFile; - @Rule - public TestName name = new TestName(); + private String name; private StoreFileListFile create() throws IOException { HRegionFileSystem hfs = mock(HRegionFileSystem.class); @@ -84,13 +77,14 @@ private StoreFileListFile create() throws IOException { return new StoreFileListFile(ctx); } - @Before - public void setUp() throws IOException { - testDir = UTIL.getDataTestDir(name.getMethodName()); + @BeforeEach + public void setUp(TestInfo testInfo) throws IOException { + name = testInfo.getTestMethod().get().getName(); + testDir = UTIL.getDataTestDir(name); storeFileListFile = create(); } - @AfterClass + @AfterAll public static void tearDown() { UTIL.cleanupTestDir(); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/storefiletracker/TestStoreFileListFilePrinter.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/storefiletracker/TestStoreFileListFilePrinter.java index 0887413cb623..c885fb511079 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/storefiletracker/TestStoreFileListFilePrinter.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/storefiletracker/TestStoreFileListFilePrinter.java @@ -17,7 +17,7 @@ */ package org.apache.hadoop.hbase.regionserver.storefiletracker; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -28,10 +28,9 @@ import org.apache.hadoop.fs.LocatedFileStatus; import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.RemoteIterator; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseTestingUtil; import org.apache.hadoop.hbase.TableName; -import org.apache.hadoop.hbase.TableNameTestRule; +import org.apache.hadoop.hbase.TableNameTestExtension; import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Table; @@ -41,34 +40,30 @@ import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.util.Bytes; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.hbase.thirdparty.com.google.common.collect.Iterables; -@Category({ RegionServerTests.class, MediumTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(MediumTests.TAG) public class TestStoreFileListFilePrinter { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestStoreFileListFilePrinter.class); - private static final HBaseTestingUtil UTIL = new HBaseTestingUtil(); - @Rule - public final TableNameTestRule tableName = new TableNameTestRule(); + @RegisterExtension + public final TableNameTestExtension tableName = new TableNameTestExtension(); public static byte[] family = Bytes.toBytes("F");; - @BeforeClass + @BeforeAll public static void setUp() throws Exception { UTIL.startMiniCluster(1); } - @AfterClass + @AfterAll public static void tearDown() throws Exception { UTIL.shutdownMiniCluster(); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/storefiletracker/TestStoreFileTrackerFactory.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/storefiletracker/TestStoreFileTrackerFactory.java index 0d6670aafdea..14b8e2836a62 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/storefiletracker/TestStoreFileTrackerFactory.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/storefiletracker/TestStoreFileTrackerFactory.java @@ -17,25 +17,20 @@ */ package org.apache.hadoop.hbase.regionserver.storefiletracker; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertThrows; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.regionserver.StoreContext; import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.testclassification.SmallTests; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category({ RegionServerTests.class, SmallTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(SmallTests.TAG) public class TestStoreFileTrackerFactory { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestStoreFileTrackerFactory.class); - @Test public void testCreateForMigration() { Configuration conf = HBaseConfiguration.create(); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/storefiletracker/TestStoreFileTrackerValidationUtils.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/storefiletracker/TestStoreFileTrackerValidationUtils.java index 788f1823528d..71999ded9d89 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/storefiletracker/TestStoreFileTrackerValidationUtils.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/storefiletracker/TestStoreFileTrackerValidationUtils.java @@ -17,10 +17,9 @@ */ package org.apache.hadoop.hbase.regionserver.storefiletracker; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertThrows; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor; import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder; @@ -30,17 +29,13 @@ import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.testclassification.SmallTests; import org.apache.hadoop.hbase.util.Bytes; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category({ RegionServerTests.class, SmallTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(SmallTests.TAG) public class TestStoreFileTrackerValidationUtils { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestStoreFileTrackerValidationUtils.class); - @Test public void testCheckSFTCompatibility() throws Exception { // checking default value change on different configuration levels diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/throttle/TestCompactionWithThroughputController.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/throttle/TestCompactionWithThroughputController.java index 8c7262e56cb9..bafbf019adb2 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/throttle/TestCompactionWithThroughputController.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/throttle/TestCompactionWithThroughputController.java @@ -20,13 +20,12 @@ import static org.apache.hadoop.hbase.regionserver.throttle.PressureAwareCompactionThroughputController.HBASE_HSTORE_COMPACTION_MAX_THROUGHPUT_HIGHER_BOUND; import static org.apache.hadoop.hbase.regionserver.throttle.PressureAwareCompactionThroughputController.HBASE_HSTORE_COMPACTION_MAX_THROUGHPUT_LOWER_BOUND; import static org.apache.hadoop.hbase.regionserver.throttle.PressureAwareCompactionThroughputController.HBASE_HSTORE_COMPACTION_THROUGHPUT_TUNE_PERIOD; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; import java.util.List; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseTestingUtil; import org.apache.hadoop.hbase.SingleProcessHBaseCluster; import org.apache.hadoop.hbase.TableName; @@ -51,19 +50,15 @@ import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; import org.apache.hadoop.hbase.util.JVMClusterUtil; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -@Category({ RegionServerTests.class, LargeTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(LargeTests.TAG) public class TestCompactionWithThroughputController { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestCompactionWithThroughputController.class); - private static final Logger LOG = LoggerFactory.getLogger(TestCompactionWithThroughputController.class); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/throttle/TestFlushWithThroughputController.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/throttle/TestFlushWithThroughputController.java index c1d9e2788d47..99136779ff14 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/throttle/TestFlushWithThroughputController.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/throttle/TestFlushWithThroughputController.java @@ -17,15 +17,14 @@ */ package org.apache.hadoop.hbase.regionserver.throttle; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseTestingUtil; import org.apache.hadoop.hbase.SingleProcessHBaseCluster; import org.apache.hadoop.hbase.TableName; @@ -46,44 +45,38 @@ import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.JVMClusterUtil; import org.apache.hadoop.hbase.util.Pair; -import org.junit.After; -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.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.slf4j.Logger; import org.slf4j.LoggerFactory; -@Category(LargeTests.class) +@Tag(LargeTests.TAG) public class TestFlushWithThroughputController { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestFlushWithThroughputController.class); - private static final Logger LOG = LoggerFactory.getLogger(TestFlushWithThroughputController.class); private static final double EPSILON = 1.3E-6; private HBaseTestingUtil hbtu; - @Rule - public TestName testName = new TestName(); + private String testName; private TableName tableName; private final byte[] family = Bytes.toBytes("f"); private final byte[] qualifier = Bytes.toBytes("q"); - @Before - public void setUp() { + @BeforeEach + public void setUp(TestInfo testInfo) { + testName = testInfo.getTestMethod().get().getName(); hbtu = new HBaseTestingUtil(); - tableName = TableName.valueOf("Table-" + testName.getMethodName()); + tableName = TableName.valueOf("Table-" + testName); hbtu.getConfiguration().set( FlushThroughputControllerFactory.HBASE_FLUSH_THROUGHPUT_CONTROLLER_KEY, PressureAwareFlushThroughputController.class.getName()); } - @After + @AfterEach public void tearDown() throws Exception { hbtu.shutdownMiniCluster(); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/throttle/TestStoreHotnessProtector.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/throttle/TestStoreHotnessProtector.java index 290dce104876..e09735d99069 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/throttle/TestStoreHotnessProtector.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/throttle/TestStoreHotnessProtector.java @@ -20,6 +20,7 @@ import static org.apache.hadoop.hbase.regionserver.throttle.StoreHotnessProtector.PARALLEL_PREPARE_PUT_STORE_MULTIPLIER; import static org.apache.hadoop.hbase.regionserver.throttle.StoreHotnessProtector.PARALLEL_PUT_STORE_THREADS_LIMIT; import static org.apache.hadoop.hbase.regionserver.throttle.StoreHotnessProtector.PARALLEL_PUT_STORE_THREADS_LIMIT_MIN_COLUMN_COUNT; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -33,27 +34,20 @@ import java.util.concurrent.atomic.AtomicReference; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.Cell; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.RegionTooBusyException; import org.apache.hadoop.hbase.client.RegionInfo; import org.apache.hadoop.hbase.regionserver.Region; import org.apache.hadoop.hbase.regionserver.Store; import org.apache.hadoop.hbase.testclassification.SmallTests; import org.apache.hadoop.hbase.util.Bytes; -import org.junit.Assert; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import org.apache.hbase.thirdparty.com.google.common.collect.Lists; -@Category(SmallTests.class) +@Tag(SmallTests.TAG) public class TestStoreHotnessProtector { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestStoreHotnessProtector.class); - @Test public void testPreparePutCounter() throws Exception { @@ -103,10 +97,9 @@ public void testPreparePutCounter() throws Exception { countDownLatch.await(60, TimeUnit.SECONDS); // no exception - Assert.assertEquals(exception.get(), null); - Assert.assertEquals(storeHotnessProtector.getPreparePutToStoreMap().size(), 1); - Assert.assertEquals(storeHotnessProtector.getPreparePutToStoreMap().get(family).get(), - threadCount); + assertEquals(exception.get(), null); + assertEquals(storeHotnessProtector.getPreparePutToStoreMap().size(), 1); + assertEquals(storeHotnessProtector.getPreparePutToStoreMap().get(family).get(), threadCount); // access limit @@ -117,16 +110,15 @@ public void testPreparePutCounter() throws Exception { exception.set(e); } - Assert.assertEquals(exception.get().getClass(), RegionTooBusyException.class); + assertEquals(exception.get().getClass(), RegionTooBusyException.class); - Assert.assertEquals(storeHotnessProtector.getPreparePutToStoreMap().size(), 1); + assertEquals(storeHotnessProtector.getPreparePutToStoreMap().size(), 1); // when access limit, counter will not changed. - Assert.assertEquals(storeHotnessProtector.getPreparePutToStoreMap().get(family).get(), + assertEquals(storeHotnessProtector.getPreparePutToStoreMap().get(family).get(), threadCount + 1); storeHotnessProtector.finish(familyMaps); - Assert.assertEquals(storeHotnessProtector.getPreparePutToStoreMap().get(family).get(), - threadCount); + assertEquals(storeHotnessProtector.getPreparePutToStoreMap().get(family).get(), threadCount); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestFSWAL.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestFSWAL.java index f26c3f3e6610..808db7c8c0ee 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestFSWAL.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestFSWAL.java @@ -19,12 +19,13 @@ import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -90,12 +91,11 @@ import org.apache.hadoop.hbase.wal.WALEditInternalHelper; import org.apache.hadoop.hbase.wal.WALKey; import org.apache.hadoop.hbase.wal.WALKeyImpl; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestName; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -108,23 +108,23 @@ public abstract class AbstractTestFSWAL { protected static Path DIR; protected final static HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil(); - @Rule - public final TestName currentTest = new TestName(); + protected String currentTest; - @Before - public void setUp() throws Exception { + @BeforeEach + public void setUp(TestInfo testInfo) throws Exception { + currentTest = testInfo.getTestMethod().get().getName(); FileStatus[] entries = FS.listStatus(new Path("/")); for (FileStatus dir : entries) { FS.delete(dir.getPath(), true); } final Path hbaseDir = TEST_UTIL.createRootDir(); final Path hbaseWALDir = TEST_UTIL.createWALRootDir(); - DIR = new Path(hbaseWALDir, currentTest.getMethodName()); + DIR = new Path(hbaseWALDir, currentTest); assertNotEquals(hbaseDir, hbaseWALDir); FS.mkdirs(DIR); } - @BeforeClass + @BeforeAll public static void setUpBeforeClass() throws Exception { // Make block sizes small. TEST_UTIL.getConfiguration().setInt("dfs.blocksize", 1024 * 1024); @@ -145,7 +145,7 @@ public static void setUpBeforeClass() throws Exception { FS = TEST_UTIL.getDFSCluster().getFileSystem(); } - @AfterClass + @AfterAll public static void tearDownAfterClass() throws Exception { TEST_UTIL.shutdownMiniCluster(); } @@ -237,14 +237,14 @@ public void testWALComparator() throws Exception { } catch (IllegalArgumentException e) { ex = true; } - assertTrue("Comparator doesn't complain while checking meta log files", ex); + assertTrue(ex, "Comparator doesn't complain while checking meta log files"); boolean exMeta = false; try { compMeta.compare(p1WithMeta, p2); } catch (IllegalArgumentException e) { exMeta = true; } - assertTrue("Meta comparator doesn't complain while checking log files", exMeta); + assertTrue(exMeta, "Meta comparator doesn't complain while checking log files"); } finally { if (wal1 != null) { wal1.close(); @@ -391,20 +391,22 @@ public void testFindMemStoresEligibleForFlush() throws Exception { } - @Test(expected = IOException.class) + @Test public void testFailedToCreateWALIfParentRenamed() throws IOException, CommonFSUtils.StreamLacksCapabilityException { - AbstractFSWAL wal = newWAL(FS, CommonFSUtils.getWALRootDir(CONF), - currentTest.getMethodName(), HConstants.HREGION_OLDLOGDIR_NAME, CONF, null, true, null, null); - long filenum = EnvironmentEdgeManager.currentTime(); - Path path = wal.computeFilename(filenum); - wal.createWriterInstance(FS, path); - Path parent = path.getParent(); - path = wal.computeFilename(filenum + 1); - Path newPath = new Path(parent.getParent(), parent.getName() + "-splitting"); - FS.rename(parent, newPath); - wal.createWriterInstance(FS, path); - fail("It should fail to create the new WAL"); + assertThrows(IOException.class, () -> { + AbstractFSWAL wal = newWAL(FS, CommonFSUtils.getWALRootDir(CONF), currentTest, + HConstants.HREGION_OLDLOGDIR_NAME, CONF, null, true, null, null); + long filenum = EnvironmentEdgeManager.currentTime(); + Path path = wal.computeFilename(filenum); + wal.createWriterInstance(FS, path); + Path parent = path.getParent(); + path = wal.computeFilename(filenum + 1); + Path newPath = new Path(parent.getParent(), parent.getName() + "-splitting"); + FS.rename(parent, newPath); + wal.createWriterInstance(FS, path); + fail("It should fail to create the new WAL"); + }); } /** @@ -416,7 +418,7 @@ public void testFailedToCreateWALIfParentRenamed() */ @Test public void testFlushSequenceIdIsGreaterThanAllEditsInHFile() throws IOException { - String testName = currentTest.getMethodName(); + String testName = currentTest; final TableName tableName = TableName.valueOf(testName); final RegionInfo hri = RegionInfoBuilder.newBuilder(tableName).build(); final byte[] rowName = tableName.getName(); @@ -491,7 +493,7 @@ public void run() { @Test public void testSyncNoAppend() throws IOException { - String testName = currentTest.getMethodName(); + String testName = currentTest; AbstractFSWAL wal = newWAL(FS, CommonFSUtils.getWALRootDir(CONF), DIR.toString(), testName, CONF, null, true, null, null); try { @@ -503,7 +505,7 @@ public void testSyncNoAppend() throws IOException { @Test public void testWriteEntryCanBeNull() throws IOException { - String testName = currentTest.getMethodName(); + String testName = currentTest; AbstractFSWAL wal = newWAL(FS, CommonFSUtils.getWALRootDir(CONF), DIR.toString(), testName, CONF, null, true, null, null); wal.close(); @@ -533,13 +535,15 @@ public void testWriteEntryCanBeNull() throws IOException { } } - @Test(expected = WALClosedException.class) + @Test public void testRollWriterForClosedWAL() throws IOException { - String testName = currentTest.getMethodName(); - AbstractFSWAL wal = newWAL(FS, CommonFSUtils.getWALRootDir(CONF), DIR.toString(), testName, - CONF, null, true, null, null); - wal.close(); - wal.rollWriter(); + assertThrows(WALClosedException.class, () -> { + String testName = currentTest; + AbstractFSWAL wal = newWAL(FS, CommonFSUtils.getWALRootDir(CONF), DIR.toString(), testName, + CONF, null, true, null, null); + wal.close(); + wal.rollWriter(); + }); } private AbstractFSWAL createHoldingWAL(String testName, AtomicBoolean startHoldingForAppend, @@ -602,7 +606,7 @@ private void doPutWithAsyncWAL(ExecutorService exec, HRegion region, Put put, // Testcase for HBASE-23181 @Test public void testUnflushedSeqIdTrackingWithAsyncWal() throws IOException, InterruptedException { - String testName = currentTest.getMethodName(); + String testName = currentTest; byte[] b = Bytes.toBytes("b"); TableDescriptor htd = TableDescriptorBuilder.newBuilder(TableName.valueOf("table")) .setColumnFamily(ColumnFamilyDescriptorBuilder.of(b)).build(); @@ -627,8 +631,8 @@ public void testUnflushedSeqIdTrackingWithAsyncWal() throws IOException, Interru // now check the region's unflushed seqIds. long seqId = getEarliestMemStoreSeqNum(wal, region.getRegionInfo().getEncodedNameAsBytes()); - assertEquals("Found seqId for the region which is already closed", HConstants.NO_SEQNUM, - seqId); + assertEquals(HConstants.NO_SEQNUM, seqId, + "Found seqId for the region which is already closed"); } finally { exec.shutdownNow(); region.close(); @@ -652,7 +656,7 @@ public static long getEarliestMemStoreSeqNum(WAL wal, byte[] encodedRegionName) // Testcase for HBASE-23157 @Test public void testMaxFlushedSequenceIdGoBackwards() throws IOException, InterruptedException { - String testName = currentTest.getMethodName(); + String testName = currentTest; byte[] a = Bytes.toBytes("a"); byte[] b = Bytes.toBytes("b"); TableDescriptor htd = TableDescriptorBuilder.newBuilder(TableName.valueOf("table")) @@ -693,10 +697,8 @@ public void testMaxFlushedSequenceIdGoBackwards() throws IOException, Interrupte // get the max flushed sequence id after the second flush long maxFlushedSeqId2 = region.getMaxFlushedSeqId(); // make sure that the maxFlushedSequenceId does not go backwards - assertTrue( - "maxFlushedSeqId1(" + maxFlushedSeqId1 - + ") is not greater than or equal to maxFlushedSeqId2(" + maxFlushedSeqId2 + ")", - maxFlushedSeqId1 <= maxFlushedSeqId2); + assertTrue(maxFlushedSeqId1 <= maxFlushedSeqId2, "maxFlushedSeqId1(" + maxFlushedSeqId1 + + ") is not greater than or equal to maxFlushedSeqId2(" + maxFlushedSeqId2 + ")"); } finally { exec.shutdownNow(); region.close(); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestLogRollPeriod.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestLogRollPeriod.java index f86c4ffa42c3..7d58b88f9481 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestLogRollPeriod.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestLogRollPeriod.java @@ -17,7 +17,7 @@ */ package org.apache.hadoop.hbase.regionserver.wal; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertFalse; import java.util.ArrayList; import java.util.List; @@ -30,9 +30,8 @@ import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; import org.apache.hadoop.hbase.wal.WAL; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -46,7 +45,6 @@ public abstract class AbstractTestLogRollPeriod { private final static long LOG_ROLL_PERIOD = 4000; - @BeforeClass public static void setUpBeforeClass() throws Exception { // disable the ui TEST_UTIL.getConfiguration().setInt("hbase.regionsever.info.port", -1); @@ -56,7 +54,7 @@ public static void setUpBeforeClass() throws Exception { TEST_UTIL.startMiniCluster(); } - @AfterClass + @AfterAll public static void tearDownAfterClass() throws Exception { TEST_UTIL.shutdownMiniCluster(); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestLogRolling.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestLogRolling.java index 2a5aec458828..31f3d20c3cf2 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestLogRolling.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestLogRolling.java @@ -19,9 +19,10 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.greaterThan; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; import java.util.concurrent.Executors; @@ -55,14 +56,12 @@ import org.apache.hadoop.hbase.wal.WALFactory; import org.apache.hadoop.hbase.wal.WALProvider; import org.apache.hadoop.hdfs.MiniDFSCluster; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestName; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -81,8 +80,7 @@ public abstract class AbstractTestLogRolling { protected Admin admin; protected SingleProcessHBaseCluster cluster; protected static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil(); - @Rule - public final TestName name = new TestName(); + private String name; protected static int syncLatencyMillis; private static int rowNum = 1; private static final AtomicBoolean slowSyncHookCalled = new AtomicBoolean(); @@ -102,7 +100,7 @@ public AbstractTestLogRolling() { // Need to override this setup so we can edit the config before it gets sent // to the HDFS & HBase cluster startup. - @BeforeClass + @BeforeAll public static void setUpBeforeClass() throws Exception { /**** configuration for testLogRolling ****/ // Force a region split after every 768KB @@ -144,7 +142,12 @@ public static void setUpBeforeClass() throws Exception { .setDaemon(true).setUncaughtExceptionHandler(Threads.LOGGING_EXCEPTION_HANDLER).build()); } - @Before + @BeforeEach + public void initTestName(TestInfo testInfo) { + name = testInfo.getTestMethod().get().getName(); + } + + @BeforeEach public void setUp() throws Exception { // Use 2 DataNodes and default values for other StartMiniCluster options. TEST_UTIL.startMiniCluster(StartTestingClusterOption.builder().numDataNodes(2).build()); @@ -158,12 +161,12 @@ public void setUp() throws Exception { cluster.getMaster().balanceSwitch(false); } - @After + @AfterEach public void tearDown() throws Exception { TEST_UTIL.shutdownMiniCluster(); } - @AfterClass + @AfterAll public static void tearDownAfterClass() { EXECUTOR.shutdownNow(); } @@ -245,9 +248,9 @@ public String explainFailure() throws Exception { } }); - assertTrue("Should have triggered log roll due to SLOW_SYNC", slowSyncHookCalled.get()); + assertTrue(slowSyncHookCalled.get(), "Should have triggered log roll due to SLOW_SYNC"); } else { - assertFalse("Should not have triggered log roll due to SLOW_SYNC", slowSyncHookCalled.get()); + assertFalse(slowSyncHookCalled.get(), "Should not have triggered log roll due to SLOW_SYNC"); } } @@ -306,7 +309,7 @@ public void testLogRolling() throws Exception { } protected String getName() { - return "TestLogRolling-" + name.getMethodName(); + return "TestLogRolling-" + name; } void writeData(Table table, int rownum) throws IOException { @@ -352,35 +355,35 @@ public void testCompactionRecordDoesntBlockRolling() throws Exception { admin.flush(table.getName()); } doPut(table, 3); // don't flush yet, or compaction might trigger before we roll WAL - assertEquals("Should have no WAL after initial writes", 0, - AbstractFSWALProvider.getNumRolledLogFiles(log)); + assertEquals(0, AbstractFSWALProvider.getNumRolledLogFiles(log), + "Should have no WAL after initial writes"); assertEquals(2, s.getStorefilesCount()); // Roll the log and compact table, to have compaction record in the 2nd WAL. log.rollWriter(); - assertEquals("Should have WAL; one table is not flushed", 1, - AbstractFSWALProvider.getNumRolledLogFiles(log)); + assertEquals(1, AbstractFSWALProvider.getNumRolledLogFiles(log), + "Should have WAL; one table is not flushed"); admin.flush(table.getName()); region.compact(false); // Wait for compaction in case if flush triggered it before us. - Assert.assertNotNull(s); + assertNotNull(s); for (int waitTime = 3000; s.getStorefilesCount() > 1 && waitTime > 0; waitTime -= 200) { Threads.sleepWithoutInterrupt(200); } - assertEquals("Compaction didn't happen", 1, s.getStorefilesCount()); + assertEquals(1, s.getStorefilesCount(), "Compaction didn't happen"); // Write some value to the table so the WAL cannot be deleted until table is flushed. doPut(table, 0); // Now 2nd WAL will have both compaction and put record for table. log.rollWriter(); // 1st WAL deleted, 2nd not deleted yet. - assertEquals("Should have WAL; one table is not flushed", 1, - AbstractFSWALProvider.getNumRolledLogFiles(log)); + assertEquals(1, AbstractFSWALProvider.getNumRolledLogFiles(log), + "Should have WAL; one table is not flushed"); // Flush table to make latest WAL obsolete; write another record, and roll again. admin.flush(table.getName()); doPut(table, 1); log.rollWriter(); // Now 2nd WAL is deleted and 3rd is added. - assertEquals("Should have 1 WALs at the end", 1, - AbstractFSWALProvider.getNumRolledLogFiles(log)); + assertEquals(1, AbstractFSWALProvider.getNumRolledLogFiles(log), + "Should have 1 WALs at the end"); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestProtobufLog.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestProtobufLog.java index 322c149897f2..687110dc61ac 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestProtobufLog.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestProtobufLog.java @@ -17,7 +17,7 @@ */ package org.apache.hadoop.hbase.regionserver.wal; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; import org.apache.hadoop.fs.FileStatus; @@ -29,13 +29,12 @@ import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; import org.apache.hadoop.hbase.wal.WALFactory; import org.apache.hadoop.hbase.wal.WALProvider; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestName; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; import org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.WALTrailer; @@ -49,17 +48,17 @@ public abstract class AbstractTestProtobufLog { protected Path dir; protected WALFactory wals; - @Rule - public final TestName currentTest = new TestName(); + private String currentTest; - @Before - public void setUp() throws Exception { + @BeforeEach + public void setUp(TestInfo testInfo) throws Exception { + currentTest = testInfo.getTestMethod().get().getName(); fs = TEST_UTIL.getDFSCluster().getFileSystem(); - dir = new Path(TEST_UTIL.createRootDir(), currentTest.getMethodName()); - wals = new WALFactory(TEST_UTIL.getConfiguration(), currentTest.getMethodName()); + dir = new Path(TEST_UTIL.createRootDir(), currentTest); + wals = new WALFactory(TEST_UTIL.getConfiguration(), currentTest); } - @After + @AfterEach public void tearDown() throws Exception { wals.close(); FileStatus[] entries = fs.listStatus(new Path("/")); @@ -68,7 +67,7 @@ public void tearDown() throws Exception { } } - @BeforeClass + @BeforeAll public static void setUpBeforeClass() throws Exception { // Make block sizes small. TEST_UTIL.getConfiguration().setInt("dfs.blocksize", 1024 * 1024); @@ -83,7 +82,7 @@ public static void setUpBeforeClass() throws Exception { TEST_UTIL.startMiniDFSCluster(3); } - @AfterClass + @AfterAll public static void tearDownAfterClass() throws Exception { TEST_UTIL.shutdownMiniCluster(); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestWALReplay.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestWALReplay.java index 0c205587091c..9736db486ad6 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestWALReplay.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestWALReplay.java @@ -17,10 +17,10 @@ */ package org.apache.hadoop.hbase.regionserver.wal; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; @@ -106,13 +106,11 @@ import org.apache.hadoop.hbase.wal.WALSplitter; import org.apache.hadoop.hbase.wal.WALStreamReader; import org.apache.hadoop.hdfs.DFSInputStream; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -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.Test; +import org.junit.jupiter.api.TestInfo; import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; @@ -134,10 +132,8 @@ public abstract class AbstractTestWALReplay { private Configuration conf; private WALFactory wals; - @Rule - public final TestName currentTest = new TestName(); + private String currentTest; - @BeforeClass public static void setUpBeforeClass() throws Exception { Configuration conf = TEST_UTIL.getConfiguration(); // The below config supported by 0.20-append and CDH3b2 @@ -148,29 +144,29 @@ public static void setUpBeforeClass() throws Exception { CommonFSUtils.setRootDir(conf, hbaseRootDir); } - @AfterClass + @AfterAll public static void tearDownAfterClass() throws Exception { TEST_UTIL.shutdownMiniCluster(); } - @Before - public void setUp() throws Exception { + @BeforeEach + public void setUp(TestInfo testInfo) throws Exception { + currentTest = testInfo.getTestMethod().get().getName(); this.conf = HBaseConfiguration.create(TEST_UTIL.getConfiguration()); this.fs = TEST_UTIL.getDFSCluster().getFileSystem(); this.hbaseRootDir = CommonFSUtils.getRootDir(this.conf); this.oldLogDir = new Path(this.hbaseRootDir, HConstants.HREGION_OLDLOGDIR_NAME); String serverName = ServerName - .valueOf(currentTest.getMethodName() + "-manual", 16010, EnvironmentEdgeManager.currentTime()) - .toString(); + .valueOf(currentTest + "-manual", 16010, EnvironmentEdgeManager.currentTime()).toString(); this.logName = AbstractFSWALProvider.getWALDirectoryName(serverName); this.logDir = new Path(this.hbaseRootDir, logName); if (TEST_UTIL.getDFSCluster().getFileSystem().exists(this.hbaseRootDir)) { TEST_UTIL.getDFSCluster().getFileSystem().delete(this.hbaseRootDir, true); } - this.wals = new WALFactory(conf, currentTest.getMethodName()); + this.wals = new WALFactory(conf, currentTest); } - @After + @AfterEach public void tearDown() throws Exception { this.wals.close(); TEST_UTIL.getDFSCluster().getFileSystem().delete(this.hbaseRootDir, true); @@ -217,8 +213,8 @@ public void testReplayEditsAfterRegionMovedWithMultiCF() throws Exception { // move region to another regionserver Region destRegion = regions.get(0); int originServerNum = hbaseCluster.getServerWith(destRegion.getRegionInfo().getRegionName()); - assertTrue("Please start more than 1 regionserver", - hbaseCluster.getRegionServerThreads().size() > 1); + assertTrue(hbaseCluster.getRegionServerThreads().size() > 1, + "Please start more than 1 regionserver"); int destServerNum = 0; while (destServerNum == originServerNum) { destServerNum++; @@ -257,8 +253,8 @@ public void testReplayEditsAfterRegionMovedWithMultiCF() throws Exception { // see what we get Result result = htable.get(new Get(Bytes.toBytes("r1"))); if (result != null) { - assertTrue("Row is deleted, but we get" + result.toString(), - (result == null) || result.isEmpty()); + assertTrue((result == null) || result.isEmpty(), + "Row is deleted, but we get" + result.toString()); } resultScanner.close(); } @@ -807,7 +803,7 @@ protected FlushResultImpl internalFlushcache(final WAL wal, final long myseqid, long writePoint = mvcc.getWritePoint(); // We flushed during init. - assertTrue("Flushcount=" + flushcount.get(), flushcount.get() > 0); + assertTrue(flushcount.get() > 0, "Flushcount=" + flushcount.get()); assertTrue((seqid - 1) == writePoint); Get get = new Get(rowName); @@ -826,7 +822,7 @@ protected FlushResultImpl internalFlushcache(final WAL wal, final long myseqid, @Test // the following test is for HBASE-6065 public void testSequentialEditLogSeqNum() throws IOException { - final TableName tableName = TableName.valueOf(currentTest.getMethodName()); + final TableName tableName = TableName.valueOf(currentTest); final RegionInfo hri = createBasic3FamilyHRegionInfo(tableName); final Path basedir = CommonFSUtils.getWALTableDir(conf, tableName); deleteDir(basedir); @@ -874,9 +870,8 @@ public boolean accept(Path p) { editCount = Integer.parseInt(fileStatus.getPath().getName()); } // The sequence number should be same - assertEquals( - "The sequence number of the recoverd.edits and the current edit seq should be same", - lastestSeqNumber, editCount); + assertEquals(lastestSeqNumber, editCount, + "The sequence number of the recoverd.edits and the current edit seq should be same"); } /** @@ -1163,7 +1158,7 @@ private Path runWALSplit(final Configuration c) throws IOException { List splits = WALSplitter.split(hbaseRootDir, logDir, oldLogDir, FileSystem.get(c), c, wals); // Split should generate only 1 file since there's only 1 region - assertEquals("splits=" + splits, 1, splits.size()); + assertEquals(1, splits.size(), "splits=" + splits); // Make sure the file exists assertTrue(fs.exists(splits.get(0))); LOG.info("Split file=" + splits.get(0)); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/ProtobufLogTestHelper.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/ProtobufLogTestHelper.java index a70f6242432a..27f05762622a 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/ProtobufLogTestHelper.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/ProtobufLogTestHelper.java @@ -17,12 +17,12 @@ */ package org.apache.hadoop.hbase.regionserver.wal; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThrows; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.EOFException; import java.io.IOException; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncFSWAL.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncFSWAL.java index b4e5d3402ae2..b41e23fc9f95 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncFSWAL.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncFSWAL.java @@ -17,7 +17,7 @@ */ package org.apache.hadoop.hbase.regionserver.wal; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -32,7 +32,6 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.TableName; @@ -58,11 +57,10 @@ import org.apache.hadoop.hbase.wal.WALKey; import org.apache.hadoop.hbase.wal.WALKeyImpl; import org.apache.hadoop.hbase.wal.WALProvider.AsyncWriter; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder; import org.apache.hbase.thirdparty.io.netty.channel.Channel; @@ -73,18 +71,15 @@ /** * Provides AsyncFSWAL test cases. */ -@Category({ RegionServerTests.class, LargeTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(LargeTests.TAG) public class TestAsyncFSWAL extends AbstractTestFSWAL { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestAsyncFSWAL.class); - private static EventLoopGroup GROUP; private static Class CHANNEL_CLASS; - @BeforeClass + @BeforeAll public static void setUpBeforeClass() throws Exception { GROUP = new NioEventLoopGroup(1, new ThreadFactoryBuilder().setNameFormat("TestAsyncFSWAL-pool-%d") @@ -93,7 +88,7 @@ public static void setUpBeforeClass() throws Exception { AbstractTestFSWAL.setUpBeforeClass(); } - @AfterClass + @AfterAll public static void tearDownAfterClass() throws Exception { AbstractTestFSWAL.tearDownAfterClass(); GROUP.shutdownGracefully(); @@ -142,7 +137,7 @@ public void testBrokenWriter() throws Exception { scopes.put(fam, 0); } long timestamp = EnvironmentEdgeManager.currentTime(); - String testName = currentTest.getMethodName(); + String testName = currentTest; AtomicInteger failedCount = new AtomicInteger(0); try (LogRoller roller = new LogRoller(services); AsyncFSWAL wal = new AsyncFSWAL(FS, null, CommonFSUtils.getWALRootDir(CONF), DIR.toString(), diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncFSWALDurability.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncFSWALDurability.java index cb48b903537a..1664716e6053 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncFSWALDurability.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncFSWALDurability.java @@ -22,37 +22,32 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.io.asyncfs.monitor.StreamSlowMonitor; -import org.apache.hadoop.hbase.regionserver.RegionServerServices; +import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.testclassification.SmallTests; import org.apache.hadoop.hbase.wal.WALProvider.AsyncWriter; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; import org.apache.hbase.thirdparty.io.netty.channel.Channel; import org.apache.hbase.thirdparty.io.netty.channel.EventLoopGroup; import org.apache.hbase.thirdparty.io.netty.channel.nio.NioEventLoopGroup; import org.apache.hbase.thirdparty.io.netty.channel.socket.nio.NioSocketChannel; -@Category({ RegionServerServices.class, SmallTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(SmallTests.TAG) public class TestAsyncFSWALDurability extends WALDurabilityTestBase { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestAsyncFSWALDurability.class); - private static NioEventLoopGroup GROUP; - @BeforeClass + @BeforeAll public static void setUpBeforeClass() { GROUP = new NioEventLoopGroup(); } - @AfterClass + @AfterAll public static void tearDownAfterClass() throws Exception { GROUP.shutdownGracefully().get(); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncFSWALRollStuck.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncFSWALRollStuck.java index b065b92e5d07..797848c05a27 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncFSWALRollStuck.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncFSWALRollStuck.java @@ -33,7 +33,6 @@ import org.apache.hadoop.hbase.Cell.Type; import org.apache.hadoop.hbase.CellBuilderType; import org.apache.hadoop.hbase.ExtendedCellBuilderFactory; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseTestingUtil; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.RegionInfo; @@ -49,11 +48,10 @@ import org.apache.hadoop.hbase.wal.WALEdit; import org.apache.hadoop.hbase.wal.WALEditInternalHelper; import org.apache.hadoop.hbase.wal.WALKeyImpl; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -67,13 +65,10 @@ /** * Testcase for HBASE-25905 */ -@Category({ RegionServerTests.class, MediumTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(MediumTests.TAG) public class TestAsyncFSWALRollStuck { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestAsyncFSWALRollStuck.class); - private static final Logger LOG = LoggerFactory.getLogger(TestAsyncFSWALRollStuck.class); private static final HBaseTestingUtil UTIL = new HBaseTestingUtil(); @@ -133,7 +128,7 @@ public CompletableFuture sync(boolean forceSync) { private static ExecutorService ROLL_EXEC; - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Configuration conf = UTIL.getConfiguration(); conf.setClass(AsyncFSWALProvider.WRITER_IMPL, TestAsyncWriter.class, AsyncWriter.class); @@ -171,7 +166,7 @@ public void logRollRequested(RollRequestReason reason) { WAL.init(); } - @AfterClass + @AfterAll public static void tearDown() throws Exception { EXECUTOR.shutdownNow(); ROLL_EXEC.shutdownNow(); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncLogRollPeriod.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncLogRollPeriod.java index 59771f4e25d9..99051539c4b4 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncLogRollPeriod.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncLogRollPeriod.java @@ -18,22 +18,17 @@ package org.apache.hadoop.hbase.regionserver.wal; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.testclassification.LargeTests; import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.wal.WALFactory; -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({ RegionServerTests.class, LargeTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(LargeTests.TAG) public class TestAsyncLogRollPeriod extends AbstractTestLogRollPeriod { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestAsyncLogRollPeriod.class); - - @BeforeClass + @BeforeAll public static void setUpBeforeClass() throws Exception { Configuration conf = AbstractTestLogRollPeriod.TEST_UTIL.getConfiguration(); conf.set(WALFactory.WAL_PROVIDER, "asyncfs"); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncLogRolling.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncLogRolling.java index 804e93eb8f56..b81c382c5216 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncLogRolling.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncLogRolling.java @@ -17,13 +17,12 @@ */ package org.apache.hadoop.hbase.regionserver.wal; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder; @@ -38,22 +37,18 @@ import org.apache.hadoop.hbase.wal.WALFactory; import org.apache.hadoop.hdfs.MiniDFSCluster.DataNodeProperties; import org.apache.hadoop.hdfs.protocol.DatanodeInfo; -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.Test; import org.apache.hbase.thirdparty.io.netty.channel.Channel; import org.apache.hbase.thirdparty.io.netty.channel.EventLoopGroup; -@Category({ VerySlowRegionServerTests.class, LargeTests.class }) +@Tag(VerySlowRegionServerTests.TAG) +@Tag(LargeTests.TAG) public class TestAsyncLogRolling extends AbstractTestLogRolling { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestAsyncLogRolling.class); - - @BeforeClass + @BeforeAll public static void setUpBeforeClass() throws Exception { Configuration conf = TestAsyncLogRolling.TEST_UTIL.getConfiguration(); conf.setInt(FanOutOneBlockAsyncDFSOutputHelper.ASYNC_DFS_OUTPUT_CREATE_MAX_RETRIES, 100); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncProtobufLog.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncProtobufLog.java index 9c06d9b4b8b4..1eee6a14ab41 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncProtobufLog.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncProtobufLog.java @@ -19,39 +19,35 @@ import java.io.IOException; import org.apache.hadoop.fs.Path; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.testclassification.SmallTests; import org.apache.hadoop.hbase.wal.AsyncFSWALProvider; import org.apache.hadoop.hbase.wal.WALProvider.Writer; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; import org.apache.hbase.thirdparty.io.netty.channel.Channel; import org.apache.hbase.thirdparty.io.netty.channel.EventLoopGroup; import org.apache.hbase.thirdparty.io.netty.channel.nio.NioEventLoopGroup; import org.apache.hbase.thirdparty.io.netty.channel.socket.nio.NioSocketChannel; -@Category({ RegionServerTests.class, SmallTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(SmallTests.TAG) public class TestAsyncProtobufLog extends AbstractTestProtobufLog { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestAsyncProtobufLog.class); private static EventLoopGroup EVENT_LOOP_GROUP; private static Class CHANNEL_CLASS; - @BeforeClass + @BeforeAll public static void setUpBeforeClass() throws Exception { EVENT_LOOP_GROUP = new NioEventLoopGroup(); CHANNEL_CLASS = NioSocketChannel.class; AbstractTestProtobufLog.setUpBeforeClass(); } - @AfterClass + @AfterAll public static void tearDownAfterClass() throws Exception { AbstractTestProtobufLog.tearDownAfterClass(); EVENT_LOOP_GROUP.shutdownGracefully().syncUninterruptibly(); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncWALReplay.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncWALReplay.java index 5a1816859cd5..e48dc4f63b55 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncWALReplay.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncWALReplay.java @@ -21,7 +21,6 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.io.asyncfs.monitor.StreamSlowMonitor; import org.apache.hadoop.hbase.testclassification.MediumTests; @@ -29,10 +28,10 @@ import org.apache.hadoop.hbase.util.Threads; import org.apache.hadoop.hbase.wal.WAL; import org.apache.hadoop.hbase.wal.WALFactory; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.TestInfo; import org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder; import org.apache.hbase.thirdparty.io.netty.channel.Channel; @@ -40,18 +39,21 @@ import org.apache.hbase.thirdparty.io.netty.channel.nio.NioEventLoopGroup; import org.apache.hbase.thirdparty.io.netty.channel.socket.nio.NioSocketChannel; -@Category({ RegionServerTests.class, MediumTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(MediumTests.TAG) public class TestAsyncWALReplay extends AbstractTestWALReplay { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestAsyncWALReplay.class); - private static EventLoopGroup GROUP; private static Class CHANNEL_CLASS; - @BeforeClass + @BeforeAll + public static void setUpBeforeClass(TestInfo testInfo) throws Exception { + if (testInfo.getTestClass().get() == TestAsyncWALReplay.class) { + setUpBeforeClass(); + } + } + public static void setUpBeforeClass() throws Exception { GROUP = new NioEventLoopGroup(1, new ThreadFactoryBuilder().setNameFormat("TestAsyncWALReplay-pool-%d").setDaemon(true) @@ -62,7 +64,7 @@ public static void setUpBeforeClass() throws Exception { AbstractTestWALReplay.setUpBeforeClass(); } - @AfterClass + @AfterAll public static void tearDownAfterClass() throws Exception { AbstractTestWALReplay.tearDownAfterClass(); GROUP.shutdownGracefully(); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncWALReplayCompressed.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncWALReplayCompressed.java index a8edb823f16f..2ac667da588d 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncWALReplayCompressed.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncWALReplayCompressed.java @@ -18,22 +18,17 @@ package org.apache.hadoop.hbase.regionserver.wal; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.testclassification.RegionServerTests; -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({ RegionServerTests.class, MediumTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(MediumTests.TAG) public class TestAsyncWALReplayCompressed extends TestAsyncWALReplay { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestAsyncWALReplayCompressed.class); - - @BeforeClass + @BeforeAll public static void setUpBeforeClass() throws Exception { Configuration conf = AbstractTestWALReplay.TEST_UTIL.getConfiguration(); conf.setBoolean(HConstants.ENABLE_WAL_COMPRESSION, true); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncWALReplayValueCompression.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncWALReplayValueCompression.java index 592af9cf1440..a31e08ffa86e 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncWALReplayValueCompression.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncWALReplayValueCompression.java @@ -18,22 +18,17 @@ package org.apache.hadoop.hbase.regionserver.wal; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.testclassification.RegionServerTests; -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({ RegionServerTests.class, MediumTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(MediumTests.TAG) public class TestAsyncWALReplayValueCompression extends TestAsyncWALReplay { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestAsyncWALReplayValueCompression.class); - - @BeforeClass + @BeforeAll public static void setUpBeforeClass() throws Exception { Configuration conf = AbstractTestWALReplay.TEST_UTIL.getConfiguration(); conf.setBoolean(HConstants.ENABLE_WAL_COMPRESSION, true); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestCombinedAsyncWriter.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestCombinedAsyncWriter.java index db1d7cf595d7..c358f88c15a9 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestCombinedAsyncWriter.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestCombinedAsyncWriter.java @@ -21,7 +21,6 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseTestingUtil; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.testclassification.MediumTests; @@ -31,26 +30,22 @@ import org.apache.hadoop.hbase.wal.AsyncFSWALProvider; import org.apache.hadoop.hbase.wal.AsyncFSWALProvider.AsyncWriter; import org.apache.hadoop.hbase.wal.WALFactory; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.rules.TestName; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +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.apache.hbase.thirdparty.io.netty.channel.Channel; import org.apache.hbase.thirdparty.io.netty.channel.EventLoopGroup; import org.apache.hbase.thirdparty.io.netty.channel.nio.NioEventLoopGroup; import org.apache.hbase.thirdparty.io.netty.channel.socket.nio.NioSocketChannel; -@Category({ RegionServerTests.class, MediumTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(MediumTests.TAG) public class TestCombinedAsyncWriter { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestCombinedAsyncWriter.class); - private static final HBaseTestingUtil UTIL = new HBaseTestingUtil(); private static EventLoopGroup EVENT_LOOP_GROUP; @@ -59,10 +54,14 @@ public class TestCombinedAsyncWriter { private static WALFactory WALS; - @Rule - public final TestName name = new TestName(); + private String name; + + @BeforeEach + public void initTestName(TestInfo testInfo) { + name = testInfo.getTestMethod().get().getName(); + } - @BeforeClass + @BeforeAll public static void setUpBeforeClass() throws Exception { EVENT_LOOP_GROUP = new NioEventLoopGroup(); CHANNEL_CLASS = NioSocketChannel.class; @@ -71,7 +70,7 @@ public static void setUpBeforeClass() throws Exception { WALS = new WALFactory(UTIL.getConfiguration(), TestCombinedAsyncWriter.class.getSimpleName()); } - @AfterClass + @AfterAll public static void tearDownAfterClass() throws Exception { if (WALS != null) { WALS.close(); @@ -91,7 +90,7 @@ public void testWithoutTrailer() throws IOException { } private Path getPath(int index) throws IOException { - String methodName = name.getMethodName().replaceAll("[^A-Za-z0-9_-]", "_"); + String methodName = name.replaceAll("[^A-Za-z0-9_-]", "_"); return new Path(UTIL.getDataTestDirOnTestFS(), methodName + "-" + index); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestCompressor.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestCompressor.java index 12cb0270ddb4..839a1ed398d1 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestCompressor.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestCompressor.java @@ -17,36 +17,32 @@ */ package org.apache.hadoop.hbase.regionserver.wal; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.io.util.Dictionary; import org.apache.hadoop.hbase.io.util.LRUDictionary; import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.testclassification.SmallTests; import org.apache.hadoop.hbase.util.Bytes; -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.Test; /** * Test our compressor class. */ -@Category({ RegionServerTests.class, SmallTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(SmallTests.TAG) public class TestCompressor { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestCompressor.class); - - @BeforeClass + @BeforeAll public static void setUpBeforeClass() throws Exception { } @@ -58,9 +54,11 @@ public void testToShort() { assertEquals(s, Compressor.toShort((byte) 1, (byte) 0)); } - @Test(expected = IllegalArgumentException.class) + @Test public void testNegativeToShort() { - Compressor.toShort((byte) 0xff, (byte) 0xff); + assertThrows(IllegalArgumentException.class, () -> { + Compressor.toShort((byte) 0xff, (byte) 0xff); + }); } @Test diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestCustomWALCellCodec.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestCustomWALCellCodec.java index f60695aeedbd..49c8354998f2 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestCustomWALCellCodec.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestCustomWALCellCodec.java @@ -17,26 +17,22 @@ */ package org.apache.hadoop.hbase.regionserver.wal; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.testclassification.SmallTests; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; /** * Test that we can create, load, setup our own custom codec */ -@Category({ RegionServerTests.class, SmallTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(SmallTests.TAG) public class TestCustomWALCellCodec { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestCustomWALCellCodec.class); - public static class CustomWALCellCodec extends WALCellCodec { public Configuration conf; public CompressionContext context; @@ -59,19 +55,21 @@ public void testCreatePreparesCodec() throws Exception { conf.setClass(WALCellCodec.WAL_CELL_CODEC_CLASS_KEY, CustomWALCellCodec.class, WALCellCodec.class); CustomWALCellCodec codec = (CustomWALCellCodec) WALCellCodec.create(conf, null, null); - assertEquals("Custom codec didn't get initialized with the right configuration!", conf, - codec.conf); - assertEquals("Custom codec didn't get initialized with the right compression context!", null, - codec.context); + assertEquals(conf, codec.conf, + "Custom codec didn't get initialized with the right configuration!"); + assertEquals(null, codec.context, + "Custom codec didn't get initialized with the right compression context!"); } /** * Test that a custom {@link WALCellCodec} will fail if provided an invalid code class. */ - @Test(expected = RuntimeException.class) + @Test public void testCreatePreparesCodecInvalidClass() throws Exception { - Configuration conf = new Configuration(false); - conf.setStrings(WALCellCodec.WAL_CELL_CODEC_CLASS_KEY, "org.apache.hbase.wal.NoSuchClass"); - WALCellCodec.create(conf, null, null); + assertThrows(RuntimeException.class, () -> { + Configuration conf = new Configuration(false); + conf.setStrings(WALCellCodec.WAL_CELL_CODEC_CLASS_KEY, "org.apache.hbase.wal.NoSuchClass"); + WALCellCodec.create(conf, null, null); + }); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestDurability.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestDurability.java index 750fabd1a91d..81d8cbd0be15 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestDurability.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestDurability.java @@ -17,15 +17,15 @@ */ package org.apache.hadoop.hbase.regionserver.wal; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; -import java.util.Arrays; +import java.util.stream.Stream; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; -import org.apache.hadoop.hbase.HBaseClassTestRule; +import org.apache.hadoop.hbase.HBaseParameterizedTestTemplate; import org.apache.hadoop.hbase.HBaseTestingUtil; import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.TableName; @@ -51,31 +51,23 @@ import org.apache.hadoop.hbase.wal.WAL; import org.apache.hadoop.hbase.wal.WALFactory; import org.apache.hadoop.hdfs.MiniDFSCluster; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.rules.TestName; -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.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.TestTemplate; +import org.junit.jupiter.params.provider.Arguments; /** * Tests for WAL write durability */ -@RunWith(Parameterized.class) -@Category({ RegionServerTests.class, MediumTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(MediumTests.TAG) +@HBaseParameterizedTestTemplate(name = "{index}: provider={0}") public class TestDurability { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestDurability.class); - private static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil(); private static FileSystem FS; private static MiniDFSCluster CLUSTER; @@ -86,18 +78,19 @@ public class TestDurability { private static byte[] ROW = Bytes.toBytes("row"); private static byte[] COL = Bytes.toBytes("col"); - @Parameter - public String walProvider; + private final String walProvider; + + private String name; - @Rule - public TestName name = new TestName(); + public static Stream parameters() { + return Stream.of(Arguments.of("defaultProvider"), Arguments.of("asyncfs")); + } - @Parameters(name = "{index}: provider={0}") - public static Iterable data() { - return Arrays.asList(new Object[] { "defaultProvider" }, new Object[] { "asyncfs" }); + public TestDurability(String walProvider) { + this.walProvider = walProvider; } - @BeforeClass + @BeforeAll public static void setUpBeforeClass() throws Exception { CONF = TEST_UTIL.getConfiguration(); TEST_UTIL.startMiniDFSCluster(1); @@ -108,22 +101,23 @@ public static void setUpBeforeClass() throws Exception { CommonFSUtils.setRootDir(CONF, DIR); } - @AfterClass + @AfterAll public static void tearDownAfterClass() throws Exception { TEST_UTIL.shutdownMiniCluster(); } - @Before - public void setUp() { + @BeforeEach + public void setUp(TestInfo testInfo) { + name = testInfo.getTestMethod().get().getName(); CONF.set(WALFactory.WAL_PROVIDER, walProvider); } - @After + @AfterEach public void tearDown() throws IOException { FS.delete(DIR, true); } - @Test + @TestTemplate public void testDurability() throws Exception { WALFactory wals = new WALFactory(CONF, ServerName.valueOf("TestDurability", 16010, EnvironmentEdgeManager.currentTime()).toString()); @@ -181,7 +175,7 @@ public void testDurability() throws Exception { verifyWALCount(wals, wal, 12); } - @Test + @TestTemplate public void testIncrement() throws Exception { byte[] row1 = Bytes.toBytes("row1"); byte[] col1 = Bytes.toBytes("col1"); @@ -248,7 +242,7 @@ public void testIncrement() throws Exception { * Test when returnResults set to false in increment it should not return the result instead it * resturn null. */ - @Test + @TestTemplate public void testIncrementWithReturnResultsSetToFalse() throws Exception { byte[] row1 = Bytes.toBytes("row1"); byte[] col1 = Bytes.toBytes("col1"); @@ -282,7 +276,7 @@ private void verifyWALCount(WALFactory wals, WAL log, int expected) throws Excep // lifted from TestAtomicOperation private HRegion createHRegion(WALFactory wals, Durability durability) throws IOException { - TableName tableName = TableName.valueOf(name.getMethodName().replaceAll("[^A-Za-z0-9-_]", "_")); + TableName tableName = TableName.valueOf(name.replaceAll("[^A-Za-z0-9-_]", "_")); TableDescriptor htd = TableDescriptorBuilder.newBuilder(tableName) .setColumnFamily(ColumnFamilyDescriptorBuilder.of(FAMILY)).build(); RegionInfo info = RegionInfoBuilder.newBuilder(tableName).build(); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestFSHLog.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestFSHLog.java index d99b3d958cdb..9c927e43e0d2 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestFSHLog.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestFSHLog.java @@ -17,7 +17,7 @@ */ package org.apache.hadoop.hbase.regionserver.wal; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; import java.lang.reflect.Field; @@ -31,7 +31,6 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder; @@ -51,25 +50,26 @@ import org.apache.hadoop.hbase.util.Threads; import org.apache.hadoop.hbase.wal.WALEdit; import org.apache.hadoop.hbase.wal.WALKey; -import org.junit.ClassRule; -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.rules.TestName; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; /** * Provides FSHLog test cases. */ -@Category({ RegionServerTests.class, MediumTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(MediumTests.TAG) public class TestFSHLog extends AbstractTestFSWAL { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = HBaseClassTestRule.forClass(TestFSHLog.class); - private static final long TEST_TIMEOUT_MS = 10000; - @Rule - public TestName name = new TestName(); + private String name; + + @BeforeEach + public void initTestName(TestInfo testInfo) { + name = testInfo.getTestMethod().get().getName(); + } @Override protected AbstractFSWAL newWAL(FileSystem fs, Path rootDir, String walDir, String archiveDir, @@ -102,7 +102,7 @@ protected void atHeadOfRingBufferEventHandlerAppend() { @Test public void testSyncRunnerIndexOverflow() throws IOException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { - final String name = this.name.getMethodName(); + final String name = this.name; FS.mkdirs(new Path(CommonFSUtils.getRootDir(CONF), name)); FSHLog log = new FSHLog(FS, CommonFSUtils.getRootDir(CONF), name, HConstants.HREGION_OLDLOGDIR_NAME, CONF, null, true, null, null); @@ -111,9 +111,8 @@ public void testSyncRunnerIndexOverflow() throws IOException, NoSuchFieldExcepti Field syncRunnerIndexField = FSHLog.class.getDeclaredField("syncRunnerIndex"); syncRunnerIndexField.setAccessible(true); syncRunnerIndexField.set(log, Integer.MAX_VALUE - 1); - TableDescriptor htd = - TableDescriptorBuilder.newBuilder(TableName.valueOf(this.name.getMethodName())) - .setColumnFamily(ColumnFamilyDescriptorBuilder.of("row")).build(); + TableDescriptor htd = TableDescriptorBuilder.newBuilder(TableName.valueOf(this.name)) + .setColumnFamily(ColumnFamilyDescriptorBuilder.of("row")).build(); NavigableMap scopes = new TreeMap<>(Bytes.BYTES_COMPARATOR); for (byte[] fam : htd.getColumnFamilyNames()) { scopes.put(fam, 0); @@ -133,7 +132,7 @@ public void testSyncRunnerIndexOverflow() throws IOException, NoSuchFieldExcepti */ @Test public void testUnflushedSeqIdTracking() throws IOException, InterruptedException { - final String name = this.name.getMethodName(); + final String name = this.name; final byte[] b = Bytes.toBytes("b"); final AtomicBoolean startHoldingForAppend = new AtomicBoolean(false); @@ -159,9 +158,8 @@ public void visitLogEntryBeforeWrite(RegionInfo info, WALKey logKey, WALEdit log }); // open a new region which uses this WAL - TableDescriptor htd = - TableDescriptorBuilder.newBuilder(TableName.valueOf(this.name.getMethodName())) - .setColumnFamily(ColumnFamilyDescriptorBuilder.of(b)).build(); + TableDescriptor htd = TableDescriptorBuilder.newBuilder(TableName.valueOf(this.name)) + .setColumnFamily(ColumnFamilyDescriptorBuilder.of(b)).build(); RegionInfo hri = RegionInfoBuilder.newBuilder(htd.getTableName()).build(); ChunkCreator.initialize(MemStoreLAB.CHUNK_SIZE_DEFAULT, false, 0, 0, 0, null, MemStoreLAB.INDEX_CHUNK_SIZE_PERCENTAGE_DEFAULT); @@ -211,12 +209,12 @@ public void run() { flushFinished.await(); // check whether flush went through - assertEquals("Region did not flush?", 1, region.getStoreFileList(new byte[][] { b }).size()); + assertEquals(1, region.getStoreFileList(new byte[][] { b }).size(), "Region did not flush?"); // now check the region's unflushed seqIds. long seqId = AbstractTestFSWAL.getEarliestMemStoreSeqNum(log, hri.getEncodedNameAsBytes()); - assertEquals("Found seqId for the region which is already flushed", HConstants.NO_SEQNUM, - seqId); + assertEquals(HConstants.NO_SEQNUM, seqId, + "Found seqId for the region which is already flushed"); region.close(); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestFSHLogDurability.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestFSHLogDurability.java index d6ca9a1ab235..3d92125c53c5 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestFSHLogDurability.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestFSHLogDurability.java @@ -21,20 +21,15 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; -import org.apache.hadoop.hbase.HBaseClassTestRule; -import org.apache.hadoop.hbase.regionserver.RegionServerServices; import org.apache.hadoop.hbase.testclassification.MediumTests; +import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.wal.WALProvider.Writer; -import org.junit.ClassRule; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Tag; -@Category({ RegionServerServices.class, MediumTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(MediumTests.TAG) public class TestFSHLogDurability extends WALDurabilityTestBase { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestFSHLogDurability.class); - @Override protected CustomFSHLog getWAL0(FileSystem fs, Path root, String logDir, Configuration conf) throws IOException { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestFSWALEntry.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestFSWALEntry.java index 1a0ecdfc55d7..00201f6175c9 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestFSWALEntry.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestFSWALEntry.java @@ -17,31 +17,26 @@ */ package org.apache.hadoop.hbase.regionserver.wal; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.ArrayList; import java.util.List; import org.apache.hadoop.hbase.CellBuilderType; import org.apache.hadoop.hbase.ExtendedCell; import org.apache.hadoop.hbase.ExtendedCellBuilderFactory; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.testclassification.SmallTests; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.wal.WALEdit; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category({ RegionServerTests.class, SmallTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(SmallTests.TAG) public class TestFSWALEntry { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestFSWALEntry.class); - @Test public void testCollectFamilies() { byte[] family0 = Bytes.toBytes("family0"); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHBaseWalOnEC.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHBaseWalOnEC.java index 4c3e5859dab6..e6c307212ed7 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHBaseWalOnEC.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHBaseWalOnEC.java @@ -17,16 +17,15 @@ */ package org.apache.hadoop.hbase.regionserver.wal; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import java.io.IOException; -import java.util.Arrays; -import java.util.List; +import java.util.stream.Stream; import org.apache.hadoop.fs.FSDataOutputStream; import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.StreamCapabilities; -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.client.Get; @@ -41,28 +40,21 @@ import org.apache.hadoop.hdfs.DistributedFileSystem; import org.apache.hadoop.hdfs.MiniDFSCluster; import org.apache.hadoop.hdfs.client.HdfsAdmin; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -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; - -@RunWith(Parameterized.class) -@Category({ RegionServerTests.class, LargeTests.class }) +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.TestTemplate; +import org.junit.jupiter.params.provider.Arguments; + +@Tag(RegionServerTests.TAG) +@Tag(LargeTests.TAG) +@HBaseParameterizedTestTemplate public class TestHBaseWalOnEC { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestHBaseWalOnEC.class); - private static final HBaseTestingUtil UTIL = new HBaseTestingUtil(); - @BeforeClass + @BeforeAll public static void setUpBeforeClass() throws Exception { MiniDFSCluster cluster = UTIL.startMiniDFSCluster(3); // Need 3 DNs for RS-3-2 policy DistributedFileSystem fs = cluster.getFileSystem(); @@ -75,33 +67,35 @@ public static void setUpBeforeClass() throws Exception { try (FSDataOutputStream out = fs.create(new Path("/canary"))) { // If this comes back as having hflush then some test setup assumption is wrong. // Fail the test so that a developer has to look and triage - assertFalse("Did not enable EC!", out.hasCapability(StreamCapabilities.HFLUSH)); + assertFalse(out.hasCapability(StreamCapabilities.HFLUSH), "Did not enable EC!"); } UTIL.getConfiguration().setBoolean(CommonFSUtils.UNSAFE_STREAM_CAPABILITY_ENFORCE, true); } - @Parameter - public String walProvider; + private final String walProvider; + + public static Stream parameters() { + return Stream.of(Arguments.of("asyncfs"), Arguments.of("filesystem")); + } - @Parameters - public static List params() { - return Arrays.asList(new Object[] { "asyncfs" }, new Object[] { "filesystem" }); + public TestHBaseWalOnEC(String walProvider) { + this.walProvider = walProvider; } - @Before + @BeforeEach public void setUp() throws Exception { UTIL.getConfiguration().set(WALFactory.WAL_PROVIDER, walProvider); UTIL.startMiniCluster(3); } - @After + @AfterEach public void tearDown() throws Exception { UTIL.shutdownMiniCluster(); } - @Test + @TestTemplate public void testReadWrite() throws IOException { byte[] row = Bytes.toBytes("row"); byte[] cf = Bytes.toBytes("cf"); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestLogRollAbort.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestLogRollAbort.java index 11bb4479d106..9fdb1466cf5d 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestLogRollAbort.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestLogRollAbort.java @@ -17,19 +17,18 @@ */ package org.apache.hadoop.hbase.regionserver.wal; -import static org.junit.Assert.assertThrows; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.FileNotFoundException; import java.io.IOException; -import java.util.Arrays; -import java.util.List; import java.util.NavigableMap; import java.util.TreeMap; +import java.util.stream.Stream; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; -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.KeyValue; @@ -62,16 +61,12 @@ import org.apache.hadoop.hbase.wal.WALSplitter; import org.apache.hadoop.hdfs.MiniDFSCluster; import org.apache.hadoop.ipc.RemoteException; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -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.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.TestTemplate; +import org.junit.jupiter.params.provider.Arguments; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -80,14 +75,11 @@ /** * Tests for conditions that should trigger RegionServer aborts when rolling the current WAL fails. */ -@RunWith(Parameterized.class) -@Category({ RegionServerTests.class, MediumTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(MediumTests.TAG) +@HBaseParameterizedTestTemplate(name = "{index}: walProvider={0}") public class TestLogRollAbort { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestLogRollAbort.class); - private static final Logger LOG = LoggerFactory.getLogger(TestLogRollAbort.class); private static MiniDFSCluster dfsCluster; private static Admin admin; @@ -101,7 +93,7 @@ public class TestLogRollAbort { // Need to override this setup so we can edit the config before it gets sent // to the HDFS & HBase cluster startup. - @BeforeClass + @BeforeAll public static void setUpBeforeClass() throws Exception { // Tweak default timeout values down for faster recovery TEST_UTIL.getConfiguration().setInt("hbase.regionserver.logroll.errors.tolerated", 2); @@ -120,18 +112,20 @@ public static void setUpBeforeClass() throws Exception { TEST_UTIL.getConfiguration().set(WALFactory.WAL_PROVIDER, "asyncfs"); } - @Parameters(name = "{index}: walProvider={0}") - public static List params() { - return Arrays.asList(new Object[] { "filesystem" }, new Object[] { "asyncfs" }); + public static Stream parameters() { + return Stream.of(Arguments.of("filesystem"), Arguments.of("asyncfs")); } private Configuration conf; private FileSystem fs; - @Parameter - public String walProvider; + private final String walProvider; + + public TestLogRollAbort(String walProvider) { + this.walProvider = walProvider; + } - @Before + @BeforeEach public void setUp() throws Exception { TEST_UTIL.getConfiguration().set(WALFactory.WAL_PROVIDER, walProvider); TEST_UTIL.startMiniCluster(2); @@ -148,7 +142,7 @@ public void setUp() throws Exception { CommonFSUtils.setWALRootDir(conf, HBASELOGDIR); } - @After + @AfterEach public void tearDown() throws Exception { TEST_UTIL.shutdownMiniCluster(); } @@ -157,7 +151,7 @@ public void tearDown() throws Exception { * Tests that RegionServer aborts if we hit an error closing the WAL when there are unsynced WAL * edits. See HBASE-4282. */ - @Test + @TestTemplate public void testRSAbortWithUnflushedEdits() throws Exception { LOG.info("Starting testRSAbortWithUnflushedEdits()"); @@ -207,7 +201,7 @@ public void testRSAbortWithUnflushedEdits() throws Exception { * declared it dead and started to split. Want log rolling after a master split to fail. See * HBASE-2312. */ - @Test + @TestTemplate public void testLogRollAfterSplitStart() throws IOException { LOG.info("Verify wal roll after split starts will fail."); String logName = @@ -254,9 +248,9 @@ public void testLogRollAfterSplitStart() throws IOException { if (error instanceof RemoteException) { error = ((RemoteException) error).unwrapRemoteException(); } - assertTrue("unexpected error: " + Throwables.getStackTraceAsString(error), - error instanceof FileNotFoundException - || error.getCause() instanceof FileNotFoundException); + assertTrue( + error instanceof FileNotFoundException || error.getCause() instanceof FileNotFoundException, + "unexpected error: " + Throwables.getStackTraceAsString(error)); } finally { wals.close(); if (fs.exists(thisTestsDir)) { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestLogRollPeriod.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestLogRollPeriod.java index 392bf9ab64f1..6f2afe61b0b2 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestLogRollPeriod.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestLogRollPeriod.java @@ -18,22 +18,17 @@ package org.apache.hadoop.hbase.regionserver.wal; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.testclassification.LargeTests; import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.wal.WALFactory; -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({ RegionServerTests.class, LargeTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(LargeTests.TAG) public class TestLogRollPeriod extends AbstractTestLogRollPeriod { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestLogRollPeriod.class); - - @BeforeClass + @BeforeAll public static void setUpBeforeClass() throws Exception { Configuration conf = AbstractTestLogRollPeriod.TEST_UTIL.getConfiguration(); conf.set(WALFactory.WAL_PROVIDER, "filesystem"); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestLogRolling.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestLogRolling.java index 43477f21f7f8..8ab1725e5648 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestLogRolling.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestLogRolling.java @@ -17,10 +17,10 @@ */ package org.apache.hadoop.hbase.regionserver.wal; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.EOFException; import java.io.IOException; @@ -33,7 +33,6 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.Cell; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder; @@ -61,23 +60,19 @@ import org.apache.hadoop.hbase.wal.WALStreamReader; import org.apache.hadoop.hdfs.protocol.DatanodeInfo; import org.apache.hadoop.hdfs.server.datanode.DataNode; -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.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -@Category({ VerySlowRegionServerTests.class, LargeTests.class }) +@Tag(VerySlowRegionServerTests.TAG) +@Tag(LargeTests.TAG) public class TestLogRolling extends AbstractTestLogRolling { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestLogRolling.class); - private static final Logger LOG = LoggerFactory.getLogger(TestLogRolling.class); - @BeforeClass + @BeforeAll public static void setUpBeforeClass() throws Exception { // TODO: testLogRollOnDatanodeDeath fails if short circuit reads are on under the hadoop2 // profile. See HBASE-9337 for related issues. @@ -202,8 +197,8 @@ public void testLogRollOnDatanodeDeath() throws Exception { this.setUp(); TEST_UTIL.ensureSomeRegionServersAvailable(2); - assertTrue("This test requires WAL file replication set to 2.", - fs.getDefaultReplication(TEST_UTIL.getDataTestDirOnTestFS()) == 2); + assertTrue(fs.getDefaultReplication(TEST_UTIL.getDataTestDirOnTestFS()) == 2, + "This test requires WAL file replication set to 2."); LOG.info("Replication=" + fs.getDefaultReplication(TEST_UTIL.getDataTestDirOnTestFS())); this.server = cluster.getRegionServer(0); @@ -250,21 +245,21 @@ public void logRollRequested(WALActionsListener.RollRequestReason reason) { } assertTrue( - "DataNodes " + dfsCluster.getDataNodes().size() + " default replication " - + fs.getDefaultReplication(TEST_UTIL.getDataTestDirOnTestFS()), dfsCluster.getDataNodes().size() - >= fs.getDefaultReplication(TEST_UTIL.getDataTestDirOnTestFS()) + 1); + >= fs.getDefaultReplication(TEST_UTIL.getDataTestDirOnTestFS()) + 1, + "DataNodes " + dfsCluster.getDataNodes().size() + " default replication " + + fs.getDefaultReplication(TEST_UTIL.getDataTestDirOnTestFS())); writeData(table, 2); long curTime = EnvironmentEdgeManager.currentTime(); LOG.info("log.getCurrentFileName(): " + log.getCurrentFileName()); long oldFilenum = AbstractFSWALProvider.extractFileNumFromWAL(log); - assertTrue("Log should have a timestamp older than now", - curTime > oldFilenum && oldFilenum != -1); + assertTrue(curTime > oldFilenum && oldFilenum != -1, + "Log should have a timestamp older than now"); - assertTrue("The log shouldn't have rolled yet", - oldFilenum == AbstractFSWALProvider.extractFileNumFromWAL(log)); + assertTrue(oldFilenum == AbstractFSWALProvider.extractFileNumFromWAL(log), + "The log shouldn't have rolled yet"); final DatanodeInfo[] pipeline = log.getPipeline(); assertTrue(pipeline.length == fs.getDefaultReplication(TEST_UTIL.getDataTestDirOnTestFS())); @@ -284,17 +279,16 @@ public void logRollRequested(WALActionsListener.RollRequestReason reason) { // write some more log data (this should use a new hdfs_out) writeData(table, 3); - assertTrue("The log should not roll again.", - AbstractFSWALProvider.extractFileNumFromWAL(log) == newFilenum); + assertTrue(AbstractFSWALProvider.extractFileNumFromWAL(log) == newFilenum, + "The log should not roll again."); // kill another datanode in the pipeline, so the replicas will be lower than // the configured value 2. assertTrue(dfsCluster.stopDataNode(pipeline[1].getName()) != null); batchWriteAndWait(table, log, 3, false, 14000); int replication = log.getLogReplication(); - assertTrue( - "LowReplication Roller should've been disabled, current replication=" + replication, - !log.isLowReplicationRollEnabled()); + assertTrue(!log.isLowReplicationRollEnabled(), + "LowReplication Roller should've been disabled, current replication=" + replication); dfsCluster.startDataNodes(TEST_UTIL.getConfiguration(), 1, true, null, null); @@ -303,9 +297,9 @@ public void logRollRequested(WALActionsListener.RollRequestReason reason) { log.rollWriter(true); batchWriteAndWait(table, log, 13, true, 10000); replication = log.getLogReplication(); - assertTrue("New log file should have the default replication instead of " + replication, - replication == fs.getDefaultReplication(TEST_UTIL.getDataTestDirOnTestFS())); - assertTrue("LowReplication Roller should've been enabled", log.isLowReplicationRollEnabled()); + assertTrue(replication == fs.getDefaultReplication(TEST_UTIL.getDataTestDirOnTestFS()), + "New log file should have the default replication instead of " + replication); + assertTrue(log.isLowReplicationRollEnabled(), "LowReplication Roller should've been enabled"); } finally { TEST_UTIL.getConfiguration().setLong("hbase.regionserver.hlog.check.lowreplication.interval", oldValue); @@ -318,8 +312,8 @@ public void logRollRequested(WALActionsListener.RollRequestReason reason) { @Test public void testLogRollOnPipelineRestart() throws Exception { LOG.info("Starting testLogRollOnPipelineRestart"); - assertTrue("This test requires WAL file replication.", - fs.getDefaultReplication(TEST_UTIL.getDataTestDirOnTestFS()) > 1); + assertTrue(fs.getDefaultReplication(TEST_UTIL.getDataTestDirOnTestFS()) > 1, + "This test requires WAL file replication."); LOG.info("Replication=" + fs.getDefaultReplication(TEST_UTIL.getDataTestDirOnTestFS())); // When the hbase:meta table can be opened, the region servers are running Table t = TEST_UTIL.getConnection().getTable(TableName.META_TABLE_NAME); @@ -359,11 +353,11 @@ public void postLogRoll(Path oldFile, Path newFile) { long curTime = EnvironmentEdgeManager.currentTime(); LOG.info("log.getCurrentFileName()): " + AbstractFSWALProvider.getCurrentFileName(log)); long oldFilenum = AbstractFSWALProvider.extractFileNumFromWAL(log); - assertTrue("Log should have a timestamp older than now", - curTime > oldFilenum && oldFilenum != -1); + assertTrue(curTime > oldFilenum && oldFilenum != -1, + "Log should have a timestamp older than now"); - assertTrue("The log shouldn't have rolled yet", - oldFilenum == AbstractFSWALProvider.extractFileNumFromWAL(log)); + assertTrue(oldFilenum == AbstractFSWALProvider.extractFileNumFromWAL(log), + "The log shouldn't have rolled yet"); // roll all datanodes in the pipeline dfsCluster.restartDataNodes(); @@ -376,8 +370,8 @@ public void postLogRoll(Path oldFile, Path newFile) { writeData(table, 1003); long newFilenum = AbstractFSWALProvider.extractFileNumFromWAL(log); - assertTrue("Missing datanode should've triggered a log roll", - newFilenum > oldFilenum && newFilenum > curTime); + assertTrue(newFilenum > oldFilenum && newFilenum > curTime, + "Missing datanode should've triggered a log roll"); validateData(table, 1003); writeData(table, 1004); @@ -394,8 +388,8 @@ public void postLogRoll(Path oldFile, Path newFile) { // force a log roll to read back and verify previously written logs log.rollWriter(true); - assertTrue("preLogRolledCalled has size of " + preLogRolledCalled.size(), - preLogRolledCalled.size() >= 1); + assertTrue(preLogRolledCalled.size() >= 1, + "preLogRolledCalled has size of " + preLogRolledCalled.size()); // read back the data written Set loggedRows = new HashSet<>(); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestLogRollingNoCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestLogRollingNoCluster.java index dd4fe77c8a38..31d28a63abcc 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestLogRollingNoCluster.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestLogRollingNoCluster.java @@ -17,7 +17,7 @@ */ package org.apache.hadoop.hbase.regionserver.wal; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertFalse; import java.io.IOException; import java.util.NavigableMap; @@ -25,7 +25,6 @@ import java.util.concurrent.ThreadLocalRandom; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseTestingUtil; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.KeyValue; @@ -48,22 +47,18 @@ import org.apache.hadoop.hbase.wal.WALEditInternalHelper; import org.apache.hadoop.hbase.wal.WALFactory; import org.apache.hadoop.hbase.wal.WALKeyImpl; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * Test many concurrent appenders to an WAL while rolling the log. */ -@Category({ RegionServerTests.class, MediumTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(MediumTests.TAG) public class TestLogRollingNoCluster { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestLogRollingNoCluster.class); - private final static HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil(); private final static byte[] EMPTY_1K_ARRAY = new byte[1024]; private static final int NUM_THREADS = 100; // Spin up this many threads @@ -120,7 +115,7 @@ public void testContendedLogRolling() throws Exception { wals.close(); } for (int i = 0; i < numThreads; i++) { - assertFalse("Error: " + appenders[i].getException(), appenders[i].isException()); + assertFalse(appenders[i].isException(), "Error: " + appenders[i].getException()); } TEST_UTIL.shutdownMiniDFSCluster(); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestMetricsWAL.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestMetricsWAL.java index e430964afd1c..e051e2c6bd15 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestMetricsWAL.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestMetricsWAL.java @@ -17,7 +17,7 @@ */ package org.apache.hadoop.hbase.regionserver.wal; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -25,27 +25,26 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import org.apache.hadoop.fs.Path; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.testclassification.MiscTests; import org.apache.hadoop.hbase.testclassification.SmallTests; import org.apache.hadoop.hbase.wal.WALKey; import org.apache.hadoop.hbase.wal.WALKeyImpl; import org.apache.hadoop.metrics2.lib.DynamicMetricsRegistry; -import org.junit.ClassRule; -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.rules.TestName; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; -@Category({ MiscTests.class, SmallTests.class }) +@Tag(MiscTests.TAG) +@Tag(SmallTests.TAG) public class TestMetricsWAL { - @Rule - public TestName name = new TestName(); + private String name; - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestMetricsWAL.class); + @BeforeEach + public void initTestName(TestInfo testInfo) { + name = testInfo.getTestMethod().get().getName(); + } @Test public void testLogRollRequested() throws Exception { @@ -79,7 +78,7 @@ public void testPostSync() throws Exception { @Test public void testSlowAppend() throws Exception { - String testName = name.getMethodName(); + String testName = name; MetricsWALSource source = new MetricsWALSourceImpl(testName, testName, testName, testName); MetricsWAL metricsWAL = new MetricsWAL(source); TableName tableName = TableName.valueOf("foo"); @@ -138,7 +137,7 @@ public void testPerTableWALMetrics() throws Exception { @Test public void testLogRolls() { - String testName = name.getMethodName(); + String testName = name; MetricsWALSource source = new MetricsWALSourceImpl(testName, testName, testName, testName); MetricsWAL metricsWAL = new MetricsWAL(source); Path path1 = new Path("path-1"); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestProtobufLog.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestProtobufLog.java index c721b1e62fff..f2417158779d 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestProtobufLog.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestProtobufLog.java @@ -19,21 +19,16 @@ import java.io.IOException; import org.apache.hadoop.fs.Path; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.wal.FSHLogProvider; import org.apache.hadoop.hbase.wal.WALProvider.Writer; -import org.junit.ClassRule; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Tag; -@Category({ RegionServerTests.class, MediumTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(MediumTests.TAG) public class TestProtobufLog extends AbstractTestProtobufLog { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestProtobufLog.class); - @Override protected Writer createWriter(Path path) throws IOException { return FSHLogProvider.createWriter(TEST_UTIL.getConfiguration(), fs, path, false); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestSecureAsyncWALReplay.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestSecureAsyncWALReplay.java index c123fb2dcf16..1721dc099c74 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestSecureAsyncWALReplay.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestSecureAsyncWALReplay.java @@ -18,23 +18,18 @@ package org.apache.hadoop.hbase.regionserver.wal; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.io.crypto.MockAesKeyProvider; import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.testclassification.RegionServerTests; -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({ RegionServerTests.class, MediumTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(MediumTests.TAG) public class TestSecureAsyncWALReplay extends TestAsyncWALReplay { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestSecureAsyncWALReplay.class); - - @BeforeClass + @BeforeAll public static void setUpBeforeClass() throws Exception { Configuration conf = AbstractTestWALReplay.TEST_UTIL.getConfiguration(); conf.set(HConstants.CRYPTO_KEYPROVIDER_CONF_KEY, MockAesKeyProvider.class.getName()); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestSecureWALReplay.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestSecureWALReplay.java index e6a001b054b9..70841789f563 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestSecureWALReplay.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestSecureWALReplay.java @@ -17,29 +17,32 @@ */ package org.apache.hadoop.hbase.regionserver.wal; +import java.io.IOException; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.HBaseClassTestRule; +import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.io.crypto.MockAesKeyProvider; import org.apache.hadoop.hbase.testclassification.LargeTests; import org.apache.hadoop.hbase.testclassification.RegionServerTests; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.experimental.categories.Category; +import org.apache.hadoop.hbase.wal.WAL; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; -@Category({ RegionServerTests.class, LargeTests.class }) -public class TestSecureWALReplay extends TestWALReplay { +@Tag(RegionServerTests.TAG) +@Tag(LargeTests.TAG) +public class TestSecureWALReplay extends AbstractTestWALReplay { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestSecureWALReplay.class); - - @BeforeClass + @BeforeAll public static void setUpBeforeClass() throws Exception { Configuration conf = AbstractTestWALReplay.TEST_UTIL.getConfiguration(); conf.set(HConstants.CRYPTO_KEYPROVIDER_CONF_KEY, MockAesKeyProvider.class.getName()); conf.set(HConstants.CRYPTO_MASTERKEY_NAME_CONF_KEY, "hbase"); conf.setBoolean(HConstants.ENABLE_WAL_ENCRYPTION, true); - AbstractTestWALReplay.setUpBeforeClass(); + TestWALReplay.setUpBeforeClass(); + } + + @Override + protected WAL createWAL(Configuration c, Path hbaseRootDir, String logName) throws IOException { + return TestWALReplay.createFSHLog(c, hbaseRootDir, logName); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestSequenceIdAccounting.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestSequenceIdAccounting.java index 0ab5312e204c..693dbc93cc50 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestSequenceIdAccounting.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestSequenceIdAccounting.java @@ -17,31 +17,25 @@ */ package org.apache.hadoop.hbase.regionserver.wal; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.testclassification.SmallTests; import org.apache.hadoop.hbase.util.Bytes; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(SmallTests.class) +@Tag(SmallTests.TAG) public class TestSequenceIdAccounting { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestSequenceIdAccounting.class); - private static final byte[] ENCODED_REGION_NAME = Bytes.toBytes("r"); private static final byte[] FAMILY_NAME = Bytes.toBytes("cf"); private static final byte[] META_FAMILY = Bytes.toBytes("METAFAMILY"); @@ -96,7 +90,7 @@ public void testAreAllLower() { assertEquals(1, regions.size()); assertArrayEquals(ENCODED_REGION_NAME, regions.get(0)); long lowest = sida.getLowestSequenceId(ENCODED_REGION_NAME); - assertEquals("Lowest should be first sequence id inserted", 1, lowest); + assertEquals(1, lowest, "Lowest should be first sequence id inserted"); m.put(ENCODED_REGION_NAME, lowest); assertFalse(sida.areAllLower(m, null)); // Now make sure above works when flushing. diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestSyncFuture.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestSyncFuture.java index 618961719edb..bdca79f05f73 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestSyncFuture.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestSyncFuture.java @@ -17,31 +17,29 @@ */ package org.apache.hadoop.hbase.regionserver.wal; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.exceptions.TimeoutIOException; import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.testclassification.SmallTests; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category({ RegionServerTests.class, SmallTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(SmallTests.TAG) public class TestSyncFuture { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestSyncFuture.class); - - @Test(expected = TimeoutIOException.class) + @Test public void testGet() throws Exception { - long timeout = 5000; - long txid = 100000; - SyncFuture syncFulture = new SyncFuture().reset(txid, false); - syncFulture.done(txid, null); - assertEquals(txid, syncFulture.get(timeout)); + assertThrows(TimeoutIOException.class, () -> { + long timeout = 5000; + long txid = 100000; + SyncFuture syncFulture = new SyncFuture().reset(txid, false); + syncFulture.done(txid, null); + assertEquals(txid, syncFulture.get(timeout)); - syncFulture.reset(txid, false).get(timeout); + syncFulture.reset(txid, false).get(timeout); + }); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestSyncFutureCache.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestSyncFutureCache.java index ffa1249064ff..f3b4dd7976af 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestSyncFutureCache.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestSyncFutureCache.java @@ -17,27 +17,22 @@ */ package org.apache.hadoop.hbase.regionserver.wal; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; import java.util.concurrent.CompletableFuture; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.testclassification.SmallTests; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category({ RegionServerTests.class, SmallTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(SmallTests.TAG) public class TestSyncFutureCache { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestSyncFutureCache.class); - @Test public void testSyncFutureCacheLifeCycle() throws Exception { final Configuration conf = HBaseConfiguration.create(); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALActionsListener.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALActionsListener.java index 61dd8def4ea6..f5fc08aee930 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALActionsListener.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALActionsListener.java @@ -17,14 +17,13 @@ */ package org.apache.hadoop.hbase.regionserver.wal; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.NavigableMap; import java.util.TreeMap; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseTestingUtil; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.KeyValue; @@ -41,23 +40,19 @@ import org.apache.hadoop.hbase.wal.WALEditInternalHelper; import org.apache.hadoop.hbase.wal.WALFactory; import org.apache.hadoop.hbase.wal.WALKeyImpl; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; /** * Test that the actions are called while playing with an WAL */ -@Category({ RegionServerTests.class, SmallTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(SmallTests.TAG) public class TestWALActionsListener { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestWALActionsListener.class); - private final static HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil(); private final static byte[] SOME_BYTES = Bytes.toBytes("t"); @@ -67,7 +62,7 @@ public class TestWALActionsListener { private static FileSystem fs; private static FileSystem logFs; - @BeforeClass + @BeforeAll public static void setUpBeforeClass() throws Exception { conf = TEST_UTIL.getConfiguration(); conf.setInt("hbase.regionserver.maxlogs", 5); @@ -77,14 +72,14 @@ public static void setUpBeforeClass() throws Exception { logFs = CommonFSUtils.getWALFileSystem(conf); } - @Before + @BeforeEach public void setUp() throws Exception { fs.delete(rootDir, true); logFs.delete(new Path(walRootDir, HConstants.HREGION_LOGDIR_NAME), true); logFs.delete(new Path(walRootDir, HConstants.HREGION_OLDLOGDIR_NAME), true); } - @After + @AfterEach public void tearDown() throws Exception { setUp(); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALCellCodecWithCompression.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALCellCodecWithCompression.java index 32a2b06610bb..e14351e1d923 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALCellCodecWithCompression.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALCellCodecWithCompression.java @@ -17,8 +17,8 @@ */ package org.apache.hadoop.hbase.regionserver.wal; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -26,15 +26,15 @@ import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.List; +import java.util.stream.Stream; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.ArrayBackedTag; import org.apache.hadoop.hbase.ByteBufferKeyValue; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseCommonTestingUtil; +import org.apache.hadoop.hbase.HBaseParameterizedTestTemplate; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.PrivateCellUtil; -import org.apache.hadoop.hbase.Tag; import org.apache.hadoop.hbase.codec.Codec.Decoder; import org.apache.hadoop.hbase.codec.Codec.Encoder; import org.apache.hadoop.hbase.io.compress.Compression; @@ -42,53 +42,46 @@ import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.testclassification.SmallTests; import org.apache.hadoop.hbase.util.Bytes; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; - -@Category({ RegionServerTests.class, SmallTests.class }) -@RunWith(Parameterized.class) -public class TestWALCellCodecWithCompression { +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.TestTemplate; +import org.junit.jupiter.params.provider.Arguments; - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestWALCellCodecWithCompression.class); +@Tag(RegionServerTests.TAG) +@Tag(SmallTests.TAG) +@HBaseParameterizedTestTemplate +public class TestWALCellCodecWithCompression { - private Compression.Algorithm compression; + private final Compression.Algorithm compression; public TestWALCellCodecWithCompression(Compression.Algorithm algo) { this.compression = algo; } - @Parameters - public static List params() { - return HBaseCommonTestingUtil.COMPRESSION_ALGORITHMS_PARAMETERIZED; + public static Stream parameters() { + return HBaseCommonTestingUtil.COMPRESSION_ALGORITHMS_PARAMETERIZED.stream().map(Arguments::of); } - @Test + @TestTemplate public void testEncodeDecodeKVsWithTags() throws Exception { doTest(false, false); } - @Test + @TestTemplate public void testEncodeDecodeKVsWithTagsWithTagsCompression() throws Exception { doTest(true, false); } - @Test + @TestTemplate public void testEncodeDecodeOffKVsWithTagsWithTagsCompression() throws Exception { doTest(true, false); } - @Test + @TestTemplate public void testValueCompressionEnabled() throws Exception { doTest(false, true); } - @Test + @TestTemplate public void testValueCompression() throws Exception { final byte[] row_1 = Bytes.toBytes("row_1"); final byte[] value_1 = new byte[20]; @@ -186,9 +179,9 @@ private void doTest(boolean compressTags, boolean offheapKV) throws Exception { Decoder decoder = codec.getDecoder(is); decoder.advance(); KeyValue kv = (KeyValue) decoder.current(); - List tags = PrivateCellUtil.getTags(kv); + List tags = PrivateCellUtil.getTags(kv); assertEquals(1, tags.size()); - assertEquals("tagValue1", Bytes.toString(Tag.cloneValue(tags.get(0)))); + assertEquals("tagValue1", Bytes.toString(org.apache.hadoop.hbase.Tag.cloneValue(tags.get(0)))); decoder.advance(); kv = (KeyValue) decoder.current(); tags = PrivateCellUtil.getTags(kv); @@ -197,14 +190,14 @@ private void doTest(boolean compressTags, boolean offheapKV) throws Exception { kv = (KeyValue) decoder.current(); tags = PrivateCellUtil.getTags(kv); assertEquals(2, tags.size()); - assertEquals("tagValue1", Bytes.toString(Tag.cloneValue(tags.get(0)))); - assertEquals("tagValue2", Bytes.toString(Tag.cloneValue(tags.get(1)))); + assertEquals("tagValue1", Bytes.toString(org.apache.hadoop.hbase.Tag.cloneValue(tags.get(0)))); + assertEquals("tagValue2", Bytes.toString(org.apache.hadoop.hbase.Tag.cloneValue(tags.get(1)))); } private KeyValue createKV(byte[] row, byte[] value, int noOfTags) { byte[] cf = Bytes.toBytes("myCF"); byte[] q = Bytes.toBytes("myQualifier"); - List tags = new ArrayList<>(noOfTags); + List tags = new ArrayList<>(noOfTags); for (int i = 1; i <= noOfTags; i++) { tags.add(new ArrayBackedTag((byte) i, Bytes.toBytes("tagValue" + i))); } @@ -214,7 +207,7 @@ private KeyValue createKV(byte[] row, byte[] value, int noOfTags) { private ByteBufferKeyValue createOffheapKV(byte[] row, byte[] value, int noOfTags) { byte[] cf = Bytes.toBytes("myCF"); byte[] q = Bytes.toBytes("myQualifier"); - List tags = new ArrayList<>(noOfTags); + List tags = new ArrayList<>(noOfTags); for (int i = 1; i <= noOfTags; i++) { tags.add(new ArrayBackedTag((byte) i, Bytes.toBytes("tagValue" + i))); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALConfiguration.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALConfiguration.java index 7ffa72c0eece..b9c978ec710c 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALConfiguration.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALConfiguration.java @@ -17,14 +17,14 @@ */ package org.apache.hadoop.hbase.regionserver.wal; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import java.io.IOException; -import java.util.Arrays; +import java.util.stream.Stream; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; -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.testclassification.RegionServerTests; @@ -32,14 +32,11 @@ import org.apache.hadoop.hbase.wal.WAL; import org.apache.hadoop.hbase.wal.WALFactory; import org.apache.hadoop.hbase.wal.WALProvider; -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.TestName; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.TestTemplate; +import org.junit.jupiter.params.provider.Arguments; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -47,28 +44,28 @@ * Ensure configuration changes are having an effect on WAL. There is a lot of reflection around WAL * setup; could be skipping Configuration changes. */ -@RunWith(Parameterized.class) -@Category({ RegionServerTests.class, SmallTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(SmallTests.TAG) +@HBaseParameterizedTestTemplate(name = "{index}: provider={0}") public class TestWALConfiguration { private static final Logger LOG = LoggerFactory.getLogger(TestWALConfiguration.class); static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil(); - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestWALConfiguration.class); - @Rule - public TestName name = new TestName(); + private String name; - @Parameterized.Parameter - public String walProvider; + private final String walProvider; - @Parameterized.Parameters(name = "{index}: provider={0}") - public static Iterable data() { - return Arrays.asList(new Object[] { "filesystem" }, new Object[] { "asyncfs" }); + public static Stream parameters() { + return Stream.of(Arguments.of("filesystem"), Arguments.of("asyncfs")); } - @Before - public void before() { + public TestWALConfiguration(String walProvider) { + this.walProvider = walProvider; + } + + @BeforeEach + public void before(TestInfo testInfo) { + name = testInfo.getTestMethod().get().getName(); TEST_UTIL.getConfiguration().set(WALFactory.WAL_PROVIDER, walProvider); } @@ -77,7 +74,7 @@ public void before() { * verify more than this given the blocksize is passed down to HDFS on create -- not kept local to * the streams themselves. */ - @Test + @TestTemplate public void testBlocksizeDefaultsToTwiceHDFSBlockSize() throws IOException { TableName tableName = TableName.valueOf("test"); final WALFactory walFactory = new WALFactory(TEST_UTIL.getConfiguration(), this.walProvider); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALEdit.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALEdit.java index 00de2118795a..a19acea45663 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALEdit.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALEdit.java @@ -19,25 +19,20 @@ import static org.apache.hadoop.hbase.wal.WALEdit.METAFAMILY; import static org.apache.hadoop.hbase.wal.WALEdit.REPLICATION_MARKER; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.CellUtil; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.replication.regionserver.ReplicationMarkerChore; import org.apache.hadoop.hbase.testclassification.SmallTests; import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; import org.apache.hadoop.hbase.wal.WALEdit; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category({ SmallTests.class }) +@Tag(SmallTests.TAG) public class TestWALEdit { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestWALEdit.class); private static final String RS_NAME = "test-region-server-name"; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALReplay.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALReplay.java index a41b83fb41c5..e93272999953 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALReplay.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALReplay.java @@ -21,24 +21,26 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseTestingUtil; import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.wal.WAL; import org.apache.hadoop.hbase.wal.WALFactory; -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; +import org.junit.jupiter.api.TestInfo; -@Category({ RegionServerTests.class, MediumTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(MediumTests.TAG) public class TestWALReplay extends AbstractTestWALReplay { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestWALReplay.class); + @BeforeAll + public static void setUpBeforeClass(TestInfo testInfo) throws Exception { + if (testInfo.getTestClass().get() == TestWALReplay.class) { + setUpBeforeClass(); + } + } - @BeforeClass public static void setUpBeforeClass() throws Exception { Configuration conf = AbstractTestWALReplay.TEST_UTIL.getConfiguration(); conf.set(WALFactory.WAL_PROVIDER, "filesystem"); @@ -47,6 +49,10 @@ public static void setUpBeforeClass() throws Exception { @Override protected WAL createWAL(Configuration c, Path hbaseRootDir, String logName) throws IOException { + return createFSHLog(c, hbaseRootDir, logName); + } + + static WAL createFSHLog(Configuration c, Path hbaseRootDir, String logName) throws IOException { FileSystem fs = hbaseRootDir.getFileSystem(c); fs.mkdirs(new Path(hbaseRootDir, logName)); FSHLog wal = new FSHLog(fs, hbaseRootDir, logName, c); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALReplayBoundedLogWriterCreation.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALReplayBoundedLogWriterCreation.java index bbeaa2b1609e..07cfbafcda87 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALReplayBoundedLogWriterCreation.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALReplayBoundedLogWriterCreation.java @@ -17,23 +17,26 @@ */ package org.apache.hadoop.hbase.regionserver.wal; -import org.apache.hadoop.hbase.HBaseClassTestRule; +import java.io.IOException; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.testclassification.LargeTests; +import org.apache.hadoop.hbase.wal.WAL; import org.apache.hadoop.hbase.wal.WALSplitter; -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) -public class TestWALReplayBoundedLogWriterCreation extends TestWALReplay { +@Tag(LargeTests.TAG) +public class TestWALReplayBoundedLogWriterCreation extends AbstractTestWALReplay { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestWALReplayBoundedLogWriterCreation.class); - - @BeforeClass + @BeforeAll public static void setUpBeforeClass() throws Exception { TestWALReplay.setUpBeforeClass(); TEST_UTIL.getConfiguration().setBoolean(WALSplitter.SPLIT_WRITER_CREATION_BOUNDED, true); } + + @Override + protected WAL createWAL(Configuration c, Path hbaseRootDir, String logName) throws IOException { + return TestWALReplay.createFSHLog(c, hbaseRootDir, logName); + } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALReplayCompressed.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALReplayCompressed.java index 87bcfbb2a88a..6a210c75036c 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALReplayCompressed.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALReplayCompressed.java @@ -17,29 +17,32 @@ */ package org.apache.hadoop.hbase.regionserver.wal; +import java.io.IOException; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.HBaseClassTestRule; +import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.testclassification.LargeTests; import org.apache.hadoop.hbase.testclassification.RegionServerTests; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.experimental.categories.Category; +import org.apache.hadoop.hbase.wal.WAL; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; /** * Enables compression and runs the TestWALReplay tests. */ -@Category({ RegionServerTests.class, LargeTests.class }) -public class TestWALReplayCompressed extends TestWALReplay { +@Tag(RegionServerTests.TAG) +@Tag(LargeTests.TAG) +public class TestWALReplayCompressed extends AbstractTestWALReplay { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestWALReplayCompressed.class); - - @BeforeClass + @BeforeAll public static void setUpBeforeClass() throws Exception { Configuration conf = AbstractTestWALReplay.TEST_UTIL.getConfiguration(); conf.setBoolean(HConstants.ENABLE_WAL_COMPRESSION, true); TestWALReplay.setUpBeforeClass(); } + + @Override + protected WAL createWAL(Configuration c, Path hbaseRootDir, String logName) throws IOException { + return TestWALReplay.createFSHLog(c, hbaseRootDir, logName); + } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALReplayValueCompression.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALReplayValueCompression.java index 8478215c6988..17647882eb60 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALReplayValueCompression.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALReplayValueCompression.java @@ -17,30 +17,33 @@ */ package org.apache.hadoop.hbase.regionserver.wal; +import java.io.IOException; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.HBaseClassTestRule; +import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.testclassification.LargeTests; import org.apache.hadoop.hbase.testclassification.RegionServerTests; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.experimental.categories.Category; +import org.apache.hadoop.hbase.wal.WAL; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; /** * Enables compression and runs the TestWALReplay tests. */ -@Category({ RegionServerTests.class, LargeTests.class }) -public class TestWALReplayValueCompression extends TestWALReplay { +@Tag(RegionServerTests.TAG) +@Tag(LargeTests.TAG) +public class TestWALReplayValueCompression extends AbstractTestWALReplay { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestWALReplayValueCompression.class); - - @BeforeClass + @BeforeAll public static void setUpBeforeClass() throws Exception { Configuration conf = AbstractTestWALReplay.TEST_UTIL.getConfiguration(); conf.setBoolean(HConstants.ENABLE_WAL_COMPRESSION, true); conf.setBoolean(CompressionContext.ENABLE_WAL_VALUE_COMPRESSION, true); TestWALReplay.setUpBeforeClass(); } + + @Override + protected WAL createWAL(Configuration c, Path hbaseRootDir, String logName) throws IOException { + return TestWALReplay.createFSHLog(c, hbaseRootDir, logName); + } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALSyncTimeoutException.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALSyncTimeoutException.java index a1b9b9d54a10..e7ce5735cbbc 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALSyncTimeoutException.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALSyncTimeoutException.java @@ -17,8 +17,8 @@ */ package org.apache.hadoop.hbase.regionserver.wal; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.io.IOException; import java.util.List; @@ -26,7 +26,6 @@ import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.Abortable; -import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseTestingUtil; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.StartTestingClusterOption; @@ -50,22 +49,18 @@ import org.apache.hadoop.hbase.wal.WAL; import org.apache.hadoop.hbase.wal.WALFactory; import org.apache.hadoop.hbase.wal.WALProvider; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import org.apache.hbase.thirdparty.io.netty.channel.Channel; import org.apache.hbase.thirdparty.io.netty.channel.EventLoopGroup; -@Category({ RegionServerTests.class, LargeTests.class }) +@Tag(RegionServerTests.TAG) +@Tag(LargeTests.TAG) public class TestWALSyncTimeoutException { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestWALSyncTimeoutException.class); - private static final byte[] FAMILY = Bytes.toBytes("family_test"); private static final byte[] QUAL = Bytes.toBytes("qualifier_test"); @@ -77,7 +72,7 @@ public class TestWALSyncTimeoutException { private static final long timeoutMIlliseconds = 3000; private static final String USER_THREAD_NAME = tableName.getNameAsString(); - @BeforeClass + @BeforeAll public static void setUp() throws Exception { Configuration conf = HTU.getConfiguration(); conf.setClass(HConstants.REGION_IMPL, HRegionForTest.class, HRegion.class); @@ -92,7 +87,7 @@ public static void setUp() throws Exception { } - @AfterClass + @AfterAll public static void tearDown() throws Exception { HTU.shutdownMiniCluster(); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/WALDurabilityTestBase.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/WALDurabilityTestBase.java index d0aebad90fcc..9585e4065754 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/WALDurabilityTestBase.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/WALDurabilityTestBase.java @@ -17,9 +17,9 @@ */ package org.apache.hadoop.hbase.regionserver.wal; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; import org.apache.hadoop.conf.Configuration; @@ -34,11 +34,10 @@ import org.apache.hadoop.hbase.regionserver.MemStoreLAB; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.wal.WAL; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestName; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; /** * Tests for WAL write durability - hflush vs hsync @@ -51,20 +50,20 @@ public abstract class WALDurabilityTestBase { private final static HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil(); private Configuration conf; private String dir; - @Rule - public TestName name = new TestName(); + private String name; // Test names protected TableName tableName; - @Before - public void setUp() throws IOException { + @BeforeEach + public void setUp(TestInfo testInfo) throws IOException { + name = testInfo.getTestMethod().get().getName(); conf = TEST_UTIL.getConfiguration(); dir = TEST_UTIL.getDataTestDir("TestHRegion").toString(); - tableName = TableName.valueOf(name.getMethodName()); + tableName = TableName.valueOf(name); } - @After + @AfterEach public void tearDown() throws IOException { TEST_UTIL.cleanupTestDir(); } @@ -155,7 +154,7 @@ public void testWALDurability() throws IOException { } private String getName() { - return name.getMethodName(); + return name; } /** From 88d75f1f7507710f40f8bea029c4bbd62d450937 Mon Sep 17 00:00:00 2001 From: liuxiaocs7 Date: Mon, 27 Apr 2026 23:46:47 +0800 Subject: [PATCH 2/4] address comments --- .../hadoop/hbase/regionserver/wal/TestSyncFuture.java | 8 ++++---- .../regionserver/wal/TestWALCellCodecWithCompression.java | 2 +- .../hbase/regionserver/wal/TestWALConfiguration.java | 8 +------- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestSyncFuture.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestSyncFuture.java index bdca79f05f73..e23094c74122 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestSyncFuture.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestSyncFuture.java @@ -35,11 +35,11 @@ public void testGet() throws Exception { assertThrows(TimeoutIOException.class, () -> { long timeout = 5000; long txid = 100000; - SyncFuture syncFulture = new SyncFuture().reset(txid, false); - syncFulture.done(txid, null); - assertEquals(txid, syncFulture.get(timeout)); + SyncFuture syncFuture = new SyncFuture().reset(txid, false); + syncFuture.done(txid, null); + assertEquals(txid, syncFuture.get(timeout)); - syncFulture.reset(txid, false).get(timeout); + syncFuture.reset(txid, false).get(timeout); }); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALCellCodecWithCompression.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALCellCodecWithCompression.java index e14351e1d923..27ffd8b8c04d 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALCellCodecWithCompression.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALCellCodecWithCompression.java @@ -73,7 +73,7 @@ public void testEncodeDecodeKVsWithTagsWithTagsCompression() throws Exception { @TestTemplate public void testEncodeDecodeOffKVsWithTagsWithTagsCompression() throws Exception { - doTest(true, false); + doTest(true, true); } @TestTemplate diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALConfiguration.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALConfiguration.java index b9c978ec710c..cf1532a14b62 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALConfiguration.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALConfiguration.java @@ -26,7 +26,6 @@ import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.hbase.HBaseParameterizedTestTemplate; import org.apache.hadoop.hbase.HBaseTestingUtil; -import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.testclassification.SmallTests; import org.apache.hadoop.hbase.wal.WAL; @@ -34,7 +33,6 @@ import org.apache.hadoop.hbase.wal.WALProvider; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; -import org.junit.jupiter.api.TestInfo; import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.params.provider.Arguments; import org.slf4j.Logger; @@ -51,8 +49,6 @@ public class TestWALConfiguration { private static final Logger LOG = LoggerFactory.getLogger(TestWALConfiguration.class); static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil(); - private String name; - private final String walProvider; public static Stream parameters() { @@ -64,8 +60,7 @@ public TestWALConfiguration(String walProvider) { } @BeforeEach - public void before(TestInfo testInfo) { - name = testInfo.getTestMethod().get().getName(); + public void before() { TEST_UTIL.getConfiguration().set(WALFactory.WAL_PROVIDER, walProvider); } @@ -76,7 +71,6 @@ public void before(TestInfo testInfo) { */ @TestTemplate public void testBlocksizeDefaultsToTwiceHDFSBlockSize() throws IOException { - TableName tableName = TableName.valueOf("test"); final WALFactory walFactory = new WALFactory(TEST_UTIL.getConfiguration(), this.walProvider); Configuration conf = TEST_UTIL.getConfiguration(); WALProvider provider = walFactory.getWALProvider(); From a364de956c5c928f6864b06abaf344598c349dfa Mon Sep 17 00:00:00 2001 From: liuxiaocs7 Date: Thu, 30 Apr 2026 11:32:41 +0800 Subject: [PATCH 3/4] address comments --- .../PerfTestCompactionPolicies.java | 17 +++---- .../regionserver/wal/AbstractTestFSWAL.java | 45 +++++++------------ .../regionserver/wal/TestAsyncFSWAL.java | 2 +- 3 files changed, 27 insertions(+), 37 deletions(-) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/PerfTestCompactionPolicies.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/PerfTestCompactionPolicies.java index 7bb2458618be..3d21473da3a9 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/PerfTestCompactionPolicies.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/PerfTestCompactionPolicies.java @@ -42,13 +42,13 @@ import org.junit.jupiter.params.provider.Arguments; /** - * This is not a unit test. It is not run as part of the general unit test suite. It is for - * comparing compaction policies. You must run it explicitly; e.g. mvn test - * -Dtest=PerfTestCompactionPolicies + * This test compares compaction policy behavior with different generated store file lists and + * settings. It can be run explicitly; e.g. mvn test -Dtest=PerfTestCompactionPolicies */ @Tag(RegionServerTests.TAG) @Tag(MediumTests.TAG) -@HBaseParameterizedTestTemplate +@HBaseParameterizedTestTemplate( + name = "{index}: policy={0}, fileGen={1}, max={2}, min={3}, " + "ratio={4}") public class PerfTestCompactionPolicies extends MockStoreFileGenerator { private final RatioBasedCompactionPolicy cp; @@ -94,10 +94,11 @@ public static Stream parameters() { /** * Test the perf of a CompactionPolicy with settings. - * @param cpClass The compaction policy to test - * @param inMmax The maximum number of file to compact - * @param inMin The min number of files to compact - * @param inRatio The ratio that files must be under to be compacted. + * @param cpClass The compaction policy to test + * @param fileGenClass The store file list generator to test with + * @param inMmax The maximum number of files to compact + * @param inMin The min number of files to compact + * @param inRatio The ratio that files must be under to be compacted. */ public PerfTestCompactionPolicies(final Class cpClass, final Class fileGenClass, final int inMmax, final int inMin, diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestFSWAL.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestFSWAL.java index 808db7c8c0ee..0a31440e3197 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestFSWAL.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestFSWAL.java @@ -108,18 +108,18 @@ public abstract class AbstractTestFSWAL { protected static Path DIR; protected final static HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil(); - protected String currentTest; + protected String testName; @BeforeEach public void setUp(TestInfo testInfo) throws Exception { - currentTest = testInfo.getTestMethod().get().getName(); + testName = testInfo.getTestMethod().get().getName(); FileStatus[] entries = FS.listStatus(new Path("/")); for (FileStatus dir : entries) { FS.delete(dir.getPath(), true); } final Path hbaseDir = TEST_UTIL.createRootDir(); final Path hbaseWALDir = TEST_UTIL.createWALRootDir(); - DIR = new Path(hbaseWALDir, currentTest); + DIR = new Path(hbaseWALDir, testName); assertNotEquals(hbaseDir, hbaseWALDir); FS.mkdirs(DIR); } @@ -394,19 +394,16 @@ public void testFindMemStoresEligibleForFlush() throws Exception { @Test public void testFailedToCreateWALIfParentRenamed() throws IOException, CommonFSUtils.StreamLacksCapabilityException { - assertThrows(IOException.class, () -> { - AbstractFSWAL wal = newWAL(FS, CommonFSUtils.getWALRootDir(CONF), currentTest, - HConstants.HREGION_OLDLOGDIR_NAME, CONF, null, true, null, null); - long filenum = EnvironmentEdgeManager.currentTime(); - Path path = wal.computeFilename(filenum); - wal.createWriterInstance(FS, path); - Path parent = path.getParent(); - path = wal.computeFilename(filenum + 1); - Path newPath = new Path(parent.getParent(), parent.getName() + "-splitting"); - FS.rename(parent, newPath); - wal.createWriterInstance(FS, path); - fail("It should fail to create the new WAL"); - }); + AbstractFSWAL wal = newWAL(FS, CommonFSUtils.getWALRootDir(CONF), testName, + HConstants.HREGION_OLDLOGDIR_NAME, CONF, null, true, null, null); + long filenum = EnvironmentEdgeManager.currentTime(); + Path path = wal.computeFilename(filenum); + wal.createWriterInstance(FS, path); + Path parent = path.getParent(); + Path newPath = new Path(parent.getParent(), parent.getName() + "-splitting"); + FS.rename(parent, newPath); + Path nextPath = wal.computeFilename(filenum + 1); + assertThrows(IOException.class, () -> wal.createWriterInstance(FS, nextPath)); } /** @@ -418,7 +415,6 @@ public void testFailedToCreateWALIfParentRenamed() */ @Test public void testFlushSequenceIdIsGreaterThanAllEditsInHFile() throws IOException { - String testName = currentTest; final TableName tableName = TableName.valueOf(testName); final RegionInfo hri = RegionInfoBuilder.newBuilder(tableName).build(); final byte[] rowName = tableName.getName(); @@ -493,7 +489,6 @@ public void run() { @Test public void testSyncNoAppend() throws IOException { - String testName = currentTest; AbstractFSWAL wal = newWAL(FS, CommonFSUtils.getWALRootDir(CONF), DIR.toString(), testName, CONF, null, true, null, null); try { @@ -505,7 +500,6 @@ public void testSyncNoAppend() throws IOException { @Test public void testWriteEntryCanBeNull() throws IOException { - String testName = currentTest; AbstractFSWAL wal = newWAL(FS, CommonFSUtils.getWALRootDir(CONF), DIR.toString(), testName, CONF, null, true, null, null); wal.close(); @@ -537,13 +531,10 @@ public void testWriteEntryCanBeNull() throws IOException { @Test public void testRollWriterForClosedWAL() throws IOException { - assertThrows(WALClosedException.class, () -> { - String testName = currentTest; - AbstractFSWAL wal = newWAL(FS, CommonFSUtils.getWALRootDir(CONF), DIR.toString(), testName, - CONF, null, true, null, null); - wal.close(); - wal.rollWriter(); - }); + AbstractFSWAL wal = newWAL(FS, CommonFSUtils.getWALRootDir(CONF), DIR.toString(), testName, + CONF, null, true, null, null); + wal.close(); + assertThrows(WALClosedException.class, () -> wal.rollWriter()); } private AbstractFSWAL createHoldingWAL(String testName, AtomicBoolean startHoldingForAppend, @@ -606,7 +597,6 @@ private void doPutWithAsyncWAL(ExecutorService exec, HRegion region, Put put, // Testcase for HBASE-23181 @Test public void testUnflushedSeqIdTrackingWithAsyncWal() throws IOException, InterruptedException { - String testName = currentTest; byte[] b = Bytes.toBytes("b"); TableDescriptor htd = TableDescriptorBuilder.newBuilder(TableName.valueOf("table")) .setColumnFamily(ColumnFamilyDescriptorBuilder.of(b)).build(); @@ -656,7 +646,6 @@ public static long getEarliestMemStoreSeqNum(WAL wal, byte[] encodedRegionName) // Testcase for HBASE-23157 @Test public void testMaxFlushedSequenceIdGoBackwards() throws IOException, InterruptedException { - String testName = currentTest; byte[] a = Bytes.toBytes("a"); byte[] b = Bytes.toBytes("b"); TableDescriptor htd = TableDescriptorBuilder.newBuilder(TableName.valueOf("table")) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncFSWAL.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncFSWAL.java index b41e23fc9f95..6594d27014ed 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncFSWAL.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncFSWAL.java @@ -137,7 +137,7 @@ public void testBrokenWriter() throws Exception { scopes.put(fam, 0); } long timestamp = EnvironmentEdgeManager.currentTime(); - String testName = currentTest; + String testName = this.testName; AtomicInteger failedCount = new AtomicInteger(0); try (LogRoller roller = new LogRoller(services); AsyncFSWAL wal = new AsyncFSWAL(FS, null, CommonFSUtils.getWALRootDir(CONF), DIR.toString(), From ec3cb1b10a2128f8ca7969ba0c8e10da7d7f68e2 Mon Sep 17 00:00:00 2001 From: liuxiaocs7 Date: Thu, 30 Apr 2026 11:47:12 +0800 Subject: [PATCH 4/4] update --- .../org/apache/hadoop/hbase/regionserver/wal/TestAsyncFSWAL.java | 1 - 1 file changed, 1 deletion(-) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncFSWAL.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncFSWAL.java index 6594d27014ed..5d0ad4d70cad 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncFSWAL.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncFSWAL.java @@ -137,7 +137,6 @@ public void testBrokenWriter() throws Exception { scopes.put(fam, 0); } long timestamp = EnvironmentEdgeManager.currentTime(); - String testName = this.testName; AtomicInteger failedCount = new AtomicInteger(0); try (LogRoller roller = new LogRoller(services); AsyncFSWAL wal = new AsyncFSWAL(FS, null, CommonFSUtils.getWALRootDir(CONF), DIR.toString(),