diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/AbstractTestRpcServer.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/AbstractTestRpcServer.java
new file mode 100644
index 000000000000..7b8aa3add3f9
--- /dev/null
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/AbstractTestRpcServer.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase.ipc;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.apache.hadoop.hbase.HBaseTestingUtil;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.Get;
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.client.Table;
+import org.apache.hadoop.hbase.client.TableDescriptor;
+import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
+import org.apache.hadoop.hbase.regionserver.DisabledRegionSplitPolicy;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.LoadTestKVGenerator;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.TestInfo;
+
+public abstract class AbstractTestRpcServer {
+
+ private static final byte[] FAMILY = Bytes.toBytes("f");
+ private static final byte[] QUALIFIER = Bytes.toBytes("q");
+ private static final int NUM_ROWS = 100;
+ private static final int MIN_LEN = 1000;
+ private static final int MAX_LEN = 1000000;
+ protected static final LoadTestKVGenerator GENERATOR = new LoadTestKVGenerator(MIN_LEN, MAX_LEN);
+ protected static HBaseTestingUtil TEST_UTIL;
+ protected TableName tableName;
+
+ @BeforeEach
+ public void setUpTest(TestInfo testInfo) {
+ tableName = TableName.valueOf(testInfo.getTestMethod().get().getName());
+ }
+
+ protected void doTest(TableName tableName) throws Exception {
+ // Splitting just complicates the test scenario, disable it
+ final TableDescriptor desc = TableDescriptorBuilder.newBuilder(tableName)
+ .setRegionSplitPolicyClassName(DisabledRegionSplitPolicy.class.getName()).build();
+ try (Table table =
+ TEST_UTIL.createTable(desc, new byte[][] { FAMILY }, TEST_UTIL.getConfiguration())) {
+ // put some test data
+ for (int i = 0; i < NUM_ROWS; i++) {
+ final byte[] rowKey = Bytes.toBytes(LoadTestKVGenerator.md5PrefixedKey(i));
+ final byte[] v = GENERATOR.generateRandomSizeValue(rowKey, QUALIFIER);
+ table.put(new Put(rowKey).addColumn(FAMILY, QUALIFIER, v));
+ }
+ // read to verify it.
+ for (int i = 0; i < NUM_ROWS; i++) {
+ final byte[] rowKey = Bytes.toBytes(LoadTestKVGenerator.md5PrefixedKey(i));
+ final Result r = table.get(new Get(rowKey).addColumn(FAMILY, QUALIFIER));
+ assertNotNull(r, "Result was empty");
+ final byte[] v = r.getValue(FAMILY, QUALIFIER);
+ assertNotNull(v, "Result did not contain expected value");
+ assertTrue(LoadTestKVGenerator.verify(v, rowKey, QUALIFIER), "Value was not verified");
+ }
+ }
+ }
+}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestBufferChain.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestBufferChain.java
index c7142f34f631..978a3f106c07 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestBufferChain.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestBufferChain.java
@@ -17,47 +17,42 @@
*/
package org.apache.hadoop.hbase.ipc;
-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 java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.RPCTests;
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;
import org.apache.hbase.thirdparty.com.google.common.base.Charsets;
import org.apache.hbase.thirdparty.com.google.common.io.Files;
-@Category({ RPCTests.class, SmallTests.class })
+@Tag(RPCTests.TAG)
+@Tag(SmallTests.TAG)
public class TestBufferChain {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestBufferChain.class);
-
private File tmpFile;
private static final byte[][] HELLO_WORLD_CHUNKS =
new byte[][] { "hello".getBytes(Charsets.UTF_8), " ".getBytes(Charsets.UTF_8),
"world".getBytes(Charsets.UTF_8) };
- @Before
+ @BeforeEach
public void setup() throws IOException {
tmpFile = File.createTempFile("TestBufferChain", "txt");
}
- @After
+ @AfterEach
public void teardown() {
tmpFile.delete();
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestCallRunner.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestCallRunner.java
index 4e8b7fdb6895..e8adc796d172 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestCallRunner.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestCallRunner.java
@@ -27,12 +27,11 @@
import static org.hamcrest.Matchers.hasItem;
import io.opentelemetry.api.trace.StatusCode;
-import io.opentelemetry.sdk.testing.junit4.OpenTelemetryRule;
+import io.opentelemetry.sdk.testing.junit5.OpenTelemetryExtension;
import java.net.InetSocketAddress;
import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.CallDroppedException;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.MatcherPredicate;
import org.apache.hadoop.hbase.Waiter;
@@ -41,31 +40,26 @@
import org.apache.hadoop.hbase.testclassification.RPCTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.trace.TraceUtil;
-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.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
+import org.junit.jupiter.api.extension.RegisterExtension;
import org.mockito.Mockito;
-@Category({ RPCTests.class, SmallTests.class })
+@Tag(RPCTests.TAG)
+@Tag(SmallTests.TAG)
public class TestCallRunner {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestCallRunner.class);
-
- @Rule
- public TestName testName = new TestName();
-
- @Rule
- public OpenTelemetryRule otelRule = OpenTelemetryRule.create();
+ @RegisterExtension
+ public static final OpenTelemetryExtension otelRule = OpenTelemetryExtension.create();
private Configuration conf = null;
+ private String testMethodName;
- @Before
- public void before() {
+ @BeforeEach
+ public void before(TestInfo testInfo) {
+ testMethodName = testInfo.getTestMethod().get().getName();
final HBaseTestingUtil util = new HBaseTestingUtil();
conf = util.getConfiguration();
}
@@ -83,13 +77,13 @@ public void testSimpleCall() {
CallRunner cr = new CallRunner(mockRpcServer, mockCall);
cr.setStatus(new MonitoredRPCHandlerImpl("test"));
cr.run();
- }, testName.getMethodName());
+ }, testMethodName);
Waiter.waitFor(conf, TimeUnit.SECONDS.toMillis(5), new MatcherPredicate<>(otelRule::getSpans,
- hasItem(allOf(hasName(testName.getMethodName()), hasEnded()))));
+ hasItem(allOf(hasName(testMethodName), hasEnded()))));
- assertThat(otelRule.getSpans(), hasItem(
- allOf(hasName(testName.getMethodName()), hasStatusWithCode(StatusCode.OK), hasEnded())));
+ assertThat(otelRule.getSpans(),
+ hasItem(allOf(hasName(testMethodName), hasStatusWithCode(StatusCode.OK), hasEnded())));
}
@Test
@@ -103,7 +97,7 @@ public void testCallCleanup() {
CallRunner cr = new CallRunner(mockRpcServer, mockCall);
cr.setStatus(new MonitoredRPCHandlerImpl("test"));
cr.run();
- }, testName.getMethodName());
+ }, testMethodName);
Mockito.verify(mockCall, Mockito.times(1)).cleanup();
}
@@ -118,14 +112,14 @@ public void testCallRunnerDropDisconnected() {
CallRunner cr = new CallRunner(mockRpcServer, mockCall);
cr.setStatus(new MonitoredRPCHandlerImpl("test"));
cr.drop();
- }, testName.getMethodName());
+ }, testMethodName);
Mockito.verify(mockCall, Mockito.times(1)).cleanup();
Waiter.waitFor(conf, TimeUnit.SECONDS.toMillis(5), new MatcherPredicate<>(otelRule::getSpans,
- hasItem(allOf(hasName(testName.getMethodName()), hasEnded()))));
+ hasItem(allOf(hasName(testMethodName), hasEnded()))));
assertThat(otelRule.getSpans(),
- hasItem(allOf(hasName(testName.getMethodName()), hasStatusWithCode(StatusCode.OK),
+ hasItem(allOf(hasName(testMethodName), hasStatusWithCode(StatusCode.OK),
hasEvents(hasItem(EventMatchers.hasName("Client disconnect detected"))), hasEnded())));
}
@@ -144,15 +138,15 @@ public void testCallRunnerDropConnected() {
CallRunner cr = new CallRunner(mockRpcServer, mockCall);
cr.setStatus(new MonitoredRPCHandlerImpl("test"));
cr.drop();
- }, testName.getMethodName());
+ }, testMethodName);
Mockito.verify(mockCall, Mockito.times(1)).cleanup();
Mockito.verify(mockMetrics).exception(Mockito.any(CallDroppedException.class));
Waiter.waitFor(conf, TimeUnit.SECONDS.toMillis(5), new MatcherPredicate<>(otelRule::getSpans,
- hasItem(allOf(hasName(testName.getMethodName()), hasEnded()))));
+ hasItem(allOf(hasName(testMethodName), hasEnded()))));
assertThat(otelRule.getSpans(),
- hasItem(allOf(hasName(testName.getMethodName()), hasStatusWithCode(StatusCode.ERROR),
+ hasItem(allOf(hasName(testMethodName), hasStatusWithCode(StatusCode.ERROR),
hasEvents(hasItem(allOf(EventMatchers.hasName("exception"),
EventMatchers.hasAttributes(
containsEntry("exception.type", CallDroppedException.class.getName()))))),
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestFifoRpcScheduler.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestFifoRpcScheduler.java
index 06b25f81ba92..69ecd821e7ac 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestFifoRpcScheduler.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestFifoRpcScheduler.java
@@ -17,7 +17,7 @@
*/
package org.apache.hadoop.hbase.ipc;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -29,27 +29,22 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.monitoring.MonitoredRPCHandlerImpl;
import org.apache.hadoop.hbase.testclassification.RPCTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
-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;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ RPCTests.class, SmallTests.class })
+@Tag(RPCTests.TAG)
+@Tag(SmallTests.TAG)
public class TestFifoRpcScheduler {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestFifoRpcScheduler.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestFifoRpcScheduler.class);
private AtomicInteger callExecutionCount;
@@ -62,7 +57,7 @@ public InetSocketAddress getListenerAddress() {
};
private Configuration conf;
- @Before
+ @BeforeEach
public void setUp() {
conf = HBaseConfiguration.create();
callExecutionCount = new AtomicInteger(0);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestHBaseClient.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestHBaseClient.java
index 90e696c45918..a2a9da01f756 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestHBaseClient.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestHBaseClient.java
@@ -17,24 +17,21 @@
*/
package org.apache.hadoop.hbase.ipc;
+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.net.Address;
import org.apache.hadoop.hbase.testclassification.RPCTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.ManualEnvironmentEdge;
-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;
-@Category({ RPCTests.class, SmallTests.class })
+@Tag(RPCTests.TAG)
+@Tag(SmallTests.TAG)
public class TestHBaseClient {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestHBaseClient.class);
-
@Test
public void testFailedServer() {
ManualEnvironmentEdge ee = new ManualEnvironmentEdge();
@@ -48,36 +45,36 @@ public void testFailedServer() {
Address ia3 = Address.fromParts("badtoo", 12);
Address ia4 = Address.fromParts("badtoo", 13);
- Assert.assertFalse(fs.isFailedServer(ia));
+ assertFalse(fs.isFailedServer(ia));
fs.addToFailedServers(ia, testThrowable);
- Assert.assertTrue(fs.isFailedServer(ia));
- Assert.assertTrue(fs.isFailedServer(ia2));
+ assertTrue(fs.isFailedServer(ia));
+ assertTrue(fs.isFailedServer(ia2));
ee.incValue(1);
- Assert.assertTrue(fs.isFailedServer(ia));
- Assert.assertTrue(fs.isFailedServer(ia2));
+ assertTrue(fs.isFailedServer(ia));
+ assertTrue(fs.isFailedServer(ia2));
ee.incValue(RpcClient.FAILED_SERVER_EXPIRY_DEFAULT + 1);
- Assert.assertFalse(fs.isFailedServer(ia));
- Assert.assertFalse(fs.isFailedServer(ia2));
+ assertFalse(fs.isFailedServer(ia));
+ assertFalse(fs.isFailedServer(ia2));
fs.addToFailedServers(ia, testThrowable);
fs.addToFailedServers(ia3, testThrowable);
fs.addToFailedServers(ia4, testThrowable);
- Assert.assertTrue(fs.isFailedServer(ia));
- Assert.assertTrue(fs.isFailedServer(ia2));
- Assert.assertTrue(fs.isFailedServer(ia3));
- Assert.assertTrue(fs.isFailedServer(ia4));
+ assertTrue(fs.isFailedServer(ia));
+ assertTrue(fs.isFailedServer(ia2));
+ assertTrue(fs.isFailedServer(ia3));
+ assertTrue(fs.isFailedServer(ia4));
ee.incValue(RpcClient.FAILED_SERVER_EXPIRY_DEFAULT + 1);
- Assert.assertFalse(fs.isFailedServer(ia));
- Assert.assertFalse(fs.isFailedServer(ia2));
- Assert.assertFalse(fs.isFailedServer(ia3));
- Assert.assertFalse(fs.isFailedServer(ia4));
+ assertFalse(fs.isFailedServer(ia));
+ assertFalse(fs.isFailedServer(ia2));
+ assertFalse(fs.isFailedServer(ia3));
+ assertFalse(fs.isFailedServer(ia4));
fs.addToFailedServers(ia3, testThrowable);
- Assert.assertFalse(fs.isFailedServer(ia4));
+ assertFalse(fs.isFailedServer(ia4));
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestMasterFifoRpcScheduler.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestMasterFifoRpcScheduler.java
index d11e32c723b6..986ad4f2e259 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestMasterFifoRpcScheduler.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestMasterFifoRpcScheduler.java
@@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hbase.ipc;
-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.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -26,7 +26,6 @@
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
@@ -34,29 +33,24 @@
import org.apache.hadoop.hbase.master.MasterRpcServices;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.RPCTests;
-import org.junit.AfterClass;
-import org.junit.Assert;
-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.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.apache.hadoop.hbase.shaded.protobuf.generated.RPCProtos;
-@Category({ RPCTests.class, LargeTests.class })
+@Tag(RPCTests.TAG)
+@Tag(LargeTests.TAG)
public class TestMasterFifoRpcScheduler {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMasterFifoRpcScheduler.class);
-
private static final String REGION_SERVER_REPORT = "RegionServerReport";
private static final String OTHER = "Other";
private static HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
- @BeforeClass
+ @BeforeAll
public static void setupBeforeClass() throws Exception {
Configuration conf = TEST_UTIL.getConfiguration();
conf.set(MasterRpcServices.MASTER_RPC_SCHEDULER_FACTORY_CLASS,
@@ -66,7 +60,7 @@ public static void setupBeforeClass() throws Exception {
TEST_UTIL.startMiniCluster();
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
@@ -76,7 +70,7 @@ public void testMasterRpcScheduler() {
HMaster master = TEST_UTIL.getHBaseCluster().getMaster();
MasterRpcServices masterRpcServices = master.getMasterRpcServices();
RpcScheduler masterRpcScheduler = masterRpcServices.getRpcScheduler();
- Assert.assertTrue(masterRpcScheduler instanceof MasterFifoRpcScheduler);
+ assertTrue(masterRpcScheduler instanceof MasterFifoRpcScheduler);
}
@Test
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestMultipleServerPrincipalsIPC.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestMultipleServerPrincipalsIPC.java
index 237f1cb40259..f1704fb5c966 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestMultipleServerPrincipalsIPC.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestMultipleServerPrincipalsIPC.java
@@ -21,8 +21,8 @@
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.either;
import static org.hamcrest.Matchers.instanceOf;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.File;
import java.io.IOException;
@@ -32,10 +32,11 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.stream.Stream;
import javax.security.sasl.SaslException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeys;
-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.ServerName;
@@ -46,17 +47,13 @@
import org.apache.hadoop.ipc.RemoteException;
import org.apache.hadoop.minikdc.MiniKdc;
import org.apache.hadoop.security.UserGroupInformation;
-import org.junit.After;
-import org.junit.AfterClass;
-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.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.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.collect.Lists;
@@ -74,14 +71,11 @@
*
* Put here just because we need to visit some package private classes under this package.
*/
-@RunWith(Parameterized.class)
-@Category({ SecurityTests.class, MediumTests.class })
+@Tag(SecurityTests.TAG)
+@Tag(MediumTests.TAG)
+@HBaseParameterizedTestTemplate(name = "{index}: rpcServerImpl={0}, rpcClientImpl={1}")
public class TestMultipleServerPrincipalsIPC {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMultipleServerPrincipalsIPC.class);
-
private static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
private static final File KEYTAB_FILE =
@@ -93,11 +87,8 @@ public class TestMultipleServerPrincipalsIPC {
private static String SERVER_PRINCIPAL2;
private static String CLIENT_PRINCIPAL;
- @Parameter(0)
- public Class extends RpcServer> rpcServerImpl;
-
- @Parameter(1)
- public Class extends RpcClient> rpcClientImpl;
+ private final Class extends RpcServer> rpcServerImpl;
+ private final Class extends RpcClient> rpcClientImpl;
private Configuration clientConf;
private Configuration serverConf;
@@ -106,22 +97,27 @@ public class TestMultipleServerPrincipalsIPC {
private RpcServer rpcServer;
private RpcClient rpcClient;
- @Parameters(name = "{index}: rpcServerImpl={0}, rpcClientImpl={1}")
- public static List params() {
- List params = new ArrayList<>();
+ public TestMultipleServerPrincipalsIPC(Class extends RpcServer> rpcServerImpl,
+ Class extends RpcClient> rpcClientImpl) {
+ this.rpcServerImpl = rpcServerImpl;
+ this.rpcClientImpl = rpcClientImpl;
+ }
+
+ public static Stream parameters() {
+ List params = new ArrayList<>();
List> rpcServerImpls =
Arrays.asList(NettyRpcServer.class, SimpleRpcServer.class);
List> rpcClientImpls =
Arrays.asList(NettyRpcClient.class, BlockingRpcClient.class);
for (Class extends RpcServer> rpcServerImpl : rpcServerImpls) {
for (Class extends RpcClient> rpcClientImpl : rpcClientImpls) {
- params.add(new Object[] { rpcServerImpl, rpcClientImpl });
+ params.add(Arguments.of(rpcServerImpl, rpcClientImpl));
}
}
- return params;
+ return params.stream();
}
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
KDC = TEST_UTIL.setupMiniKdc(KEYTAB_FILE);
SERVER_PRINCIPAL = "server/" + HOST + "@" + KDC.getRealm();
@@ -134,7 +130,7 @@ public static void setUpBeforeClass() throws Exception {
TEST_UTIL.getConfiguration().setInt(RpcClient.FAILED_SERVER_EXPIRY_KEY, 10);
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() {
if (KDC != null) {
KDC.stop();
@@ -159,7 +155,7 @@ private void loginAndStartRpcServer(String principal, int port) throws Exception
rpcServer.start();
}
- @Before
+ @BeforeEach
public void setUp() throws Exception {
clientConf = new Configuration(TEST_UTIL.getConfiguration());
clientConf.setClass(RpcClientFactory.CUSTOM_RPC_CLIENT_IMPL_CONF_KEY, rpcClientImpl,
@@ -183,7 +179,7 @@ public void setUp() throws Exception {
.createClient(clientConf, HConstants.DEFAULT_CLUSTER_ID.toString()));
}
- @After
+ @AfterEach
public void tearDown() throws IOException {
Closeables.close(rpcClient, true);
rpcServer.stop();
@@ -200,13 +196,13 @@ private String echo(String msg) throws Exception {
});
}
- @Test
+ @TestTemplate
public void testEcho() throws Exception {
String msg = "Hello World";
assertEquals(msg, echo(msg));
}
- @Test
+ @TestTemplate
public void testMaliciousServer() throws Exception {
// reset the server principals so the principal returned by server does not match
SecurityInfo securityInfo =
@@ -221,7 +217,7 @@ public void testMaliciousServer() throws Exception {
assertThat(error.getCause().getCause(), instanceOf(SaslException.class));
}
- @Test
+ @TestTemplate
public void testRememberLastSucceededServerPrincipal() throws Exception {
// after this call we will remember the last succeeded server principal
assertEquals("a", echo("a"));
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestNettyChannelWritability.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestNettyChannelWritability.java
index 64fc47ca1940..0726f6a06df7 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestNettyChannelWritability.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestNettyChannelWritability.java
@@ -19,10 +19,10 @@
import static org.apache.hadoop.hbase.ipc.TestProtobufRpcServiceImpl.SERVICE;
import static org.apache.hadoop.hbase.ipc.TestProtobufRpcServiceImpl.newBlockingStub;
-import static org.junit.Assert.assertEquals;
-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.assertEquals;
+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.net.InetSocketAddress;
@@ -35,7 +35,6 @@
import org.apache.hadoop.hbase.CellScanner;
import org.apache.hadoop.hbase.CompatibilityFactory;
import org.apache.hadoop.hbase.ExtendedCell;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.PrivateCellUtil;
@@ -43,9 +42,8 @@
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.RPCTests;
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;
import org.apache.hbase.thirdparty.com.google.common.collect.Lists;
import org.apache.hbase.thirdparty.com.google.protobuf.ServiceException;
@@ -54,13 +52,10 @@
import org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestProtos;
import org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestRpcServiceProtos;
-@Category({ RPCTests.class, MediumTests.class })
+@Tag(RPCTests.TAG)
+@Tag(MediumTests.TAG)
public class TestNettyChannelWritability {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestNettyChannelWritability.class);
-
private static final MetricsAssertHelper METRICS_ASSERT =
CompatibilityFactory.getInstance(MetricsAssertHelper.class);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestNettyIPCCloseConnection.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestNettyIPCCloseConnection.java
index e21ad286853b..d9f4dd96e94e 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestNettyIPCCloseConnection.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestNettyIPCCloseConnection.java
@@ -18,8 +18,8 @@
package org.apache.hadoop.hbase.ipc;
import static org.apache.hadoop.hbase.ipc.TestProtobufRpcServiceImpl.SERVICE;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -28,17 +28,15 @@
import java.net.InetSocketAddress;
import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.Waiter;
import org.apache.hadoop.hbase.security.HBaseSaslRpcServer;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.RPCTests;
-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.apache.hbase.thirdparty.com.google.common.collect.Iterators;
import org.apache.hbase.thirdparty.com.google.common.collect.Lists;
@@ -53,13 +51,10 @@
/**
* Confirm that we truly close the NettyRpcConnection when the netty channel is closed.
*/
-@Category({ RPCTests.class, MediumTests.class })
+@Tag(RPCTests.TAG)
+@Tag(MediumTests.TAG)
public class TestNettyIPCCloseConnection {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestNettyIPCCloseConnection.class);
-
private static Configuration CONF = HBaseConfiguration.create();
private NioEventLoopGroup group;
@@ -70,7 +65,7 @@ public class TestNettyIPCCloseConnection {
private TestProtobufRpcProto.BlockingInterface stub;
- @Before
+ @BeforeEach
public void setUp() throws IOException {
group = new NioEventLoopGroup();
server = new NettyRpcServer(null, getClass().getSimpleName(),
@@ -82,7 +77,7 @@ public void setUp() throws IOException {
stub = TestProtobufRpcServiceImpl.newBlockingStub(client, server.getListenerAddress());
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
Closeables.close(client, true);
server.stop();
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestNettyRpcServer.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestNettyRpcServer.java
index 2d5b95028f6f..5318e6828959 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestNettyRpcServer.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestNettyRpcServer.java
@@ -17,9 +17,9 @@
*/
package org.apache.hadoop.hbase.ipc;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -32,14 +32,13 @@
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.Arrays;
-import java.util.Collection;
+import java.util.stream.Stream;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLSession;
-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.TableNameTestRule;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
@@ -51,26 +50,20 @@
import org.apache.hadoop.hbase.testclassification.RPCTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.LoadTestKVGenerator;
-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.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.AfterEach;
+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.io.netty.handler.ssl.SslHandler;
-@Category({ RPCTests.class, MediumTests.class })
-@RunWith(Parameterized.class)
+@Tag(RPCTests.TAG)
+@Tag(MediumTests.TAG)
+@HBaseParameterizedTestTemplate(name = "{index}: allocatorType={0}")
public class TestNettyRpcServer {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestNettyRpcServer.class);
-
private static final byte[] FAMILY = Bytes.toBytes("f");
private static final byte[] QUALIFIER = Bytes.toBytes("q");
private static final int NUM_ROWS = 100;
@@ -78,21 +71,29 @@ public class TestNettyRpcServer {
private static final int MAX_LEN = 1000000;
protected static final LoadTestKVGenerator GENERATOR = new LoadTestKVGenerator(MIN_LEN, MAX_LEN);
protected static HBaseTestingUtil TEST_UTIL;
+ protected TableName tableName;
+ protected final String allocatorType;
- @Rule
- public TableNameTestRule name = new TableNameTestRule();
+ public TestNettyRpcServer(String allocatorType) {
+ this.allocatorType = allocatorType;
+ }
- @Parameterized.Parameter
- public String allocatorType;
+ public static Stream parameters() {
+ return Arrays
+ .stream(
+ new Object[] { NettyRpcServer.POOLED_ALLOCATOR_TYPE, NettyRpcServer.UNPOOLED_ALLOCATOR_TYPE,
+ NettyRpcServer.HEAP_ALLOCATOR_TYPE, SimpleByteBufAllocator.class.getName() })
+ .map(Arguments::of);
+ }
- @Parameters
- public static Collection parameters() {
- return Arrays.asList(new Object[][] { { NettyRpcServer.POOLED_ALLOCATOR_TYPE },
- { NettyRpcServer.UNPOOLED_ALLOCATOR_TYPE }, { NettyRpcServer.HEAP_ALLOCATOR_TYPE },
- { SimpleByteBufAllocator.class.getName() } });
+ @BeforeEach
+ public void setUpTable(TestInfo testInfo) {
+ String sanitizedAllocatorType = allocatorType.replaceAll("[^a-zA-Z0-9_.-]", "_");
+ tableName =
+ TableName.valueOf(testInfo.getTestMethod().get().getName() + "_" + sanitizedAllocatorType);
}
- @Before
+ @BeforeEach
public void setup() throws Exception {
// A subclass may have already created TEST_UTIL and is now upcalling to us
if (TEST_UTIL == null) {
@@ -104,14 +105,14 @@ public void setup() throws Exception {
TEST_UTIL.startMiniCluster();
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
- @Test
+ @TestTemplate
public void testNettyRpcServer() throws Exception {
- doTest(name.getTableName());
+ doTest(tableName);
}
protected void doTest(TableName tableName) throws Exception {
@@ -130,10 +131,10 @@ protected void doTest(TableName tableName) throws Exception {
for (int i = 0; i < NUM_ROWS; i++) {
final byte[] rowKey = Bytes.toBytes(LoadTestKVGenerator.md5PrefixedKey(i));
final Result r = table.get(new Get(rowKey).addColumn(FAMILY, QUALIFIER));
- assertNotNull("Result was empty", r);
+ assertNotNull(r, "Result was empty");
final byte[] v = r.getValue(FAMILY, QUALIFIER);
- assertNotNull("Result did not contain expected value", v);
- assertTrue("Value was not verified", LoadTestKVGenerator.verify(v, rowKey, QUALIFIER));
+ assertNotNull(v, "Result did not contain expected value");
+ assertTrue(LoadTestKVGenerator.verify(v, rowKey, QUALIFIER), "Value was not verified");
}
}
}
@@ -163,7 +164,7 @@ protected void doTest(TableName tableName) throws Exception {
+ "khS2d/JDZq2XL5RGexf3CA6YYzWiTr9YZHNjuobvLH7mVnA2c8n6Zty/UhfnuK1x\n" + "JbkleFk=\n"
+ "-----END CERTIFICATE-----";
- @Test
+ @TestTemplate
public void testHandshakeCompleteHandler()
throws SSLPeerUnverifiedException, CertificateException {
NettyServerRpcConnection conn = mock(NettyServerRpcConnection.class);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestProtoBufRpc.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestProtoBufRpc.java
index a9cac3d0e7b6..8fbb22e7f295 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestProtoBufRpc.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestProtoBufRpc.java
@@ -19,29 +19,25 @@
import static org.apache.hadoop.hbase.ipc.TestProtobufRpcServiceImpl.SERVICE;
import static org.apache.hadoop.hbase.ipc.TestProtobufRpcServiceImpl.newBlockingStub;
-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.assertThrows;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.Arrays;
-import java.util.Collection;
+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.HConstants;
import org.apache.hadoop.hbase.logging.Log4jUtils;
import org.apache.hadoop.hbase.testclassification.RPCTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
-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.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.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.TestTemplate;
+import org.junit.jupiter.params.provider.Arguments;
import org.apache.hbase.thirdparty.com.google.common.collect.Lists;
@@ -55,30 +51,29 @@
* of types in src/test/protobuf/test.proto and protobuf service definition from
* src/test/protobuf/test_rpc_service.proto
*/
-@RunWith(Parameterized.class)
-@Category({ RPCTests.class, SmallTests.class })
+@Tag(RPCTests.TAG)
+@Tag(SmallTests.TAG)
+@HBaseParameterizedTestTemplate(name = "{index}: rpcServerImpl={0}")
public class TestProtoBufRpc {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestProtoBufRpc.class);
-
public final static String ADDRESS = "localhost";
private static int PORT = 0;
private InetSocketAddress isa;
private Configuration conf;
private RpcServerInterface server;
+ private final String rpcServerImpl;
- @Parameters(name = "{index}: rpcServerImpl={0}")
- public static Collection parameters() {
- return Arrays.asList(new Object[] { SimpleRpcServer.class.getName() },
- new Object[] { NettyRpcServer.class.getName() });
+ public TestProtoBufRpc(String rpcServerImpl) {
+ this.rpcServerImpl = rpcServerImpl;
}
- @Parameter(0)
- public String rpcServerImpl;
+ public static Stream parameters() {
+ return Arrays
+ .stream(new Object[] { SimpleRpcServer.class.getName(), NettyRpcServer.class.getName() })
+ .map(Arguments::of);
+ }
- @Before
+ @BeforeEach
public void setUp() throws IOException { // Setup server for both protocols
this.conf = HBaseConfiguration.create();
this.conf.set(RpcServerFactory.CUSTOM_RPC_SERVER_IMPL_CONF_KEY, rpcServerImpl);
@@ -97,13 +92,12 @@ public void setUp() throws IOException { // Setup server for both protocols
this.server.start();
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
server.stop();
}
- @Test(expected = org.apache.hbase.thirdparty.com.google.protobuf.ServiceException.class
- /* Thrown when we call stub.error */)
+ @TestTemplate
public void testProtoBufRpc() throws Exception {
RpcClient rpcClient = RpcClientFactory.createClient(conf, HConstants.CLUSTER_ID_DEFAULT);
try {
@@ -117,8 +111,8 @@ public void testProtoBufRpc() throws Exception {
EchoResponseProto echoResponse = stub.echo(null, echoRequest);
assertEquals("hello", echoResponse.getMessage());
- stub.error(null, emptyRequest);
- fail("Expected exception is not thrown");
+ assertThrows(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException.class,
+ () -> stub.error(null, emptyRequest));
} finally {
rpcClient.close();
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRWQueueRpcExecutor.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRWQueueRpcExecutor.java
index 0008ea5f44d6..714956c5ddd0 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRWQueueRpcExecutor.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRWQueueRpcExecutor.java
@@ -21,38 +21,31 @@
import static org.apache.hadoop.hbase.ipc.RWQueueRpcExecutor.CALL_QUEUE_SCAN_SHARE_CONF_KEY;
import static org.apache.hadoop.hbase.ipc.RpcExecutor.CALL_QUEUE_HANDLER_FACTOR_CONF_KEY;
import static org.apache.hadoop.hbase.ipc.RpcExecutor.DEFAULT_CALL_QUEUE_SIZE_HARD_LIMIT;
-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.Mockito.mock;
import java.util.List;
import java.util.concurrent.BlockingQueue;
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.RPCTests;
-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.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
-@Category({ RPCTests.class, MediumTests.class })
+@Tag(RPCTests.TAG)
+@Tag(MediumTests.TAG)
public class TestRWQueueRpcExecutor {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRWQueueRpcExecutor.class);
-
- @Rule
- public TestName testName = new TestName();
-
private Configuration conf;
+ private String testMethodName;
- @Before
- public void setUp() {
+ @BeforeEach
+ public void setUp(TestInfo testInfo) {
+ testMethodName = testInfo.getTestMethod().get().getName();
conf = HBaseConfiguration.create();
conf.setFloat(CALL_QUEUE_HANDLER_FACTOR_CONF_KEY, 1.0f);
conf.setFloat(CALL_QUEUE_SCAN_SHARE_CONF_KEY, 0.5f);
@@ -63,8 +56,8 @@ public void setUp() {
public void itProvidesCorrectQueuesToBalancers() throws InterruptedException {
PriorityFunction qosFunction = mock(PriorityFunction.class);
int softQueueLimit = 100;
- RWQueueRpcExecutor executor = new RWQueueRpcExecutor(testName.getMethodName(), 100,
- softQueueLimit, qosFunction, conf, null);
+ RWQueueRpcExecutor executor =
+ new RWQueueRpcExecutor(testMethodName, 100, softQueueLimit, qosFunction, conf, null);
QueueBalancer readBalancer = executor.getReadBalancer();
QueueBalancer writeBalancer = executor.getWriteBalancer();
@@ -81,11 +74,11 @@ public void itProvidesCorrectQueuesToBalancers() throws InterruptedException {
assertEquals(25, readQueues.size());
assertEquals(50, writeQueues.size());
assertEquals(25, scanQueues.size());
- assertEquals("Soft limit is not applied properly", softQueueLimit, executor.currentQueueLimit);
+ assertEquals(softQueueLimit, executor.currentQueueLimit, "Soft limit is not applied properly");
// Hard Limit is applied as the max capacity of the queue
int hardQueueLimit = readQueues.get(0).remainingCapacity() + readQueues.get(0).size();
- assertEquals("Default hard limit should be applied ", DEFAULT_CALL_QUEUE_SIZE_HARD_LIMIT,
- hardQueueLimit);
+ assertEquals(DEFAULT_CALL_QUEUE_SIZE_HARD_LIMIT, hardQueueLimit,
+ "Default hard limit should be applied ");
verifyDistinct(readQueues, writeQueues, scanQueues);
verifyDistinct(writeQueues, readQueues, scanQueues);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRpcClientLeaks.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRpcClientLeaks.java
index feaf44e0b84e..922254b54781 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRpcClientLeaks.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRpcClientLeaks.java
@@ -18,8 +18,8 @@
package org.apache.hadoop.hbase.ipc;
import static org.apache.hadoop.hbase.HBaseTestingUtil.fam1;
-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.net.Socket;
@@ -28,7 +28,6 @@
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName;
@@ -40,26 +39,18 @@
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.testclassification.MediumTests;
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.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.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category(MediumTests.class)
+@Tag(MediumTests.TAG)
public class TestRpcClientLeaks {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRpcClientLeaks.class);
-
- @Rule
- public TestName name = new TestName();
-
private static BlockingQueue SAVED_SOCKETS = new LinkedBlockingQueue<>();
public static class MyRpcClientImpl extends BlockingRpcClient {
@@ -97,29 +88,35 @@ public static void enableThrowExceptions() {
}
private static final HBaseTestingUtil UTIL = new HBaseTestingUtil();
+ private String testMethodName;
- @BeforeClass
+ @BeforeAll
public static void setup() throws Exception {
UTIL.startMiniCluster();
}
- @AfterClass
+ @AfterAll
public static void teardown() throws Exception {
UTIL.shutdownMiniCluster();
}
public static final Logger LOG = LoggerFactory.getLogger(TestRpcClientLeaks.class);
+ @BeforeEach
+ public void setUpTest(TestInfo testInfo) {
+ testMethodName = testInfo.getTestMethod().get().getName();
+ }
+
@Test
public void testSocketClosed() throws IOException, InterruptedException {
- TableName tableName = TableName.valueOf(name.getMethodName());
+ TableName tableName = TableName.valueOf(testMethodName);
UTIL.createTable(tableName, fam1).close();
Configuration conf = new Configuration(UTIL.getConfiguration());
conf.set(RpcClientFactory.CUSTOM_RPC_CLIENT_IMPL_CONF_KEY, MyRpcClientImpl.class.getName());
conf.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 2);
try (Connection connection = ConnectionFactory.createConnection(conf);
- Table table = connection.getTable(TableName.valueOf(name.getMethodName()))) {
+ Table table = connection.getTable(TableName.valueOf(testMethodName))) {
MyRpcClientImpl.enableThrowExceptions();
table.get(new Get(Bytes.toBytes("asd")));
fail("Should fail because the injected error");
@@ -127,7 +124,7 @@ public void testSocketClosed() throws IOException, InterruptedException {
// expected
}
for (Socket socket : SAVED_SOCKETS) {
- assertTrue("Socket " + socket + " is not closed", socket.isClosed());
+ assertTrue(socket.isClosed(), "Socket " + socket + " is not closed");
}
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRpcHandlerException.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRpcHandlerException.java
index f240bf88e1b4..7d7e793ec280 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRpcHandlerException.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRpcHandlerException.java
@@ -24,21 +24,17 @@
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.Arrays;
-import java.util.Collection;
+import java.util.stream.Stream;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Abortable;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.HBaseParameterizedTestTemplate;
import org.apache.hadoop.hbase.ipc.RpcServer.BlockingServiceAndInterface;
import org.apache.hadoop.hbase.testclassification.RPCTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
-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.apache.hbase.thirdparty.com.google.common.collect.Lists;
import org.apache.hbase.thirdparty.com.google.protobuf.BlockingService;
@@ -46,15 +42,13 @@
import org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestProtos.EchoRequestProto;
import org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface;
-@RunWith(Parameterized.class)
-@Category({ RPCTests.class, SmallTests.class })
+@Tag(RPCTests.TAG)
+@Tag(SmallTests.TAG)
+@HBaseParameterizedTestTemplate(name = "{index}: rpcServerImpl={0}")
public class TestRpcHandlerException {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRpcHandlerException.class);
-
private final static Configuration CONF = HBaseConfiguration.create();
+ private final String rpcServerImpl;
/**
* Tests that the rpc scheduler is called when requests arrive. When Rpc handler thread dies, the
@@ -75,20 +69,21 @@ public boolean isAborted() {
}
}
- @Parameters(name = "{index}: rpcServerImpl={0}")
- public static Collection parameters() {
- return Arrays.asList(new Object[] { SimpleRpcServer.class.getName() },
- new Object[] { NettyRpcServer.class.getName() });
+ public TestRpcHandlerException(String rpcServerImpl) {
+ this.rpcServerImpl = rpcServerImpl;
}
- @Parameter(0)
- public String rpcServerImpl;
+ public static Stream parameters() {
+ return Arrays
+ .stream(new Object[] { SimpleRpcServer.class.getName(), NettyRpcServer.class.getName() })
+ .map(Arguments::of);
+ }
/*
* This is a unit test to make sure to abort region server when the number of Rpc handler thread
* caught errors exceeds the threshold. Client will hang when RS aborts.
*/
- @Test
+ @TestTemplate
public void testRpcScheduler() throws IOException, InterruptedException {
PriorityFunction qosFunction = mock(PriorityFunction.class);
Abortable abortable = new AbortServer();
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRpcMetrics.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRpcMetrics.java
index c55568d392ac..63b958d6f316 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRpcMetrics.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRpcMetrics.java
@@ -17,12 +17,11 @@
*/
package org.apache.hadoop.hbase.ipc;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.hadoop.hbase.CallDroppedException;
import org.apache.hadoop.hbase.CompatibilityFactory;
import org.apache.hadoop.hbase.DoNotRetryIOException;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.NotServingRegionException;
import org.apache.hadoop.hbase.RegionTooBusyException;
import org.apache.hadoop.hbase.ServerName;
@@ -32,17 +31,13 @@
import org.apache.hadoop.hbase.test.MetricsAssertHelper;
import org.apache.hadoop.hbase.testclassification.RPCTests;
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({ RPCTests.class, SmallTests.class })
+@Tag(RPCTests.TAG)
+@Tag(SmallTests.TAG)
public class TestRpcMetrics {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRpcMetrics.class);
-
public MetricsAssertHelper HELPER = CompatibilityFactory.getInstance(MetricsAssertHelper.class);
@Test
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRpcServerSlowConnectionSetup.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRpcServerSlowConnectionSetup.java
index 80b3845d6688..47aa414c34bc 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRpcServerSlowConnectionSetup.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRpcServerSlowConnectionSetup.java
@@ -18,7 +18,7 @@
package org.apache.hadoop.hbase.ipc;
import static org.apache.hadoop.hbase.ipc.TestProtobufRpcServiceImpl.SERVICE;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
@@ -27,25 +27,21 @@
import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.Arrays;
-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.HConstants;
import org.apache.hadoop.hbase.client.MetricsConnection;
import org.apache.hadoop.hbase.ipc.RpcServer.BlockingServiceAndInterface;
import org.apache.hadoop.hbase.security.AuthMethod;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.RPCTests;
-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.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.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.TestTemplate;
+import org.junit.jupiter.params.provider.Arguments;
import org.apache.hbase.thirdparty.com.google.common.collect.Lists;
@@ -58,28 +54,26 @@
import org.apache.hadoop.hbase.shaded.protobuf.generated.RPCProtos.RequestHeader;
import org.apache.hadoop.hbase.shaded.protobuf.generated.RPCProtos.ResponseHeader;
-@RunWith(Parameterized.class)
-@Category({ RPCTests.class, MediumTests.class })
+@Tag(RPCTests.TAG)
+@Tag(MediumTests.TAG)
+@HBaseParameterizedTestTemplate(name = "{index}: rpcServerImpl={0}")
public class TestRpcServerSlowConnectionSetup {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRpcServerSlowConnectionSetup.class);
-
private RpcServer server;
private Socket socket;
+ private final Class extends RpcServer> rpcServerImpl;
- @Parameter
- public Class extends RpcServer> rpcServerImpl;
+ public TestRpcServerSlowConnectionSetup(Class extends RpcServer> rpcServerImpl) {
+ this.rpcServerImpl = rpcServerImpl;
+ }
- @Parameters(name = "{index}: rpcServerImpl={0}")
- public static List params() {
- return Arrays.asList(new Object[] { SimpleRpcServer.class },
- new Object[] { NettyRpcServer.class });
+ public static Stream parameters() {
+ return Arrays.stream(new Object[] { SimpleRpcServer.class, NettyRpcServer.class })
+ .map(Arguments::of);
}
- @Before
+ @BeforeEach
public void setUp() throws IOException {
Configuration conf = HBaseConfiguration.create();
conf.set(RpcServerFactory.CUSTOM_RPC_SERVER_IMPL_CONF_KEY, rpcServerImpl.getName());
@@ -90,7 +84,7 @@ public void setUp() throws IOException {
socket = new Socket("localhost", server.getListenerAddress().getPort());
}
- @After
+ @AfterEach
public void tearDown() throws IOException {
if (socket != null) {
socket.close();
@@ -100,7 +94,7 @@ public void tearDown() throws IOException {
}
}
- @Test
+ @TestTemplate
public void test() throws IOException, InterruptedException {
int rpcHeaderLen = HConstants.RPC_HEADER.length;
byte[] preamble = new byte[rpcHeaderLen + 2];
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRpcServerTraceLogging.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRpcServerTraceLogging.java
index 0ae0ac51ffb2..df57673365de 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRpcServerTraceLogging.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRpcServerTraceLogging.java
@@ -17,26 +17,20 @@
*/
package org.apache.hadoop.hbase.ipc;
-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 org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.SmallTests;
-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.mockito.Mockito;
-@Category(SmallTests.class)
+@Tag(SmallTests.TAG)
public class TestRpcServerTraceLogging {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRpcServerTraceLogging.class);
-
private static final org.apache.logging.log4j.core.Logger rpcServerLog =
(org.apache.logging.log4j.core.Logger) org.apache.logging.log4j.LogManager
.getLogger(RpcServer.class);
@@ -54,7 +48,7 @@ public class TestRpcServerTraceLogging {
static final Configuration conf = new Configuration(false);
- @BeforeClass
+ @BeforeAll
public static void setUp() {
Mockito.when(mockRpcServer.getConf()).thenReturn(conf);
Mockito.when(mockRpcServer.truncateTraceLog(Mockito.any(String.class))).thenCallRealMethod();
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRpcSkipInitialSaslHandshake.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRpcSkipInitialSaslHandshake.java
index 345514396d6b..898017e11476 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRpcSkipInitialSaslHandshake.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestRpcSkipInitialSaslHandshake.java
@@ -23,15 +23,14 @@
import static org.apache.hadoop.hbase.security.HBaseKerberosUtils.getPrincipalForTesting;
import static org.apache.hadoop.hbase.security.HBaseKerberosUtils.loginKerberosPrincipal;
import static org.apache.hadoop.hbase.security.HBaseKerberosUtils.setSecuredConfiguration;
-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 java.io.File;
import java.net.InetSocketAddress;
import java.util.Collections;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.security.HBaseKerberosUtils;
@@ -41,12 +40,11 @@
import org.apache.hadoop.hbase.testclassification.RPCTests;
import org.apache.hadoop.minikdc.MiniKdc;
import org.apache.hadoop.security.UserGroupInformation;
-import org.junit.AfterClass;
-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.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.mockito.Mockito;
import org.apache.hbase.thirdparty.com.google.common.collect.Lists;
@@ -55,13 +53,10 @@
import org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestProtos;
import org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface;
-@Category({ RPCTests.class, MediumTests.class })
+@Tag(RPCTests.TAG)
+@Tag(MediumTests.TAG)
public class TestRpcSkipInitialSaslHandshake {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRpcSkipInitialSaslHandshake.class);
-
protected static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
protected static final File KEYTAB_FILE =
@@ -103,18 +98,18 @@ protected final void setUpPrincipalAndConf() throws Exception {
serverConf = new Configuration(TEST_UTIL.getConfiguration());
}
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
initKDCAndConf();
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
stopKDC();
TEST_UTIL.cleanupTestDir();
}
- @Before
+ @BeforeEach
public void setUpTest() throws Exception {
setUpPrincipalAndConf();
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestSecureNettyRpcServer.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestSecureNettyRpcServer.java
index 6cea79039677..da53150cee41 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestSecureNettyRpcServer.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestSecureNettyRpcServer.java
@@ -19,40 +19,42 @@
import java.io.File;
import java.security.PrivilegedExceptionAction;
+import java.util.stream.Stream;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeys;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HBaseParameterizedTestTemplate;
import org.apache.hadoop.hbase.HBaseTestingUtil;
-import org.apache.hadoop.hbase.TableNameTestRule;
import org.apache.hadoop.hbase.security.HBaseKerberosUtils;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.RPCTests;
import org.apache.hadoop.minikdc.MiniKdc;
import org.apache.hadoop.security.UserGroupInformation;
-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.TestTemplate;
+import org.junit.jupiter.params.provider.Arguments;
-@Category({ RPCTests.class, MediumTests.class })
+@Tag(RPCTests.TAG)
+@Tag(MediumTests.TAG)
+@HBaseParameterizedTestTemplate(name = "{index}: allocatorType={0}")
public class TestSecureNettyRpcServer extends TestNettyRpcServer {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestSecureNettyRpcServer.class);
-
private static File KEYTAB_FILE;
private static MiniKdc KDC;
private static String HOST = "localhost";
private static String PRINCIPAL;
private static UserGroupInformation UGI;
- @Rule
- public TableNameTestRule name = new TableNameTestRule();
+ public TestSecureNettyRpcServer(String allocatorType) {
+ super(allocatorType);
+ }
+
+ public static Stream parameters() {
+ return TestNettyRpcServer.parameters();
+ }
- @Before
+ @BeforeEach
public void setup() throws Exception {
TEST_UTIL = new HBaseTestingUtil();
KEYTAB_FILE = new File(TEST_UTIL.getDataTestDir("keytab").toUri().getPath());
@@ -67,7 +69,7 @@ public void setup() throws Exception {
super.setup();
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
if (KDC != null) {
KDC.stop();
@@ -78,12 +80,12 @@ public void tearDown() throws Exception {
}
@Override
- @Test
+ @TestTemplate
public void testNettyRpcServer() throws Exception {
UGI.doAs(new PrivilegedExceptionAction() {
@Override
public Void run() throws Exception {
- doTest(name.getTableName());
+ doTest(tableName);
return null;
}
});
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestSecureSimpleRpcServer.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestSecureSimpleRpcServer.java
index 7a3961f73c07..a63b84fa6e8e 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestSecureSimpleRpcServer.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestSecureSimpleRpcServer.java
@@ -21,27 +21,20 @@
import java.security.PrivilegedExceptionAction;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeys;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
-import org.apache.hadoop.hbase.TableNameTestRule;
import org.apache.hadoop.hbase.security.HBaseKerberosUtils;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.RPCTests;
import org.apache.hadoop.minikdc.MiniKdc;
import org.apache.hadoop.security.UserGroupInformation;
-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;
-@Category({ RPCTests.class, MediumTests.class })
-public class TestSecureSimpleRpcServer extends TestSimpleRpcServer {
-
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestSecureSimpleRpcServer.class);
+@Tag(RPCTests.TAG)
+@Tag(MediumTests.TAG)
+public class TestSecureSimpleRpcServer extends AbstractTestRpcServer {
private static File KEYTAB_FILE;
private static MiniKdc KDC;
@@ -49,10 +42,7 @@ public class TestSecureSimpleRpcServer extends TestSimpleRpcServer {
private static String PRINCIPAL;
private static UserGroupInformation UGI;
- @Rule
- public TableNameTestRule name = new TableNameTestRule();
-
- @BeforeClass
+ @BeforeAll
public static void setupClass() throws Exception {
TEST_UTIL = new HBaseTestingUtil();
KEYTAB_FILE = new File(TEST_UTIL.getDataTestDir("keytab").toUri().getPath());
@@ -64,27 +54,31 @@ public static void setupClass() throws Exception {
Configuration conf = TEST_UTIL.getConfiguration();
HBaseKerberosUtils.setSecuredConfiguration(conf, principalName, principalName);
UGI = login(KEYTAB_FILE.toString(), principalName);
- TestSimpleRpcServer.setupClass();
-
+ TEST_UTIL.getConfiguration().set(RpcServerFactory.CUSTOM_RPC_SERVER_IMPL_CONF_KEY,
+ SimpleRpcServer.class.getName());
+ TEST_UTIL.startMiniCluster();
}
- @AfterClass
+ @AfterAll
public static void tearDownClass() throws Exception {
if (KDC != null) {
KDC.stop();
}
- KEYTAB_FILE.delete();
- TestSimpleRpcServer.tearDownClass();
- TEST_UTIL.cleanupTestDir();
+ if (KEYTAB_FILE != null) {
+ KEYTAB_FILE.delete();
+ }
+ if (TEST_UTIL != null) {
+ TEST_UTIL.shutdownMiniCluster();
+ TEST_UTIL.cleanupTestDir();
+ }
}
- @Override
@Test
public void testSimpleRpcServer() throws Exception {
UGI.doAs(new PrivilegedExceptionAction() {
@Override
public Void run() throws Exception {
- doTest(name.getTableName());
+ doTest(tableName);
return null;
}
});
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestSecurityRpcSentBytesMetrics.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestSecurityRpcSentBytesMetrics.java
index a74477bf28c4..6e44dedfdca7 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestSecurityRpcSentBytesMetrics.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestSecurityRpcSentBytesMetrics.java
@@ -23,13 +23,12 @@
import static org.apache.hadoop.hbase.security.HBaseKerberosUtils.getPrincipalForTesting;
import static org.apache.hadoop.hbase.security.HBaseKerberosUtils.loginKerberosPrincipal;
import static org.apache.hadoop.hbase.security.HBaseKerberosUtils.setSecuredConfiguration;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.net.InetSocketAddress;
import java.util.Collections;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.security.HBaseKerberosUtils;
@@ -39,12 +38,11 @@
import org.apache.hadoop.hbase.testclassification.SecurityTests;
import org.apache.hadoop.minikdc.MiniKdc;
import org.apache.hadoop.security.UserGroupInformation;
-import org.junit.AfterClass;
-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.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.mockito.Mockito;
import org.apache.hbase.thirdparty.com.google.common.collect.Lists;
@@ -52,13 +50,10 @@
import org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestProtos;
import org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface;
-@Category({ SecurityTests.class, MediumTests.class })
+@Tag(SecurityTests.TAG)
+@Tag(MediumTests.TAG)
public class TestSecurityRpcSentBytesMetrics {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestSecurityRpcSentBytesMetrics.class);
-
protected static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
protected static final File KEYTAB_FILE =
@@ -100,18 +95,18 @@ protected final void setUpPrincipalAndConf() throws Exception {
setSecuredConfiguration(serverConf);
}
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
initKDCAndConf();
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
stopKDC();
TEST_UTIL.cleanupTestDir();
}
- @Before
+ @BeforeEach
public void setUpTest() throws Exception {
setUpPrincipalAndConf();
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestServerCall.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestServerCall.java
index b19169d3871c..fffe315bfbe7 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestServerCall.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestServerCall.java
@@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hbase.ipc;
-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 static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
@@ -29,16 +29,14 @@
import java.nio.ByteBuffer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.ExtendedCellScanner;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.codec.Codec;
import org.apache.hadoop.hbase.io.ByteBuffAllocator;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.RPCTests;
-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;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -52,13 +50,10 @@
/**
* Test for ServerCall IOException handling in setResponse method.
*/
-@Category({ RPCTests.class, MediumTests.class })
+@Tag(RPCTests.TAG)
+@Tag(MediumTests.TAG)
public class TestServerCall {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestServerCall.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestServerCall.class);
private Configuration conf;
@@ -71,7 +66,7 @@ public class TestServerCall {
private BlockingService mockService;
private MethodDescriptor mockMethodDescriptor;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
conf = HBaseConfiguration.create();
mockConnection = mock(NettyServerRpcConnection.class);
@@ -117,13 +112,13 @@ public void testSetResponseWithIOException() throws Exception {
// Verify that response is not null and contains error information
BufferChain response = call.getResponse();
- assertNotNull("Response should not be null even when IOException occurs", response);
- assertTrue("Call should be marked as error", call.isError);
+ assertNotNull(response, "Response should not be null even when IOException occurs");
+ assertTrue(call.isError, "Call should be marked as error");
// Verify the response buffer is valid
ByteBuffer[] bufs = response.getBuffers();
- assertNotNull("Response buffers should not be null", bufs);
- assertTrue("Response should have at least one buffer", bufs.length > 0);
+ assertNotNull(bufs, "Response buffers should not be null");
+ assertTrue(bufs.length > 0, "Response should have at least one buffer");
}
/**
@@ -146,7 +141,7 @@ public void testSetResponseWithDoubleIOException() throws Exception {
// Even if error response creation might fail, the call should still be marked as error
call.setResponse(mockResponse, mockCellScanner, null, null);
- assertTrue("Call should be marked as error", call.isError);
+ assertTrue(call.isError, "Call should be marked as error");
}
/**
@@ -168,7 +163,7 @@ public void testSetResponseNormalFlow() throws Exception {
call.setResponse(mockResponse, null, null, null);
BufferChain response = call.getResponse();
- assertNotNull("Response should not be null in normal flow", response);
- assertTrue("Call should not be marked as error in normal flow", !call.isError);
+ assertNotNull(response, "Response should not be null in normal flow");
+ assertTrue(!call.isError, "Call should not be marked as error in normal flow");
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestSimpleRpcScheduler.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestSimpleRpcScheduler.java
index eed7d98d7358..dd95d33b7ba0 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestSimpleRpcScheduler.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestSimpleRpcScheduler.java
@@ -17,11 +17,11 @@
*/
package org.apache.hadoop.hbase.ipc;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-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.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+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.eq;
import static org.mockito.Mockito.doAnswer;
@@ -43,7 +43,6 @@
import java.util.concurrent.LinkedBlockingQueue;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Abortable;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.client.Put;
@@ -55,12 +54,10 @@
import org.apache.hadoop.hbase.util.EnvironmentEdge;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.Threads;
-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.BeforeEach;
+import org.junit.jupiter.api.Tag;
+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;
@@ -77,16 +74,10 @@
import org.apache.hadoop.hbase.shaded.protobuf.generated.RPCProtos;
import org.apache.hadoop.hbase.shaded.protobuf.generated.RPCProtos.RequestHeader;
-@Category({ RPCTests.class, MediumTests.class })
+@Tag(RPCTests.TAG)
+@Tag(MediumTests.TAG)
public class TestSimpleRpcScheduler {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestSimpleRpcScheduler.class);
-
- @Rule
- public TestName testName = new TestName();
-
private static final Logger LOG = LoggerFactory.getLogger(TestSimpleRpcScheduler.class);
private final RpcScheduler.Context CONTEXT = new RpcScheduler.Context() {
@@ -96,9 +87,11 @@ public InetSocketAddress getListenerAddress() {
}
};
private Configuration conf;
+ private String testMethodName;
- @Before
- public void setUp() {
+ @BeforeEach
+ public void setUp(TestInfo testInfo) {
+ testMethodName = testInfo.getTestMethod().get().getName();
conf = HBaseConfiguration.create();
}
@@ -651,8 +644,8 @@ public void testCoDelScheduling() throws Exception {
// make sure fast calls are handled
waitUntilQueueEmpty(scheduler);
Thread.sleep(100);
- assertEquals("None of these calls should have been discarded", 0,
- scheduler.getNumGeneralCallsDropped());
+ assertEquals(0, scheduler.getNumGeneralCallsDropped(),
+ "None of these calls should have been discarded");
envEdge.offset = 151;
// calls slower than min delay, but not individually slow enough to be dropped
@@ -666,8 +659,8 @@ public void testCoDelScheduling() throws Exception {
// make sure somewhat slow calls are handled
waitUntilQueueEmpty(scheduler);
Thread.sleep(100);
- assertEquals("None of these calls should have been discarded", 0,
- scheduler.getNumGeneralCallsDropped());
+ assertEquals(0, scheduler.getNumGeneralCallsDropped(),
+ "None of these calls should have been discarded");
envEdge.offset = 2000;
// now slow calls and the ones to be dropped
@@ -681,8 +674,9 @@ public void testCoDelScheduling() throws Exception {
// make sure somewhat slow calls are handled
waitUntilQueueEmpty(scheduler);
Thread.sleep(100);
- assertTrue("There should have been at least 12 calls dropped however there were "
- + scheduler.getNumGeneralCallsDropped(), scheduler.getNumGeneralCallsDropped() > 12);
+ assertTrue(scheduler.getNumGeneralCallsDropped() > 12,
+ "There should have been at least 12 calls dropped however there were "
+ + scheduler.getNumGeneralCallsDropped());
} finally {
scheduler.stop();
}
@@ -690,7 +684,7 @@ public void testCoDelScheduling() throws Exception {
@Test
public void testFastPathBalancedQueueRpcExecutorWithQueueLength0() throws Exception {
- String name = testName.getMethodName();
+ String name = testMethodName;
int handlerCount = 1;
String callQueueType = RpcExecutor.CALL_QUEUE_TYPE_CODEL_CONF_VALUE;
int maxQueueLength = 0;
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestSimpleRpcServer.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestSimpleRpcServer.java
index f2420e028b1a..fb7fe783b607 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestSimpleRpcServer.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestSimpleRpcServer.java
@@ -17,53 +17,22 @@
*/
package org.apache.hadoop.hbase.ipc;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-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.client.Get;
-import org.apache.hadoop.hbase.client.Put;
-import org.apache.hadoop.hbase.client.Result;
-import org.apache.hadoop.hbase.client.Table;
-import org.apache.hadoop.hbase.client.TableDescriptor;
-import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
-import org.apache.hadoop.hbase.regionserver.DisabledRegionSplitPolicy;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.RPCTests;
-import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.hadoop.hbase.util.LoadTestKVGenerator;
-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;
-
-@Category({ RPCTests.class, MediumTests.class })
-public class TestSimpleRpcServer {
-
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestSimpleRpcServer.class);
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
- private static final byte[] FAMILY = Bytes.toBytes("f");
- private static final byte[] QUALIFIER = Bytes.toBytes("q");
- private static final int NUM_ROWS = 100;
- private static final int MIN_LEN = 1000;
- private static final int MAX_LEN = 1000000;
- protected static final LoadTestKVGenerator GENERATOR = new LoadTestKVGenerator(MIN_LEN, MAX_LEN);
- protected static HBaseTestingUtil TEST_UTIL;
-
- @Rule
- public TableNameTestRule name = new TableNameTestRule();
+@Tag(RPCTests.TAG)
+@Tag(MediumTests.TAG)
+public class TestSimpleRpcServer extends AbstractTestRpcServer {
@SuppressWarnings("deprecation")
- @BeforeClass
+ @BeforeAll
public static void setupClass() throws Exception {
- // A subclass may have already created TEST_UTIL and is now upcalling to us
+ // Reuse TEST_UTIL if the test already initialized it.
if (TEST_UTIL == null) {
TEST_UTIL = new HBaseTestingUtil();
}
@@ -73,38 +42,15 @@ public static void setupClass() throws Exception {
TEST_UTIL.startMiniCluster();
}
- @AfterClass
+ @AfterAll
public static void tearDownClass() throws Exception {
- TEST_UTIL.shutdownMiniCluster();
+ if (TEST_UTIL != null) {
+ TEST_UTIL.shutdownMiniCluster();
+ }
}
@Test
public void testSimpleRpcServer() throws Exception {
- doTest(name.getTableName());
+ doTest(tableName);
}
-
- protected void doTest(TableName tableName) throws Exception {
- // Splitting just complicates the test scenario, disable it
- final TableDescriptor desc = TableDescriptorBuilder.newBuilder(tableName)
- .setRegionSplitPolicyClassName(DisabledRegionSplitPolicy.class.getName()).build();
- try (Table table =
- TEST_UTIL.createTable(desc, new byte[][] { FAMILY }, TEST_UTIL.getConfiguration())) {
- // put some test data
- for (int i = 0; i < NUM_ROWS; i++) {
- final byte[] rowKey = Bytes.toBytes(LoadTestKVGenerator.md5PrefixedKey(i));
- final byte[] v = GENERATOR.generateRandomSizeValue(rowKey, QUALIFIER);
- table.put(new Put(rowKey).addColumn(FAMILY, QUALIFIER, v));
- }
- // read to verify it.
- for (int i = 0; i < NUM_ROWS; i++) {
- final byte[] rowKey = Bytes.toBytes(LoadTestKVGenerator.md5PrefixedKey(i));
- final Result r = table.get(new Get(rowKey).addColumn(FAMILY, QUALIFIER));
- assertNotNull("Result was empty", r);
- final byte[] v = r.getValue(FAMILY, QUALIFIER);
- assertNotNull("Result did not contain expected value", v);
- assertTrue("Value was not verified", LoadTestKVGenerator.verify(v, rowKey, QUALIFIER));
- }
- }
- }
-
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/MobTestUtil.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/MobTestUtil.java
index 08e7a4bbcf78..3e2840f984b6 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/MobTestUtil.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/MobTestUtil.java
@@ -17,6 +17,9 @@
*/
package org.apache.hadoop.hbase.mob;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
import java.io.IOException;
import java.util.Date;
import java.util.List;
@@ -41,7 +44,6 @@
import org.apache.hadoop.hbase.regionserver.StoreFileWriter;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
-import org.junit.Assert;
public class MobTestUtil {
protected static final char FIRST_CHAR = 'a';
@@ -85,13 +87,11 @@ private static void writeStoreFile(final StoreFileWriter writer, byte[] fam, byt
* Compare two Cells only for their row family qualifier value
*/
public static void assertCellEquals(Cell firstKeyValue, Cell secondKeyValue) {
- Assert.assertArrayEquals(CellUtil.cloneRow(firstKeyValue), CellUtil.cloneRow(secondKeyValue));
- Assert.assertArrayEquals(CellUtil.cloneFamily(firstKeyValue),
- CellUtil.cloneFamily(secondKeyValue));
- Assert.assertArrayEquals(CellUtil.cloneQualifier(firstKeyValue),
+ assertArrayEquals(CellUtil.cloneRow(firstKeyValue), CellUtil.cloneRow(secondKeyValue));
+ assertArrayEquals(CellUtil.cloneFamily(firstKeyValue), CellUtil.cloneFamily(secondKeyValue));
+ assertArrayEquals(CellUtil.cloneQualifier(firstKeyValue),
CellUtil.cloneQualifier(secondKeyValue));
- Assert.assertArrayEquals(CellUtil.cloneValue(firstKeyValue),
- CellUtil.cloneValue(secondKeyValue));
+ assertArrayEquals(CellUtil.cloneValue(firstKeyValue), CellUtil.cloneValue(secondKeyValue));
}
public static void assertCellsValue(Table table, Scan scan, byte[] expectedValue,
@@ -102,12 +102,12 @@ public static void assertCellsValue(Table table, Scan scan, byte[] expectedValue
List cells = res.listCells();
for (Cell cell : cells) {
// Verify the value
- Assert.assertArrayEquals(expectedValue, CellUtil.cloneValue(cell));
+ assertArrayEquals(expectedValue, CellUtil.cloneValue(cell));
count++;
}
}
results.close();
- Assert.assertEquals(expectedCount, count);
+ assertEquals(expectedCount, count);
}
/**
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestCachedMobFile.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestCachedMobFile.java
index 32a2a1defdba..1c1fdfb373c7 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestCachedMobFile.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestCachedMobFile.java
@@ -17,13 +17,13 @@
*/
package org.apache.hadoop.hbase.mob;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.KeyValue.Type;
@@ -36,22 +36,15 @@
import org.apache.hadoop.hbase.regionserver.StoreFileWriter;
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.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TestName;
+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(SmallTests.class)
+@Tag(SmallTests.TAG)
public class TestCachedMobFile {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestCachedMobFile.class);
-
static final Logger LOG = LoggerFactory.getLogger(TestCachedMobFile.class);
private static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
private Configuration conf = TEST_UTIL.getConfiguration();
@@ -61,12 +54,10 @@ public class TestCachedMobFile {
private static final long EXPECTED_REFERENCE_ZERO = 0;
private static final long EXPECTED_REFERENCE_ONE = 1;
private static final long EXPECTED_REFERENCE_TWO = 2;
- @Rule
- public TestName testName = new TestName();
@Test
- public void testOpenClose() throws Exception {
- String caseName = testName.getMethodName();
+ public void testOpenClose(TestInfo testInfo) throws Exception {
+ String caseName = testInfo.getTestMethod().get().getName();
Path testDir = TEST_UTIL.getDataTestDir();
FileSystem fs = testDir.getFileSystem(conf);
HFileContext meta = new HFileContextBuilder().withBlockSize(8 * 1024).build();
@@ -90,8 +81,8 @@ public void testOpenClose() throws Exception {
@SuppressWarnings("SelfComparison")
@Test
- public void testCompare() throws Exception {
- String caseName = testName.getMethodName();
+ public void testCompare(TestInfo testInfo) throws Exception {
+ String caseName = testInfo.getTestMethod().get().getName();
Path testDir = TEST_UTIL.getDataTestDir();
FileSystem fs = testDir.getFileSystem(conf);
Path outputDir1 = new Path(testDir, FAMILY1);
@@ -119,13 +110,13 @@ public void testCompare() throws Exception {
}
@Test
- public void testReadKeyValue() throws Exception {
+ public void testReadKeyValue(TestInfo testInfo) throws Exception {
Path testDir = TEST_UTIL.getDataTestDir();
FileSystem fs = testDir.getFileSystem(conf);
HFileContext meta = new HFileContextBuilder().withBlockSize(8 * 1024).build();
StoreFileWriter writer = new StoreFileWriter.Builder(conf, cacheConf, fs).withOutputDir(testDir)
.withFileContext(meta).build();
- String caseName = testName.getMethodName();
+ String caseName = testInfo.getTestMethod().get().getName();
MobTestUtil.writeStoreFile(writer, caseName);
StoreFileInfo storeFileInfo =
StoreFileInfo.createStoreFileInfoForHFile(conf, fs, writer.getPath(), true);
@@ -165,6 +156,6 @@ public void testReadKeyValue() throws Exception {
// Test the key which is more than the end key
byte[] upperKey = Bytes.toBytes("z{"); // Bigger than "zz"
seekKey = new KeyValue(upperKey, family, qualify, Long.MAX_VALUE, Type.Put, upperKey);
- Assert.assertNull(cachedMobFile.readCell(seekKey, false));
+ assertNull(cachedMobFile.readCell(seekKey, false));
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestDefaultMobStoreFlusher.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestDefaultMobStoreFlusher.java
index 6b7ec952d05d..2f662129f32a 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestDefaultMobStoreFlusher.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestDefaultMobStoreFlusher.java
@@ -17,12 +17,14 @@
*/
package org.apache.hadoop.hbase.mob;
-import java.util.Arrays;
-import java.util.Collection;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
import java.util.List;
+import java.util.stream.Stream;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
-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;
@@ -36,25 +38,17 @@
import org.apache.hadoop.hbase.regionserver.storefiletracker.StoreFileTrackerFactory;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TestName;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
-@RunWith(Parameterized.class)
-@Category(LargeTests.class)
+import org.junit.jupiter.api.AfterEach;
+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;
+
+@Tag(LargeTests.TAG)
+@HBaseParameterizedTestTemplate(name = "{index}: useFileBasedSFT={0}")
public class TestDefaultMobStoreFlusher {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestDefaultMobStoreFlusher.class);
-
private final static HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
private final static byte[] row1 = Bytes.toBytes("row1");
private final static byte[] row2 = Bytes.toBytes("row2");
@@ -64,8 +58,7 @@ public class TestDefaultMobStoreFlusher {
private final static byte[] value1 = Bytes.toBytes("value1");
private final static byte[] value2 = Bytes.toBytes("value2");
- @Rule
- public TestName name = new TestName();
+ private String testMethodName;
protected Boolean useFileBasedSFT;
@@ -73,14 +66,14 @@ public TestDefaultMobStoreFlusher(Boolean useFileBasedSFT) {
this.useFileBasedSFT = useFileBasedSFT;
}
- @Parameterized.Parameters
- public static Collection data() {
- Boolean[] data = { false, true };
- return Arrays.asList(data);
+ public static Stream parameters() {
+ return Stream.of(false, true).map(Arguments::of);
}
- @Before
- public void setUpBefore() throws Exception {
+ @BeforeEach
+ public void setUpBefore(TestInfo testInfo) throws Exception {
+ testMethodName = testInfo.getTestMethod().get().getName()
+ + testInfo.getDisplayName().replaceAll("[:= ]", "_").replaceAll("_+", "_").trim();
if (useFileBasedSFT) {
TEST_UTIL.getConfiguration().set(StoreFileTrackerFactory.TRACKER_IMPL,
"org.apache.hadoop.hbase.regionserver.storefiletracker.FileBasedStoreFileTracker");
@@ -88,23 +81,23 @@ public void setUpBefore() throws Exception {
TEST_UTIL.startMiniCluster(1);
}
- @After
+ @AfterEach
public void tearDownAfter() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
- @Test
+ @TestTemplate
public void testFlushNonMobFile() throws Exception {
- final TableName tableName = TableName.valueOf(TestMobUtils.getTableName(name));
+ final TableName tableName = TableName.valueOf(TestMobUtils.getTableName(testMethodName));
TableDescriptor tableDescriptor = TableDescriptorBuilder.newBuilder(tableName)
.setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(family).setMaxVersions(4).build())
.build();
testFlushFile(tableDescriptor);
}
- @Test
+ @TestTemplate
public void testFlushMobFile() throws Exception {
- final TableName tableName = TableName.valueOf(TestMobUtils.getTableName(name));
+ final TableName tableName = TableName.valueOf(TestMobUtils.getTableName(testMethodName));
TableDescriptor tableDescriptor = TableDescriptorBuilder.newBuilder(tableName)
.setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(family).setMobEnabled(true)
.setMobThreshold(3L).setMaxVersions(4).build())
@@ -142,12 +135,12 @@ private void testFlushFile(TableDescriptor tableDescriptor) throws Exception {
size++;
List cells = result.getColumnCells(family, qf1);
// Verify the cell size
- Assert.assertEquals(1, cells.size());
+ assertEquals(1, cells.size());
// Verify the value
- Assert.assertArrayEquals(value1, CellUtil.cloneValue(cells.get(0)));
+ assertArrayEquals(value1, CellUtil.cloneValue(cells.get(0)));
}
scanner.close();
- Assert.assertEquals(1, size);
+ assertEquals(1, size);
} finally {
table.close();
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestExpiredMobFileCleaner.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestExpiredMobFileCleaner.java
index 17dc3d32cf94..acb4ac2cec56 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestExpiredMobFileCleaner.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestExpiredMobFileCleaner.java
@@ -18,11 +18,10 @@
package org.apache.hadoop.hbase.mob;
import static org.apache.hadoop.hbase.mob.MobConstants.MOB_CLEANER_BATCH_SIZE_UPPER_BOUND;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.hadoop.fs.FileStatus;
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.client.Admin;
@@ -37,23 +36,18 @@
import org.apache.hadoop.hbase.util.CommonFSUtils;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.util.ToolRunner;
-import org.junit.After;
-import org.junit.AfterClass;
-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.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.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category(MediumTests.class)
+@Tag(MediumTests.TAG)
public class TestExpiredMobFileCleaner {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestExpiredMobFileCleaner.class);
-
private final static HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
private final static TableName tableName = TableName.valueOf("TestExpiredMobFileCleaner");
private final static String family = "family";
@@ -66,23 +60,23 @@ public class TestExpiredMobFileCleaner {
private static BufferedMutator table;
private static Admin admin;
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
TEST_UTIL.getConfiguration().setInt("hfile.format.version", 3);
TEST_UTIL.getConfiguration().setInt(MOB_CLEANER_BATCH_SIZE_UPPER_BOUND, 2);
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() throws Exception {
}
- @Before
+ @BeforeEach
public void setUp() throws Exception {
TEST_UTIL.startMiniCluster(1);
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
admin.disableTable(tableName);
admin.deleteTable(tableName);
@@ -144,7 +138,7 @@ public void testCleaner() throws Exception {
TEST_UTIL.getDefaultRootDirPath(), LOG);
FileStatus[] firstFiles = TEST_UTIL.getTestFileSystem().listStatus(mobDirPath);
// the first mob file
- assertEquals("Before cleanup without delay 1", 1, firstFiles.length);
+ assertEquals(1, firstFiles.length, "Before cleanup without delay 1");
String firstFile = firstFiles[0].getPath().getName();
// 1.5 day before
@@ -152,7 +146,7 @@ public void testCleaner() throws Exception {
putKVAndFlush(table, row2, dummyData, ts);
FileStatus[] secondFiles = TEST_UTIL.getTestFileSystem().listStatus(mobDirPath);
// now there are 2 mob files
- assertEquals("Before cleanup without delay 2", 2, secondFiles.length);
+ assertEquals(2, secondFiles.length, "Before cleanup without delay 2");
String f1 = secondFiles[0].getPath().getName();
String f2 = secondFiles[1].getPath().getName();
String secondFile = f1.equals(firstFile) ? f2 : f1;
@@ -163,7 +157,7 @@ public void testCleaner() throws Exception {
putKVAndFlush(table, row3, dummyData, ts);
FileStatus[] thirdFiles = TEST_UTIL.getTestFileSystem().listStatus(mobDirPath);
// now there are 4 mob files
- assertEquals("Before cleanup without delay 3", 4, thirdFiles.length);
+ assertEquals(4, thirdFiles.length, "Before cleanup without delay 3");
modifyColumnExpiryDays(2); // ttl = 2, make the first row expired
@@ -176,8 +170,8 @@ public void testCleaner() throws Exception {
FileStatus[] filesAfterClean = TEST_UTIL.getTestFileSystem().listStatus(mobDirPath);
String lastFile = filesAfterClean[0].getPath().getName();
// there are 4 mob files in total, but only 3 need to be cleaned
- assertEquals("After cleanup without delay 1", 1, filesAfterClean.length);
- assertEquals("After cleanup without delay 2", secondFile, lastFile);
+ assertEquals(1, filesAfterClean.length, "After cleanup without delay 1");
+ assertEquals(secondFile, lastFile, "After cleanup without delay 2");
}
private int secondsOfDay() {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestExpiredMobFileCleanerChore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestExpiredMobFileCleanerChore.java
index 9ec87fe94c13..b8ca3a687efa 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestExpiredMobFileCleanerChore.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestExpiredMobFileCleanerChore.java
@@ -19,12 +19,11 @@
import static org.apache.hadoop.hbase.mob.MobConstants.MOB_CLEANER_BATCH_SIZE_UPPER_BOUND;
import static org.apache.hadoop.hbase.mob.MobConstants.MOB_CLEANER_THREAD_COUNT;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
import org.apache.hadoop.fs.FileStatus;
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.client.Admin;
@@ -38,20 +37,15 @@
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-@Category({ MediumTests.class, MasterTests.class })
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
+@Tag(MediumTests.TAG)
+@Tag(MasterTests.TAG)
public class TestExpiredMobFileCleanerChore {
-
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestExpiredMobFileCleanerChore.class);
private final static HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
private final static TableName tableName = TableName.valueOf("TestExpiredMobFileCleaner");
private final static TableName tableName2 = TableName.valueOf("TestExpiredMobFileCleaner2");
@@ -66,7 +60,7 @@ public class TestExpiredMobFileCleanerChore {
private static BufferedMutator table2;
private static MobFileCleanerChore mobFileCleanerChore;
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
TEST_UTIL.getConfiguration().setInt("hfile.format.version", 3);
TEST_UTIL.getConfiguration().setInt(MOB_CLEANER_BATCH_SIZE_UPPER_BOUND, 2);
@@ -74,7 +68,7 @@ public static void setUp() throws Exception {
mobFileCleanerChore = TEST_UTIL.getMiniHBaseCluster().getMaster().getMobFileCleanerChore();
}
- @After
+ @AfterEach
public void cleanUp() throws IOException {
admin.disableTable(tableName);
admin.deleteTable(tableName);
@@ -83,7 +77,7 @@ public void cleanUp() throws IOException {
admin.close();
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
TEST_UTIL.shutdownMiniCluster();
TEST_UTIL.getTestFileSystem().delete(TEST_UTIL.getDataTestDir(), true);
@@ -94,7 +88,7 @@ public void testCleanerSingleThread() throws Exception {
TEST_UTIL.getConfiguration().setInt(MOB_CLEANER_THREAD_COUNT, 1);
mobFileCleanerChore.onConfigurationChange(TEST_UTIL.getConfiguration());
int corePoolSize = mobFileCleanerChore.getExecutor().getCorePoolSize();
- Assert.assertEquals(1, corePoolSize);
+ assertEquals(1, corePoolSize);
testCleanerInternal();
}
@@ -103,7 +97,7 @@ public void testCleanerMultiThread() throws Exception {
TEST_UTIL.getConfiguration().setInt(MOB_CLEANER_THREAD_COUNT, 2);
mobFileCleanerChore.onConfigurationChange(TEST_UTIL.getConfiguration());
int corePoolSize = mobFileCleanerChore.getExecutor().getCorePoolSize();
- Assert.assertEquals(2, corePoolSize);
+ assertEquals(2, corePoolSize);
testCleanerInternal();
}
@@ -174,7 +168,7 @@ private static void testCleanerInternal() throws Exception {
putKVAndFlush(table, row1, dummyData, ts, tableName);
FileStatus[] firstFiles = TEST_UTIL.getTestFileSystem().listStatus(mobDirPath);
// the first mob file
- assertEquals("Before cleanup without delay 1", 1, firstFiles.length);
+ assertEquals(1, firstFiles.length, "Before cleanup without delay 1");
String firstFile = firstFiles[0].getPath().getName();
// 1.5 day before
@@ -182,7 +176,7 @@ private static void testCleanerInternal() throws Exception {
putKVAndFlush(table, row2, dummyData, ts, tableName);
FileStatus[] secondFiles = TEST_UTIL.getTestFileSystem().listStatus(mobDirPath);
// now there are 2 mob files
- assertEquals("Before cleanup without delay 2", 2, secondFiles.length);
+ assertEquals(2, secondFiles.length, "Before cleanup without delay 2");
String f1 = secondFiles[0].getPath().getName();
String f2 = secondFiles[1].getPath().getName();
String secondFile = f1.equals(firstFile) ? f2 : f1;
@@ -193,7 +187,7 @@ private static void testCleanerInternal() throws Exception {
putKVAndFlush(table, row3, dummyData, ts, tableName);
FileStatus[] thirdFiles = TEST_UTIL.getTestFileSystem().listStatus(mobDirPath);
// now there are 4 mob files
- assertEquals("Before cleanup without delay 3", 4, thirdFiles.length);
+ assertEquals(4, thirdFiles.length, "Before cleanup without delay 3");
// modifyColumnExpiryDays(2); // ttl = 2, make the first row expired
@@ -205,7 +199,7 @@ private static void testCleanerInternal() throws Exception {
putKVAndFlush(table2, row1, dummyData2, ts, tableName2);
FileStatus[] firstFiles2 = TEST_UTIL.getTestFileSystem().listStatus(mobDirPath2);
// the first mob file
- assertEquals("Before cleanup without delay 1", 1, firstFiles2.length);
+ assertEquals(1, firstFiles2.length, "Before cleanup without delay 1");
String firstFile2 = firstFiles2[0].getPath().getName();
// 1.5 day before
@@ -213,7 +207,7 @@ private static void testCleanerInternal() throws Exception {
putKVAndFlush(table2, row2, dummyData2, ts, tableName2);
FileStatus[] secondFiles2 = TEST_UTIL.getTestFileSystem().listStatus(mobDirPath2);
// now there are 2 mob files
- assertEquals("Before cleanup without delay 2", 2, secondFiles2.length);
+ assertEquals(2, secondFiles2.length, "Before cleanup without delay 2");
String f1Second = secondFiles2[0].getPath().getName();
String f2Second = secondFiles2[1].getPath().getName();
String secondFile2 = f1Second.equals(firstFile2) ? f2Second : f1Second;
@@ -223,7 +217,7 @@ private static void testCleanerInternal() throws Exception {
putKVAndFlush(table2, row3, dummyData2, ts, tableName2);
FileStatus[] thirdFiles2 = TEST_UTIL.getTestFileSystem().listStatus(mobDirPath2);
// now there are 4 mob files
- assertEquals("Before cleanup without delay 3", 4, thirdFiles2.length);
+ assertEquals(4, thirdFiles2.length, "Before cleanup without delay 3");
modifyColumnExpiryDays(2); // ttl = 2, make the first row expired
@@ -233,14 +227,14 @@ private static void testCleanerInternal() throws Exception {
FileStatus[] filesAfterClean = TEST_UTIL.getTestFileSystem().listStatus(mobDirPath);
String lastFile = filesAfterClean[0].getPath().getName();
// there are 4 mob files in total, but only 3 need to be cleaned
- assertEquals("After cleanup without delay 1", 1, filesAfterClean.length);
- assertEquals("After cleanup without delay 2", secondFile, lastFile);
+ assertEquals(1, filesAfterClean.length, "After cleanup without delay 1");
+ assertEquals(secondFile, lastFile, "After cleanup without delay 2");
filesAfterClean = TEST_UTIL.getTestFileSystem().listStatus(mobDirPath2);
lastFile = filesAfterClean[0].getPath().getName();
// there are 4 mob files in total, but only 3 need to be cleaned
- assertEquals("After cleanup without delay 1", 1, filesAfterClean.length);
- assertEquals("After cleanup without delay 2", secondFile2, lastFile);
+ assertEquals(1, filesAfterClean.length, "After cleanup without delay 1");
+ assertEquals(secondFile2, lastFile, "After cleanup without delay 2");
}
private static int secondsOfDay() {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobCompactionOptMode.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobCompactionOptMode.java
index 1c586bbd10c7..a87482f56b6b 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobCompactionOptMode.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobCompactionOptMode.java
@@ -17,10 +17,9 @@
*/
package org.apache.hadoop.hbase.mob;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HBaseParameterizedTestTemplate;
import org.apache.hadoop.hbase.testclassification.LargeTests;
-import org.junit.ClassRule;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
/**
* Mob file compaction chore in a generational non-batch mode test. 1. Uses default (non-batch) mode
@@ -32,13 +31,10 @@
* than minimum age to archive 10. Runs Mob cleaner chore 11 Verifies that number of MOB files in a
* mob directory is 20. 12 Runs scanner and checks all 3 * 1000 rows.
*/
-@Category(LargeTests.class)
+@Tag(LargeTests.TAG)
+@HBaseParameterizedTestTemplate(name = "{index}: useFileBasedSFT={0}")
public class TestMobCompactionOptMode extends TestMobCompactionWithDefaults {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMobCompactionOptMode.class);
-
public TestMobCompactionOptMode(Boolean useFileBasedSFT) {
super(useFileBasedSFT);
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobCompactionOptRegionBatchMode.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobCompactionOptRegionBatchMode.java
index dfd6435d3642..3b3857b6001f 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobCompactionOptRegionBatchMode.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobCompactionOptRegionBatchMode.java
@@ -18,15 +18,13 @@
package org.apache.hadoop.hbase.mob;
import java.io.IOException;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HBaseParameterizedTestTemplate;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor;
import org.apache.hadoop.hbase.client.TableDescriptor;
import org.apache.hadoop.hbase.testclassification.LargeTests;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.experimental.categories.Category;
-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.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -40,14 +38,11 @@
* time larger than minimum age to archive 10. Runs Mob cleaner chore 11 Verifies that number of MOB
* files in a mob directory is 20. 12 Runs scanner and checks all 3 * 1000 rows.
*/
-@RunWith(Parameterized.class)
-@Category(LargeTests.class)
+@Tag(LargeTests.TAG)
+@HBaseParameterizedTestTemplate(name = "{index}: useFileBasedSFT={0}")
public class TestMobCompactionOptRegionBatchMode extends TestMobCompactionWithDefaults {
private static final Logger LOG =
LoggerFactory.getLogger(TestMobCompactionOptRegionBatchMode.class);
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMobCompactionOptRegionBatchMode.class);
private static final int batchSize = 7;
private MobFileCompactionChore compactionChore;
@@ -56,9 +51,9 @@ public TestMobCompactionOptRegionBatchMode(Boolean useFileBasedSFT) {
super(useFileBasedSFT);
}
- @Before
- public void setUp() throws Exception {
- super.setUp();
+ @BeforeEach
+ public void setUp(TestInfo testInfo) throws Exception {
+ super.setUp(testInfo);
compactionChore = new MobFileCompactionChore(conf, batchSize);
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobCompactionRegularRegionBatchMode.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobCompactionRegularRegionBatchMode.java
index 5e2806bdee2c..39fe1779d344 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobCompactionRegularRegionBatchMode.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobCompactionRegularRegionBatchMode.java
@@ -18,15 +18,13 @@
package org.apache.hadoop.hbase.mob;
import java.io.IOException;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HBaseParameterizedTestTemplate;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor;
import org.apache.hadoop.hbase.client.TableDescriptor;
import org.apache.hadoop.hbase.testclassification.LargeTests;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.experimental.categories.Category;
-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.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -40,14 +38,11 @@
* to archive 10. Runs Mob cleaner chore 11 Verifies that number of MOB files in a mob directory is
* 20. 12 Runs scanner and checks all 3 * 1000 rows.
*/
-@RunWith(Parameterized.class)
-@Category(LargeTests.class)
+@Tag(LargeTests.TAG)
+@HBaseParameterizedTestTemplate(name = "{index}: useFileBasedSFT={0}")
public class TestMobCompactionRegularRegionBatchMode extends TestMobCompactionWithDefaults {
private static final Logger LOG =
LoggerFactory.getLogger(TestMobCompactionRegularRegionBatchMode.class);
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMobCompactionRegularRegionBatchMode.class);
private static final int batchSize = 7;
private MobFileCompactionChore compactionChore;
@@ -56,9 +51,9 @@ public TestMobCompactionRegularRegionBatchMode(Boolean useFileBasedSFT) {
super(useFileBasedSFT);
}
- @Before
- public void setUp() throws Exception {
- super.setUp();
+ @BeforeEach
+ public void setUp(TestInfo testInfo) throws Exception {
+ super.setUp(testInfo);
compactionChore = new MobFileCompactionChore(conf, batchSize);
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobCompactionWithDefaults.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobCompactionWithDefaults.java
index 3ad6585c4620..787dc5b46dc7 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobCompactionWithDefaults.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobCompactionWithDefaults.java
@@ -17,20 +17,20 @@
*/
package org.apache.hadoop.hbase.mob;
-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.Arrays;
-import java.util.Collection;
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.FileStatus;
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;
@@ -47,15 +47,12 @@
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.RegionSplitter;
-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.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.AfterEach;
+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;
@@ -69,13 +66,10 @@
* Runs Mob cleaner chore 11 Verifies that number of MOB files in a mob directory is 20. 12 Runs
* scanner and checks all 3 * 1000 rows.
*/
-@RunWith(Parameterized.class)
-@Category(LargeTests.class)
+@Tag(LargeTests.TAG)
+@HBaseParameterizedTestTemplate(name = "{index}: useFileBasedSFT={0}")
public class TestMobCompactionWithDefaults {
private static final Logger LOG = LoggerFactory.getLogger(TestMobCompactionWithDefaults.class);
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMobCompactionWithDefaults.class);
protected HBaseTestingUtil HTU;
protected static Configuration conf;
@@ -88,8 +82,7 @@ public class TestMobCompactionWithDefaults {
protected final static byte[] mobVal = Bytes
.toBytes("01234567890123456789012345678901234567890123456789012345678901234567890123456789");
- @Rule
- public TestName test = new TestName();
+ private String testMethodName;
protected TableDescriptor tableDescriptor;
private ColumnFamilyDescriptor familyDescriptor;
protected Admin admin;
@@ -103,10 +96,8 @@ public TestMobCompactionWithDefaults(Boolean useFileBasedSFT) {
this.useFileBasedSFT = useFileBasedSFT;
}
- @Parameterized.Parameters
- public static Collection data() {
- Boolean[] data = { false, true };
- return Arrays.asList(data);
+ public static Stream parameters() {
+ return Stream.of(false, true).map(Arguments::of);
}
protected void htuStart() throws Exception {
@@ -133,13 +124,15 @@ protected void htuStart() throws Exception {
protected void additonalConfigSetup() {
}
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ public void setUp(TestInfo testInfo) throws Exception {
+ testMethodName = testInfo.getTestMethod().get().getName()
+ + testInfo.getDisplayName().replaceAll("[:= ]", "_").replaceAll("_+", "_").trim();
htuStart();
admin = HTU.getAdmin();
familyDescriptor = ColumnFamilyDescriptorBuilder.newBuilder(fam).setMobEnabled(true)
.setMobThreshold(mobLen).setMaxVersions(1).build();
- tableDescriptor = HTU.createModifyableTableDescriptor(TestMobUtils.getTableName(test))
+ tableDescriptor = HTU.createModifyableTableDescriptor(TestMobUtils.getTableName(testMethodName))
.setColumnFamily(familyDescriptor).build();
RegionSplitter.UniformSplit splitAlgo = new RegionSplitter.UniformSplit();
byte[][] splitKeys = splitAlgo.split(numRegions);
@@ -164,56 +157,56 @@ private void loadData(TableName tableName, int num) {
}
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
admin.disableTable(tableDescriptor.getTableName());
admin.deleteTable(tableDescriptor.getTableName());
HTU.shutdownMiniCluster();
}
- @Test
+ @TestTemplate
public void baseTestMobFileCompaction() throws InterruptedException, IOException {
LOG.info("MOB compaction " + description() + " started");
loadAndFlushThreeTimes(rows, table, famStr);
mobCompact(tableDescriptor, familyDescriptor);
- assertEquals("Should have 4 MOB files per region due to 3xflush + compaction.", numRegions * 4,
- getNumberOfMobFiles(table, famStr));
+ assertEquals(numRegions * 4, getNumberOfMobFiles(table, famStr),
+ "Should have 4 MOB files per region due to 3xflush + compaction.");
cleanupAndVerifyCounts(table, famStr, 3 * rows);
LOG.info("MOB compaction " + description() + " finished OK");
}
- @Test
+ @TestTemplate
public void testMobFileCompactionAfterSnapshotClone() throws InterruptedException, IOException {
- final TableName clone = TableName.valueOf(TestMobUtils.getTableName(test) + "-clone");
+ final TableName clone = TableName.valueOf(TestMobUtils.getTableName(testMethodName) + "-clone");
LOG.info("MOB compaction of cloned snapshot, " + description() + " started");
loadAndFlushThreeTimes(rows, table, famStr);
LOG.debug("Taking snapshot and cloning table {}", table);
- admin.snapshot(TestMobUtils.getTableName(test), table);
- admin.cloneSnapshot(TestMobUtils.getTableName(test), clone);
- assertEquals("Should have 3 hlinks per region in MOB area from snapshot clone", 3 * numRegions,
- getNumberOfMobFiles(clone, famStr));
+ admin.snapshot(TestMobUtils.getTableName(testMethodName), table);
+ admin.cloneSnapshot(TestMobUtils.getTableName(testMethodName), clone);
+ assertEquals(3 * numRegions, getNumberOfMobFiles(clone, famStr),
+ "Should have 3 hlinks per region in MOB area from snapshot clone");
mobCompact(admin.getDescriptor(clone), familyDescriptor);
- assertEquals("Should have 3 hlinks + 1 MOB file per region due to clone + compact",
- 4 * numRegions, getNumberOfMobFiles(clone, famStr));
+ assertEquals(4 * numRegions, getNumberOfMobFiles(clone, famStr),
+ "Should have 3 hlinks + 1 MOB file per region due to clone + compact");
cleanupAndVerifyCounts(clone, famStr, 3 * rows);
LOG.info("MOB compaction of cloned snapshot, " + description() + " finished OK");
}
- @Test
+ @TestTemplate
public void testMobFileCompactionAfterSnapshotCloneAndFlush()
throws InterruptedException, IOException {
- final TableName clone = TableName.valueOf(TestMobUtils.getTableName(test) + "-clone");
+ final TableName clone = TableName.valueOf(TestMobUtils.getTableName(testMethodName) + "-clone");
LOG.info("MOB compaction of cloned snapshot after flush, " + description() + " started");
loadAndFlushThreeTimes(rows, table, famStr);
LOG.debug("Taking snapshot and cloning table {}", table);
- admin.snapshot(TestMobUtils.getTableName(test), table);
- admin.cloneSnapshot(TestMobUtils.getTableName(test), clone);
- assertEquals("Should have 3 hlinks per region in MOB area from snapshot clone", 3 * numRegions,
- getNumberOfMobFiles(clone, famStr));
+ admin.snapshot(TestMobUtils.getTableName(testMethodName), table);
+ admin.cloneSnapshot(TestMobUtils.getTableName(testMethodName), clone);
+ assertEquals(3 * numRegions, getNumberOfMobFiles(clone, famStr),
+ "Should have 3 hlinks per region in MOB area from snapshot clone");
loadAndFlushThreeTimes(rows, clone, famStr);
mobCompact(admin.getDescriptor(clone), familyDescriptor);
- assertEquals("Should have 7 MOB file per region due to clone + 3xflush + compact",
- 7 * numRegions, getNumberOfMobFiles(clone, famStr));
+ assertEquals(7 * numRegions, getNumberOfMobFiles(clone, famStr),
+ "Should have 7 MOB file per region due to clone + 3xflush + compact");
cleanupAndVerifyCounts(clone, famStr, 6 * rows);
LOG.info("MOB compaction of cloned snapshot w flush, " + description() + " finished OK");
}
@@ -225,8 +218,8 @@ protected void loadAndFlushThreeTimes(int rows, TableName table, String family)
loadData(table, rows);
loadData(table, rows);
loadData(table, rows);
- assertEquals("Should have 3 more mob files per region from flushing.", start + numRegions * 3,
- getNumberOfMobFiles(table, family));
+ assertEquals(start + numRegions * 3, getNumberOfMobFiles(table, family),
+ "Should have 3 more mob files per region from flushing.");
}
protected String description() {
@@ -292,12 +285,12 @@ protected void cleanupAndVerifyCounts(TableName table, String family, int rows)
HTU.getMiniHBaseCluster().getRegionServer(sn).getRSMobFileCleanerChore().chore();
}
- assertEquals("After cleaning, we should have 1 MOB file per region based on size.", numRegions,
- getNumberOfMobFiles(table, family));
+ assertEquals(numRegions, getNumberOfMobFiles(table, family),
+ "After cleaning, we should have 1 MOB file per region based on size.");
LOG.debug("checking count of rows");
long scanned = scanTable(table);
- assertEquals("Got the wrong number of rows in table " + table + " cf " + family, rows, scanned);
+ assertEquals(rows, scanned, "Got the wrong number of rows in table " + table + " cf " + family);
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobCompactionWithException.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobCompactionWithException.java
index 192b0e31fb02..417390e11e45 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobCompactionWithException.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobCompactionWithException.java
@@ -19,9 +19,9 @@
import static org.apache.hadoop.hbase.HBaseTestingUtil.START_KEY;
import static org.apache.hadoop.hbase.HBaseTestingUtil.fam1;
-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;
@@ -31,7 +31,6 @@
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.ExtendedCell;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor;
@@ -60,27 +59,21 @@
import org.apache.hadoop.hbase.security.User;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.After;
-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.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;
+import org.junit.jupiter.api.TestInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category(MediumTests.class)
+@Tag(MediumTests.TAG)
public class TestMobCompactionWithException {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMobCompactionWithException.class);
-
- @Rule
- public TestName name = new TestName();
static final Logger LOG = LoggerFactory.getLogger(TestMobCompactionWithException.class.getName());
private final static HBaseTestingUtil HTU = new HBaseTestingUtil();
private static Configuration conf = null;
+ private String testMethodName;
private HRegion region = null;
private TableDescriptor tableDescriptor;
@@ -93,7 +86,7 @@ public class TestMobCompactionWithException {
private static int rowCount = 100;
private Table table;
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
conf = HTU.getConfiguration();
conf.set(MobConstants.MOB_COMPACTION_TYPE_KEY, MobConstants.OPTIMIZED_MOB_COMPACTION_TYPE);
@@ -101,7 +94,12 @@ public static void setUp() throws Exception {
}
- @After
+ @BeforeEach
+ public void setUp(TestInfo testInfo) {
+ testMethodName = testInfo.getTestMethod().get().getName();
+ }
+
+ @AfterEach
public void tearDown() throws Exception {
region.close();
this.table.close();
@@ -113,9 +111,9 @@ private void createTable(long mobThreshold) throws IOException {
this.columnFamilyDescriptor =
ColumnFamilyDescriptorBuilder.newBuilder(COLUMN_FAMILY).setMobEnabled(true)
.setMobThreshold(mobThreshold).setMaxVersions(1).setBlocksize(500).build();
- this.tableDescriptor =
- TableDescriptorBuilder.newBuilder(TableName.valueOf(TestMobUtils.getTableName(name)))
- .setColumnFamily(columnFamilyDescriptor).build();
+ this.tableDescriptor = TableDescriptorBuilder
+ .newBuilder(TableName.valueOf(TestMobUtils.getTableName(testMethodName)))
+ .setColumnFamily(columnFamilyDescriptor).build();
RegionInfo regionInfo = RegionInfoBuilder.newBuilder(tableDescriptor.getTableName()).build();
region = HBaseTestingUtil.createRegionAndWAL(regionInfo, HTU.getDataTestDir(), conf,
tableDescriptor, new MobFileCache(conf));
@@ -168,8 +166,8 @@ public void testMobStoreFileDeletedWhenCompactException() throws Exception {
// When compaction is failed,the count of StoreFile and MobStoreFile should be the same as
// before compaction.
- assertEquals("After compaction: store files", storeFileCountBeforeCompact, countStoreFiles());
- assertEquals("After compaction: mob file count", mobFileCountBeforeCompact, countMobFiles());
+ assertEquals(storeFileCountBeforeCompact, countStoreFiles(), "After compaction: store files");
+ assertEquals(mobFileCountBeforeCompact, countMobFiles(), "After compaction: mob file count");
}
private int countStoreFiles() throws IOException {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobDataBlockEncoding.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobDataBlockEncoding.java
index ac921e293d42..a54b881102f2 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobDataBlockEncoding.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobDataBlockEncoding.java
@@ -17,7 +17,6 @@
*/
package org.apache.hadoop.hbase.mob;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Admin;
@@ -33,19 +32,14 @@
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
-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(MediumTests.class)
+@Tag(MediumTests.TAG)
public class TestMobDataBlockEncoding {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMobDataBlockEncoding.class);
-
private final static HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
private final static byte[] row1 = Bytes.toBytes("row1");
private final static byte[] family = Bytes.toBytes("family");
@@ -58,12 +52,12 @@ public class TestMobDataBlockEncoding {
private static TableDescriptor tableDescriptor;
private static long defaultThreshold = 10;
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
TEST_UTIL.startMiniCluster(1);
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobFile.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobFile.java
index f4b06dbecd6b..c25a806c468a 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobFile.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobFile.java
@@ -17,15 +17,14 @@
*/
package org.apache.hadoop.hbase.mob;
-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.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.KeyValue.Type;
@@ -39,33 +38,25 @@
import org.apache.hadoop.hbase.regionserver.StoreFileWriter;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes;
-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.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
-@Category(SmallTests.class)
+@Tag(SmallTests.TAG)
public class TestMobFile {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMobFile.class);
-
private static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
private Configuration conf = TEST_UTIL.getConfiguration();
private CacheConfig cacheConf = new CacheConfig(conf);
- @Rule
- public TestName testName = new TestName();
@Test
- public void testReadKeyValue() throws Exception {
+ public void testReadKeyValue(TestInfo testInfo) throws Exception {
Path testDir = TEST_UTIL.getDataTestDir();
FileSystem fs = testDir.getFileSystem(conf);
HFileContext meta = new HFileContextBuilder().withBlockSize(8 * 1024).build();
StoreFileWriter writer = new StoreFileWriter.Builder(conf, cacheConf, fs).withOutputDir(testDir)
.withFileContext(meta).build();
- String caseName = testName.getMethodName();
+ String caseName = testInfo.getTestMethod().get().getName();
MobTestUtil.writeStoreFile(writer, caseName);
StoreFileInfo storeFileInfo =
@@ -110,13 +101,13 @@ public void testReadKeyValue() throws Exception {
}
@Test
- public void testGetScanner() throws Exception {
+ public void testGetScanner(TestInfo testInfo) throws Exception {
Path testDir = TEST_UTIL.getDataTestDir();
FileSystem fs = testDir.getFileSystem(conf);
HFileContext meta = new HFileContextBuilder().withBlockSize(8 * 1024).build();
StoreFileWriter writer = new StoreFileWriter.Builder(conf, cacheConf, fs).withOutputDir(testDir)
.withFileContext(meta).build();
- MobTestUtil.writeStoreFile(writer, testName.getMethodName());
+ MobTestUtil.writeStoreFile(writer, testInfo.getTestMethod().get().getName());
StoreFileInfo storeFileInfo =
StoreFileInfo.createStoreFileInfoForHFile(conf, fs, writer.getPath(), true);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobFileCache.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobFileCache.java
index e1e907d03704..e9842a0a265e 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobFileCache.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobFileCache.java
@@ -17,15 +17,14 @@
*/
package org.apache.hadoop.hbase.mob;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.IOException;
import java.util.Date;
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;
@@ -44,19 +43,14 @@
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.Pair;
-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(SmallTests.class)
+@Tag(SmallTests.TAG)
public class TestMobFileCache {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMobFileCache.class);
-
private HBaseTestingUtil UTIL;
private HRegion region;
private Configuration conf;
@@ -83,7 +77,7 @@ public class TestMobFileCache {
private static final byte[] QF2 = Bytes.toBytes("qf2");
private static final byte[] QF3 = Bytes.toBytes("qf3");
- @Before
+ @BeforeEach
public void setUp() throws Exception {
UTIL = new HBaseTestingUtil();
conf = UTIL.getConfiguration();
@@ -108,7 +102,7 @@ public void setUp() throws Exception {
tableDescriptor, mobFileCache);
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
region.close();
region.getFilesystem().delete(UTIL.getDataTestDir(), true);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobFileCleanupUtil.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobFileCleanupUtil.java
index fc9eceb62412..225f4d2a8152 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobFileCleanupUtil.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobFileCleanupUtil.java
@@ -17,9 +17,9 @@
*/
package org.apache.hadoop.hbase.mob;
-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 java.io.IOException;
import java.util.Arrays;
@@ -27,7 +27,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.HBaseTestingUtil;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Admin;
@@ -42,11 +41,10 @@
import org.apache.hadoop.hbase.master.cleaner.TimeToLiveHFileCleaner;
import org.apache.hadoop.hbase.testclassification.MediumTests;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -56,12 +54,9 @@
* directory is N+1 5. Waits for a period of time larger than minimum age to archive 6. Runs Mob
* cleaner chore 7 Verifies that number of MOB files in a mob directory is 1.
*/
-@Category(MediumTests.class)
+@Tag(MediumTests.TAG)
public class TestMobFileCleanupUtil {
private static final Logger LOG = LoggerFactory.getLogger(TestMobFileCleanupUtil.class);
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMobFileCleanupUtil.class);
private HBaseTestingUtil HTU;
@@ -82,7 +77,7 @@ public class TestMobFileCleanupUtil {
public TestMobFileCleanupUtil() {
}
- @Before
+ @BeforeEach
public void setUp() throws Exception {
HTU = new HBaseTestingUtil();
conf = HTU.getConfiguration();
@@ -135,7 +130,7 @@ private void loadData(int start, int num) {
}
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
admin.disableTable(tableDescriptor.getTableName());
admin.deleteTable(tableDescriptor.getTableName());
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobFileLink.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobFileLink.java
index 613fa59b6350..50ec7d7cc545 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobFileLink.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobFileLink.java
@@ -17,37 +17,28 @@
*/
package org.apache.hadoop.hbase.mob;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
import java.io.IOException;
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.HBaseConfiguration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.io.HFileLink;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.CommonFSUtils;
import org.apache.hadoop.hbase.util.HFileArchiveUtil;
-import org.junit.Assert;
-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.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
-@Category(SmallTests.class)
+@Tag(SmallTests.TAG)
public class TestMobFileLink {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMobFileLink.class);
-
- @Rule
- public TestName name = new TestName();
-
@Test
- public void testMobFilePath() throws IOException {
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ public void testMobFilePath(TestInfo testInfo) throws IOException {
+ final TableName tableName = TableName.valueOf(testInfo.getTestMethod().get().getName());
Configuration conf = HBaseConfiguration.create();
FileSystem fs = FileSystem.get(conf);
Path rootDir = CommonFSUtils.getRootDir(conf);
@@ -69,8 +60,8 @@ public void testMobFilePath() throws IOException {
String hfileLinkName = tableName.getNameAsString() + "=" + encodedRegionName + "-" + fileName;
Path hfileLinkPath = new Path(columnFamily, hfileLinkName);
HFileLink hfileLink = HFileLink.buildFromHFileLinkPattern(conf, hfileLinkPath);
- Assert.assertEquals(expectedMobFilePath, hfileLink.getMobPath());
- Assert.assertEquals(expectedOriginPath, hfileLink.getOriginPath());
- Assert.assertEquals(expectedArchivePath, hfileLink.getArchivePath());
+ assertEquals(expectedMobFilePath, hfileLink.getMobPath());
+ assertEquals(expectedOriginPath, hfileLink.getOriginPath());
+ assertEquals(expectedArchivePath, hfileLink.getArchivePath());
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobFileName.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobFileName.java
index 8b11568a4cfb..1c51983962a4 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobFileName.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobFileName.java
@@ -17,37 +17,31 @@
*/
package org.apache.hadoop.hbase.mob;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotSame;
-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.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Date;
import java.util.concurrent.ThreadLocalRandom;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.MD5Hash;
-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(SmallTests.class)
+@Tag(SmallTests.TAG)
public class TestMobFileName {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMobFileName.class);
-
private String uuid;
private Date date;
private String dateStr;
private byte[] startKey;
private String regionName = "region";
- @Before
+ @BeforeEach
public void setUp() {
uuid = HBaseTestingUtil.getRandomUUID().toString().replaceAll("-", "");
date = new Date();
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobStoreCompaction.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobStoreCompaction.java
index 8dde98a67826..1ee176d57222 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobStoreCompaction.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobStoreCompaction.java
@@ -21,26 +21,25 @@
import static org.apache.hadoop.hbase.HBaseTestingUtil.fam1;
import static org.apache.hadoop.hbase.regionserver.HStoreFile.BULKLOAD_TIME_KEY;
import static org.apache.hadoop.hbase.regionserver.HStoreFile.MOB_CELLS_COUNT;
-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.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
+import java.util.stream.Stream;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.ExtendedCell;
-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;
@@ -78,33 +77,23 @@
import org.apache.hadoop.hbase.util.CommonFSUtils;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.Pair;
-import org.junit.After;
-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.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.junit.jupiter.api.AfterEach;
+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;
/**
* Test mob store compaction
*/
-@RunWith(Parameterized.class)
-@Category(MediumTests.class)
+@Tag(MediumTests.TAG)
+@HBaseParameterizedTestTemplate(name = "{index}: useFileBasedSFT={0}")
public class TestMobStoreCompaction {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMobStoreCompaction.class);
-
- @Rule
- public TestName name = new TestName();
- static final Logger LOG = LoggerFactory.getLogger(TestMobStoreCompaction.class.getName());
private final static HBaseTestingUtil UTIL = new HBaseTestingUtil();
private Configuration conf = null;
+ private String testMethodName;
private HRegion region = null;
private TableDescriptor tableDescriptor = null;
@@ -123,10 +112,14 @@ public TestMobStoreCompaction(Boolean useFileBasedSFT) {
this.useFileBasedSFT = useFileBasedSFT;
}
- @Parameterized.Parameters
- public static Collection data() {
- Boolean[] data = { false, true };
- return Arrays.asList(data);
+ public static Stream parameters() {
+ return Stream.of(false, true).map(Arguments::of);
+ }
+
+ @BeforeEach
+ public void setUp(TestInfo testInfo) {
+ testMethodName = testInfo.getTestMethod().get().getName()
+ + testInfo.getDisplayName().replaceAll("[:= ]", "_").replaceAll("_+", "_").trim();
}
private void init(Configuration conf, long mobThreshold) throws Exception {
@@ -138,13 +131,12 @@ private void init(Configuration conf, long mobThreshold) throws Exception {
this.conf = conf;
this.mobCellThreshold = mobThreshold;
- HBaseTestingUtil UTIL = new HBaseTestingUtil(conf);
-
compactionThreshold = conf.getInt("hbase.hstore.compactionThreshold", 3);
familyDescriptor = ColumnFamilyDescriptorBuilder.newBuilder(COLUMN_FAMILY).setMobEnabled(true)
.setMobThreshold(mobThreshold).setMaxVersions(1).build();
- tableDescriptor = UTIL.createModifyableTableDescriptor(TestMobUtils.getTableName(name))
- .modifyColumnFamily(familyDescriptor).build();
+ tableDescriptor =
+ UTIL.createModifyableTableDescriptor(TestMobUtils.getTableName(testMethodName))
+ .modifyColumnFamily(familyDescriptor).build();
RegionInfo regionInfo = RegionInfoBuilder.newBuilder(tableDescriptor.getTableName()).build();
region = HBaseTestingUtil.createRegionAndWAL(regionInfo, UTIL.getDataTestDir(), conf,
@@ -152,7 +144,7 @@ private void init(Configuration conf, long mobThreshold) throws Exception {
fs = FileSystem.get(conf);
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
region.close();
fs.delete(UTIL.getDataTestDir(), true);
@@ -161,7 +153,7 @@ public void tearDown() throws Exception {
/**
* During compaction, cells smaller than the threshold won't be affected.
*/
- @Test
+ @TestTemplate
public void testSmallerValue() throws Exception {
init(UTIL.getConfiguration(), 500);
byte[] dummyData = makeDummyData(300); // smaller than mob threshold
@@ -172,24 +164,24 @@ public void testSmallerValue() throws Exception {
loader.put(p);
region.flush(true);
}
- assertEquals("Before compaction: store files", compactionThreshold, countStoreFiles());
- assertEquals("Before compaction: mob file count", 0, countMobFiles());
- assertEquals("Before compaction: rows", compactionThreshold, UTIL.countRows(region));
- assertEquals("Before compaction: mob rows", 0, countMobRows());
+ assertEquals(compactionThreshold, countStoreFiles(), "Before compaction: store files");
+ assertEquals(0, countMobFiles(), "Before compaction: mob file count");
+ assertEquals(compactionThreshold, UTIL.countRows(region), "Before compaction: rows");
+ assertEquals(0, countMobRows(), "Before compaction: mob rows");
region.compactStores();
- assertEquals("After compaction: store files", 1, countStoreFiles());
- assertEquals("After compaction: mob file count", 0, countMobFiles());
- assertEquals("After compaction: referenced mob file count", 0, countReferencedMobFiles());
- assertEquals("After compaction: rows", compactionThreshold, UTIL.countRows(region));
- assertEquals("After compaction: mob rows", 0, countMobRows());
+ assertEquals(1, countStoreFiles(), "After compaction: store files");
+ assertEquals(0, countMobFiles(), "After compaction: mob file count");
+ assertEquals(0, countReferencedMobFiles(), "After compaction: referenced mob file count");
+ assertEquals(compactionThreshold, UTIL.countRows(region), "After compaction: rows");
+ assertEquals(0, countMobRows(), "After compaction: mob rows");
}
/**
* During compaction, the mob threshold size is changed.
*/
- @Test
+ @TestTemplate
public void testLargerValue() throws Exception {
init(UTIL.getConfiguration(), 200);
byte[] dummyData = makeDummyData(300); // larger than mob threshold
@@ -199,12 +191,12 @@ public void testLargerValue() throws Exception {
loader.put(p);
region.flush(true);
}
- assertEquals("Before compaction: store files", compactionThreshold, countStoreFiles());
- assertEquals("Before compaction: mob file count", compactionThreshold, countMobFiles());
- assertEquals("Before compaction: rows", compactionThreshold, UTIL.countRows(region));
- assertEquals("Before compaction: mob rows", compactionThreshold, countMobRows());
- assertEquals("Before compaction: number of mob cells", compactionThreshold,
- countMobCellsInMetadata());
+ assertEquals(compactionThreshold, countStoreFiles(), "Before compaction: store files");
+ assertEquals(compactionThreshold, countMobFiles(), "Before compaction: mob file count");
+ assertEquals(compactionThreshold, UTIL.countRows(region), "Before compaction: rows");
+ assertEquals(compactionThreshold, countMobRows(), "Before compaction: mob rows");
+ assertEquals(compactionThreshold, countMobCellsInMetadata(),
+ "Before compaction: number of mob cells");
// Change the threshold larger than the data size
setMobThreshold(region, COLUMN_FAMILY, 500);
region.initialize();
@@ -221,11 +213,11 @@ public void testLargerValue() throws Exception {
region.compact(context.get(), store, NoLimitThroughputController.INSTANCE, User.getCurrent());
}
- assertEquals("After compaction: store files", 1, countStoreFiles());
- assertEquals("After compaction: mob file count", compactionThreshold, countMobFiles());
- assertEquals("After compaction: referenced mob file count", 0, countReferencedMobFiles());
- assertEquals("After compaction: rows", compactionThreshold, UTIL.countRows(region));
- assertEquals("After compaction: mob rows", 0, countMobRows());
+ assertEquals(1, countStoreFiles(), "After compaction: store files");
+ assertEquals(compactionThreshold, countMobFiles(), "After compaction: mob file count");
+ assertEquals(0, countReferencedMobFiles(), "After compaction: referenced mob file count");
+ assertEquals(compactionThreshold, UTIL.countRows(region), "After compaction: rows");
+ assertEquals(0, countMobRows(), "After compaction: mob rows");
}
private static HRegion setMobThreshold(HRegion region, byte[] cfName, long modThreshold) {
@@ -242,7 +234,7 @@ private static HRegion setMobThreshold(HRegion region, byte[] cfName, long modTh
* This test will first generate store files, then bulk load them and trigger the compaction. When
* compaction, the cell value will be larger than the threshold.
*/
- @Test
+ @TestTemplate
public void testMobCompactionWithBulkload() throws Exception {
// The following will produce store files of 600.
init(UTIL.getConfiguration(), 300);
@@ -260,25 +252,25 @@ public void testMobCompactionWithBulkload() throws Exception {
// The following will bulk load the above generated store files and compact, with 600(fileSize)
// > 300(threshold)
Map> map = region.bulkLoadHFiles(hfiles, true, null);
- assertTrue("Bulkload result:", !map.isEmpty());
- assertEquals("Before compaction: store files", compactionThreshold, countStoreFiles());
- assertEquals("Before compaction: mob file count", 0, countMobFiles());
- assertEquals("Before compaction: rows", compactionThreshold, UTIL.countRows(region));
- assertEquals("Before compaction: mob rows", 0, countMobRows());
- assertEquals("Before compaction: referenced mob file count", 0, countReferencedMobFiles());
+ assertTrue(!map.isEmpty(), "Bulkload result:");
+ assertEquals(compactionThreshold, countStoreFiles(), "Before compaction: store files");
+ assertEquals(0, countMobFiles(), "Before compaction: mob file count");
+ assertEquals(compactionThreshold, UTIL.countRows(region), "Before compaction: rows");
+ assertEquals(0, countMobRows(), "Before compaction: mob rows");
+ assertEquals(0, countReferencedMobFiles(), "Before compaction: referenced mob file count");
region.compactStores();
- assertEquals("After compaction: store files", 1, countStoreFiles());
- assertEquals("After compaction: mob file count:", 1, countMobFiles());
- assertEquals("After compaction: rows", compactionThreshold, UTIL.countRows(region));
- assertEquals("After compaction: mob rows", compactionThreshold, countMobRows());
- assertEquals("After compaction: referenced mob file count", 1, countReferencedMobFiles());
- assertEquals("After compaction: number of mob cells", compactionThreshold,
- countMobCellsInMetadata());
+ assertEquals(1, countStoreFiles(), "After compaction: store files");
+ assertEquals(1, countMobFiles(), "After compaction: mob file count:");
+ assertEquals(compactionThreshold, UTIL.countRows(region), "After compaction: rows");
+ assertEquals(compactionThreshold, countMobRows(), "After compaction: mob rows");
+ assertEquals(1, countReferencedMobFiles(), "After compaction: referenced mob file count");
+ assertEquals(compactionThreshold, countMobCellsInMetadata(),
+ "After compaction: number of mob cells");
}
- @Test
+ @TestTemplate
public void testMajorCompactionAfterDelete() throws Exception {
init(UTIL.getConfiguration(), 100);
byte[] dummyData = makeDummyData(200); // larger than mob threshold
@@ -291,22 +283,22 @@ public void testMajorCompactionAfterDelete() throws Exception {
loader.put(p);
region.flush(true);
}
- assertEquals("Before compaction: store files", numHfiles, countStoreFiles());
- assertEquals("Before compaction: mob file count", numHfiles, countMobFiles());
- assertEquals("Before compaction: rows", numHfiles, UTIL.countRows(region));
- assertEquals("Before compaction: mob rows", numHfiles, countMobRows());
- assertEquals("Before compaction: number of mob cells", numHfiles, countMobCellsInMetadata());
+ assertEquals(numHfiles, countStoreFiles(), "Before compaction: store files");
+ assertEquals(numHfiles, countMobFiles(), "Before compaction: mob file count");
+ assertEquals(numHfiles, UTIL.countRows(region), "Before compaction: rows");
+ assertEquals(numHfiles, countMobRows(), "Before compaction: mob rows");
+ assertEquals(numHfiles, countMobCellsInMetadata(), "Before compaction: number of mob cells");
// now let's delete some cells that contain mobs
Delete delete = new Delete(deleteRow);
delete.addFamily(COLUMN_FAMILY);
region.delete(delete);
region.flush(true);
- assertEquals("Before compaction: store files", numHfiles + 1, countStoreFiles());
- assertEquals("Before compaction: mob files", numHfiles, countMobFiles());
+ assertEquals(numHfiles + 1, countStoreFiles(), "Before compaction: store files");
+ assertEquals(numHfiles, countMobFiles(), "Before compaction: mob files");
// region.compactStores();
region.compact(true);
- assertEquals("After compaction: store files", 1, countStoreFiles());
+ assertEquals(1, countStoreFiles(), "After compaction: store files");
}
private int countStoreFiles() throws IOException {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobStoreScanner.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobStoreScanner.java
index 539d0986b2ce..ddb780fdb81e 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobStoreScanner.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobStoreScanner.java
@@ -17,6 +17,12 @@
*/
package org.apache.hadoop.hbase.mob;
+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.assertTrue;
+
import java.io.IOException;
import java.util.List;
import org.apache.hadoop.conf.Configuration;
@@ -25,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.TableName;
import org.apache.hadoop.hbase.client.Admin;
@@ -50,22 +55,16 @@
import org.apache.hadoop.hbase.util.CommonFSUtils;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.HFileArchiveUtil;
-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.TestName;
-
-@Category(MediumTests.class)
+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;
+
+@Tag(MediumTests.TAG)
public class TestMobStoreScanner {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMobStoreScanner.class);
-
private final static HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
private final static byte[] row1 = Bytes.toBytes("row1");
private final static byte[] row2 = Bytes.toBytes("row2");
@@ -80,11 +79,9 @@ public class TestMobStoreScanner {
private static long defaultThreshold = 10;
private FileSystem fs;
private Configuration conf;
+ private String testMethodName;
- @Rule
- public TestName name = new TestName();
-
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
TEST_UTIL.getConfiguration().setInt(ConnectionConfiguration.MAX_KEYVALUE_SIZE_KEY,
100 * 1024 * 1024);
@@ -92,11 +89,16 @@ public static void setUpBeforeClass() throws Exception {
TEST_UTIL.startMiniCluster(1);
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
+ @BeforeEach
+ public void setUpTest(TestInfo testInfo) {
+ testMethodName = testInfo.getTestMethod().get().getName();
+ }
+
public void setUp(long threshold, TableName tn) throws Exception {
conf = TEST_UTIL.getConfiguration();
fs = FileSystem.get(conf);
@@ -153,7 +155,7 @@ public void testReversedMobStoreScanner() throws Exception {
@Test
public void testGetMassive() throws Exception {
- setUp(defaultThreshold, TableName.valueOf(name.getMethodName()));
+ setUp(defaultThreshold, TableName.valueOf(testMethodName));
// Put some data 5 10, 15, 20 mb ok (this would be right below protobuf
// default max size of 64MB.
@@ -180,7 +182,7 @@ public void testGetMassive() throws Exception {
@Test
public void testReadPt() throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ final TableName tableName = TableName.valueOf(testMethodName);
setUp(0L, tableName);
long ts = EnvironmentEdgeManager.currentTime();
byte[] value1 = Bytes.toBytes("value1");
@@ -206,29 +208,29 @@ public void testReadPt() throws Exception {
table.put(put4);
Cell cell = result.getColumnLatestCell(family, qf1);
- Assert.assertArrayEquals(value1, CellUtil.cloneValue(cell));
+ assertArrayEquals(value1, CellUtil.cloneValue(cell));
admin.flush(tableName);
result = rs.next();
cell = result.getColumnLatestCell(family, qf1);
- Assert.assertArrayEquals(value2, CellUtil.cloneValue(cell));
+ assertArrayEquals(value2, CellUtil.cloneValue(cell));
}
@Test
public void testReadFromCorruptMobFilesWithReadEmptyValueOnMobCellMiss() throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ final TableName tableName = TableName.valueOf(testMethodName);
setUp(0, tableName);
createRecordAndCorruptMobFile(tableName, row1, family, qf1, Bytes.toBytes("value1"));
Get get = new Get(row1);
get.setAttribute(MobConstants.EMPTY_VALUE_ON_MOBCELL_MISS, Bytes.toBytes(true));
Result result = table.get(get);
Cell cell = result.getColumnLatestCell(family, qf1);
- Assert.assertEquals(0, cell.getValueLength());
+ assertEquals(0, cell.getValueLength());
}
@Test
public void testReadFromCorruptMobFiles() throws Exception {
- final TableName tableName = TableName.valueOf(name.getMethodName());
+ final TableName tableName = TableName.valueOf(testMethodName);
setUp(0, tableName);
createRecordAndCorruptMobFile(tableName, row1, family, qf1, Bytes.toBytes("value1"));
Get get = new Get(row1);
@@ -238,8 +240,8 @@ public void testReadFromCorruptMobFiles() throws Exception {
} catch (IOException e) {
ioe = e;
}
- Assert.assertNotNull(ioe);
- Assert.assertEquals(CorruptHFileException.class.getName(), ioe.getClass().getName());
+ assertNotNull(ioe);
+ assertEquals(CorruptHFileException.class.getName(), ioe.getClass().getName());
}
private void createRecordAndCorruptMobFile(TableName tn, byte[] row, byte[] family, byte[] qf,
@@ -249,7 +251,7 @@ private void createRecordAndCorruptMobFile(TableName tn, byte[] row, byte[] fami
table.put(put1);
admin.flush(tn);
Path mobFile = getFlushedMobFile(conf, fs, tn, Bytes.toString(family));
- Assert.assertNotNull(mobFile);
+ assertNotNull(mobFile);
// create new corrupt mob file.
Path corruptFile = new Path(mobFile.getParent(), "dummy");
TestHFile.truncateFile(fs, mobFile, corruptFile);
@@ -331,7 +333,7 @@ private void testGetReferences(boolean reversed) throws Exception {
}
}
results.close();
- Assert.assertEquals(3, count);
+ assertEquals(3, count);
}
private void testMobThreshold(boolean reversed) throws Exception {
@@ -377,7 +379,7 @@ private void testMobThreshold(boolean reversed) throws Exception {
count++;
}
}
- Assert.assertEquals(3, count);
+ assertEquals(3, count);
assertNotMobReference(cellLess, row1, family, valueLess);
assertNotMobReference(cellEqual, row1, family, valueEqual);
assertIsMobReference(cellGreater, row1, family, valueGreater, tn);
@@ -427,9 +429,9 @@ private void testGetFromArchive(boolean reversed) throws Exception {
// Verify the moving success
FileStatus[] files1 = fs.listStatus(mobFamilyPath);
- Assert.assertEquals(0, files1.length);
+ assertEquals(0, files1.length);
FileStatus[] files2 = fs.listStatus(storeArchiveDir);
- Assert.assertEquals(fileCount, files2.length);
+ assertEquals(fileCount, files2.length);
// Scan from archive
Scan scan = new Scan();
@@ -442,9 +444,9 @@ private void testGetFromArchive(boolean reversed) throws Exception {
*/
private static void assertNotMobReference(Cell cell, byte[] row, byte[] family, byte[] value)
throws IOException {
- Assert.assertArrayEquals(row, CellUtil.cloneRow(cell));
- Assert.assertArrayEquals(family, CellUtil.cloneFamily(cell));
- Assert.assertArrayEquals(value, CellUtil.cloneValue(cell));
+ assertArrayEquals(row, CellUtil.cloneRow(cell));
+ assertArrayEquals(family, CellUtil.cloneFamily(cell));
+ assertArrayEquals(value, CellUtil.cloneValue(cell));
}
/**
@@ -452,17 +454,17 @@ private static void assertNotMobReference(Cell cell, byte[] row, byte[] family,
*/
private static void assertIsMobReference(Cell cell, byte[] row, byte[] family, byte[] value,
TableName tn) throws IOException {
- Assert.assertArrayEquals(row, CellUtil.cloneRow(cell));
- Assert.assertArrayEquals(family, CellUtil.cloneFamily(cell));
- Assert.assertFalse(Bytes.equals(value, CellUtil.cloneValue(cell)));
+ assertArrayEquals(row, CellUtil.cloneRow(cell));
+ assertArrayEquals(family, CellUtil.cloneFamily(cell));
+ assertFalse(Bytes.equals(value, CellUtil.cloneValue(cell)));
byte[] referenceValue = CellUtil.cloneValue(cell);
String fileName = MobUtils.getMobFileName(cell);
int valLen = Bytes.toInt(referenceValue, 0, Bytes.SIZEOF_INT);
- Assert.assertEquals(value.length, valLen);
+ assertEquals(value.length, valLen);
Path mobFamilyPath = MobUtils.getMobFamilyPath(TEST_UTIL.getConfiguration(), tn,
familyDescriptor.getNameAsString());
Path targetPath = new Path(mobFamilyPath, fileName);
FileSystem fs = FileSystem.get(TEST_UTIL.getConfiguration());
- Assert.assertTrue(fs.exists(targetPath));
+ assertTrue(fs.exists(targetPath));
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobUtils.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobUtils.java
index 32170e98b353..709d8b7bbef3 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobUtils.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobUtils.java
@@ -17,27 +17,20 @@
*/
package org.apache.hadoop.hbase.mob;
-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.HBaseClassTestRule;
import org.apache.hadoop.hbase.TableName;
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.rules.TestName;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.apache.hbase.thirdparty.com.google.common.collect.ImmutableSet;
import org.apache.hbase.thirdparty.com.google.common.collect.ImmutableSetMultimap;
-@Category(SmallTests.class)
+@Tag(SmallTests.TAG)
public class TestMobUtils {
-
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMobUtils.class);
public static final TableName TEST_TABLE_1 = TableName.valueOf("testTable1");
public static final TableName TEST_TABLE_2 = TableName.valueOf("testTable2");
public static final TableName TEST_TABLE_3 = TableName.valueOf("testTable3");
@@ -91,7 +84,7 @@ public void deserializeMultipleMobFileRefs() {
assertTrue(testTable3Refs.contains("file3b"));
}
- public static String getTableName(TestName test) {
- return test.getMethodName().replace("[", "-").replace("]", "");
+ public static String getTableName(String testMethodName) {
+ return testMethodName.replace("[", "-").replace("]", "");
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobWithByteBuffAllocator.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobWithByteBuffAllocator.java
index 266bc9ae648b..3f2677ea7934 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobWithByteBuffAllocator.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobWithByteBuffAllocator.java
@@ -17,10 +17,12 @@
*/
package org.apache.hadoop.hbase.mob;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.apache.hadoop.conf.Configuration;
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.HConstants;
import org.apache.hadoop.hbase.TableName;
@@ -34,25 +36,19 @@
import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.AfterClass;
-import org.junit.Assert;
-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;
/**
* Test the MOB feature when enable RPC ByteBuffAllocator (HBASE-22122)
*/
-@Category({ MediumTests.class })
+@Tag(MediumTests.TAG)
public class TestMobWithByteBuffAllocator {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMobWithByteBuffAllocator.class);
-
private static final String TABLE_NAME = "TestMobWithByteBuffAllocator";
private static final Logger LOG = LoggerFactory.getLogger(TestMobWithByteBuffAllocator.class);
@@ -60,7 +56,7 @@ public class TestMobWithByteBuffAllocator {
private static final Configuration CONF = UTIL.getConfiguration();
private static final byte[] FAMILY = Bytes.toBytes("f");
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
// Must use the ByteBuffAllocator here
CONF.setBoolean(ByteBuffAllocator.ALLOCATOR_POOL_ENABLED_KEY, true);
@@ -73,7 +69,7 @@ public static void setUp() throws Exception {
UTIL.startMiniCluster();
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
UTIL.shutdownMiniCluster();
}
@@ -103,11 +99,11 @@ public void testReadingCellsFromHFile() throws Exception {
for (Result res; (res = scanner.next()) != null;) {
rows++;
for (Cell cell : res.listCells()) {
- Assert.assertTrue(CellUtil.cloneValue(cell).length > 0);
+ assertTrue(CellUtil.cloneValue(cell).length > 0);
}
}
}
}
- Assert.assertEquals(expectedRows, rows);
+ assertEquals(expectedRows, rows);
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestRSMobFileCleanerChore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestRSMobFileCleanerChore.java
index 9454ac459060..34f179880ba5 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestRSMobFileCleanerChore.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestRSMobFileCleanerChore.java
@@ -17,9 +17,9 @@
*/
package org.apache.hadoop.hbase.mob;
-import static org.junit.Assert.assertEquals;
-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.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.util.Arrays;
@@ -31,7 +31,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.HBaseTestingUtil;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
@@ -52,11 +51,10 @@
import org.apache.hadoop.hbase.regionserver.HStoreFile;
import org.apache.hadoop.hbase.testclassification.MediumTests;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -66,12 +64,9 @@
* a period of time larger than minimum age to archive 6. Runs Mob cleaner chore 7 Verifies that
* every old MOB file referenced from current RS was archived
*/
-@Category(MediumTests.class)
+@Tag(MediumTests.TAG)
public class TestRSMobFileCleanerChore {
private static final Logger LOG = LoggerFactory.getLogger(TestRSMobFileCleanerChore.class);
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRSMobFileCleanerChore.class);
private HBaseTestingUtil HTU;
@@ -93,7 +88,7 @@ public class TestRSMobFileCleanerChore {
public TestRSMobFileCleanerChore() {
}
- @Before
+ @BeforeEach
public void setUp() throws Exception {
HTU = new HBaseTestingUtil();
conf = HTU.getConfiguration();
@@ -146,7 +141,7 @@ private void loadData(Table t, int start, int num) {
}
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
admin.disableTable(tableDescriptor.getTableName());
admin.deleteTable(tableDescriptor.getTableName());
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/namespace/TestNamespaceAuditor.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/namespace/TestNamespaceAuditor.java
index 3f52ff30026b..376ddc2803c0 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/namespace/TestNamespaceAuditor.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/namespace/TestNamespaceAuditor.java
@@ -17,12 +17,13 @@
*/
package org.apache.hadoop.hbase.namespace;
-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.Assert.fail;
+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.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.IOException;
import java.util.Collections;
@@ -38,7 +39,6 @@
import org.apache.hadoop.hbase.Coprocessor;
import org.apache.hadoop.hbase.CoprocessorEnvironment;
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.NamespaceDescriptor;
@@ -83,28 +83,23 @@
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.CommonFSUtils;
import org.apache.zookeeper.KeeperException;
-import org.junit.After;
-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.AfterEach;
+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(LargeTests.class)
+@Tag(LargeTests.TAG)
public class TestNamespaceAuditor {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestNamespaceAuditor.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestNamespaceAuditor.class);
private static final HBaseTestingUtil UTIL = new HBaseTestingUtil();
private static Admin ADMIN;
private String prefix = "TestNamespaceAuditor";
- @BeforeClass
+ @BeforeAll
public static void before() throws Exception {
Configuration conf = UTIL.getConfiguration();
conf.set(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY, CustomObserver.class.getName());
@@ -120,12 +115,12 @@ public static void before() throws Exception {
ADMIN = UTIL.getAdmin();
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
UTIL.shutdownMiniCluster();
}
- @After
+ @AfterEach
public void cleanup() throws Exception, KeeperException {
for (TableDescriptor table : ADMIN.listTableDescriptors()) {
ADMIN.disableTable(table.getTableName());
@@ -136,8 +131,8 @@ public void cleanup() throws Exception, KeeperException {
ADMIN.deleteNamespace(ns.getName());
}
}
- assertTrue("Quota manager not initialized",
- UTIL.getHBaseCluster().getMaster().getMasterQuotaManager().isQuotaInitialized());
+ assertTrue(UTIL.getHBaseCluster().getMaster().getMasterQuotaManager().isQuotaInitialized(),
+ "Quota manager not initialized");
}
@Test
@@ -147,7 +142,7 @@ public void testTableOperations() throws Exception {
NamespaceDescriptor.create(nsp).addConfiguration(TableNamespaceManager.KEY_MAX_REGIONS, "5")
.addConfiguration(TableNamespaceManager.KEY_MAX_TABLES, "2").build();
ADMIN.createNamespace(nspDesc);
- assertNotNull("Namespace descriptor found null.", ADMIN.getNamespaceDescriptor(nsp));
+ assertNotNull(ADMIN.getNamespaceDescriptor(nsp), "Namespace descriptor found null.");
assertEquals(3, ADMIN.listNamespaceDescriptors().length);
ColumnFamilyDescriptor columnFamilyDescriptor =
ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes("fam1")).build();
@@ -169,8 +164,8 @@ public void testTableOperations() throws Exception {
assertTrue(exp instanceof IOException);
constraintViolated = true;
} finally {
- assertTrue("Constraint not violated for table " + tableDescTwo.build().getTableName(),
- constraintViolated);
+ assertTrue(constraintViolated,
+ "Constraint not violated for table " + tableDescTwo.build().getTableName());
}
ADMIN.createTable(tableDescTwo.build(), Bytes.toBytes("AAA"), Bytes.toBytes("ZZZ"), 4);
NamespaceTableAndRegionInfo nspState = getQuotaManager().getState(nsp);
@@ -184,8 +179,8 @@ public void testTableOperations() throws Exception {
assertTrue(exp instanceof IOException);
constraintViolated = true;
} finally {
- assertTrue("Constraint not violated for table " + tableDescThree.build().getTableName(),
- constraintViolated);
+ assertTrue(constraintViolated,
+ "Constraint not violated for table " + tableDescThree.build().getTableName());
}
}
@@ -251,9 +246,9 @@ public void testDeleteTable() throws Exception {
.addConfiguration(TableNamespaceManager.KEY_MAX_REGIONS, "100")
.addConfiguration(TableNamespaceManager.KEY_MAX_TABLES, "3").build();
ADMIN.createNamespace(nspDesc);
- assertNotNull("Namespace descriptor found null.", ADMIN.getNamespaceDescriptor(namespace));
+ assertNotNull(ADMIN.getNamespaceDescriptor(namespace), "Namespace descriptor found null.");
NamespaceTableAndRegionInfo stateInfo = getNamespaceState(nspDesc.getName());
- assertNotNull("Namespace state found null for " + namespace, stateInfo);
+ assertNotNull(stateInfo, "Namespace state found null for " + namespace);
ColumnFamilyDescriptor columnFamilyDescriptor =
ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes("fam1")).build();
TableDescriptorBuilder tableDescOne = TableDescriptorBuilder
@@ -265,21 +260,21 @@ public void testDeleteTable() throws Exception {
ADMIN.createTable(tableDescOne.build());
ADMIN.createTable(tableDescTwo.build(), Bytes.toBytes("AAA"), Bytes.toBytes("ZZZ"), 5);
stateInfo = getNamespaceState(nspDesc.getName());
- assertNotNull("Namespace state found to be null.", stateInfo);
+ assertNotNull(stateInfo, "Namespace state found to be null.");
assertEquals(2, stateInfo.getTables().size());
assertEquals(5, stateInfo.getRegionCountOfTable(tableDescTwo.build().getTableName()));
assertEquals(6, stateInfo.getRegionCount());
ADMIN.disableTable(tableDescOne.build().getTableName());
deleteTable(tableDescOne.build().getTableName());
stateInfo = getNamespaceState(nspDesc.getName());
- assertNotNull("Namespace state found to be null.", stateInfo);
+ assertNotNull(stateInfo, "Namespace state found to be null.");
assertEquals(5, stateInfo.getRegionCount());
assertEquals(1, stateInfo.getTables().size());
ADMIN.disableTable(tableDescTwo.build().getTableName());
deleteTable(tableDescTwo.build().getTableName());
ADMIN.deleteNamespace(namespace);
stateInfo = getNamespaceState(namespace);
- assertNull("Namespace state not found to be null.", stateInfo);
+ assertNull(stateInfo, "Namespace state not found to be null.");
}
public static class CPRegionServerObserver
@@ -441,8 +436,8 @@ public void testRecreateTableWithSameNameAfterFirstTimeFailure() throws Exceptio
assertFalse(ADMIN.tableExists(tableOne));
NamespaceTableAndRegionInfo nstate = getNamespaceState(nsp1);
- assertEquals("First table creation failed in namespace so number of tables in namespace "
- + "should be 0.", 0, nstate.getTables().size());
+ assertEquals(0, nstate.getTables().size(),
+ "First table creation failed in namespace so number of tables in namespace should be 0.");
MasterSyncObserver.throwExceptionInPreCreateTableAction = false;
try {
@@ -453,9 +448,8 @@ public void testRecreateTableWithSameNameAfterFirstTimeFailure() throws Exceptio
}
assertTrue(ADMIN.tableExists(tableOne));
nstate = getNamespaceState(nsp1);
- assertEquals(
- "First table was created successfully so table size in namespace should " + "be one now.",
- 1, nstate.getTables().size());
+ assertEquals(1, nstate.getTables().size(),
+ "First table was created successfully so table size in namespace should be one now.");
} finally {
MasterSyncObserver.throwExceptionInPreCreateTableAction = false;
if (ADMIN.tableExists(tableOne)) {
@@ -526,8 +520,8 @@ public boolean evaluate() throws Exception {
NamespaceTableAndRegionInfo before = getNamespaceState(nsp1);
killActiveMaster();
NamespaceTableAndRegionInfo after = getNamespaceState(nsp1);
- assertEquals("Expected: " + before.getTables() + " Found: " + after.getTables(),
- before.getTables().size(), after.getTables().size());
+ assertEquals(before.getTables().size(), after.getTables().size(),
+ "Expected: " + before.getTables() + " Found: " + after.getTables());
}
public static void waitForQuotaInitialize(final HBaseTestingUtil util) throws Exception {
@@ -594,13 +588,13 @@ private void deleteTable(final TableName tableName) throws Exception {
observer.tableDeletionLatch.await();
}
- @Test(expected = QuotaExceededException.class)
+ @Test
public void testExceedTableQuotaInNamespace() throws Exception {
String nsp = prefix + "_testExceedTableQuotaInNamespace";
NamespaceDescriptor nspDesc = NamespaceDescriptor.create(nsp)
.addConfiguration(TableNamespaceManager.KEY_MAX_TABLES, "1").build();
ADMIN.createNamespace(nspDesc);
- assertNotNull("Namespace descriptor found null.", ADMIN.getNamespaceDescriptor(nsp));
+ assertNotNull(ADMIN.getNamespaceDescriptor(nsp), "Namespace descriptor found null.");
assertEquals(3, ADMIN.listNamespaceDescriptors().length);
ColumnFamilyDescriptor columnFamilyDescriptor =
ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes("fam1")).build();
@@ -611,16 +605,17 @@ public void testExceedTableQuotaInNamespace() throws Exception {
.newBuilder(TableName.valueOf(nsp + TableName.NAMESPACE_DELIM + "table2"));
tableDescTwo.setColumnFamily(columnFamilyDescriptor);
ADMIN.createTable(tableDescOne.build());
- ADMIN.createTable(tableDescTwo.build(), Bytes.toBytes("AAA"), Bytes.toBytes("ZZZ"), 4);
+ assertThrows(QuotaExceededException.class,
+ () -> ADMIN.createTable(tableDescTwo.build(), Bytes.toBytes("AAA"), Bytes.toBytes("ZZZ"), 4));
}
- @Test(expected = QuotaExceededException.class)
+ @Test
public void testCloneSnapshotQuotaExceed() throws Exception {
String nsp = prefix + "_testTableQuotaExceedWithCloneSnapshot";
NamespaceDescriptor nspDesc = NamespaceDescriptor.create(nsp)
.addConfiguration(TableNamespaceManager.KEY_MAX_TABLES, "1").build();
ADMIN.createNamespace(nspDesc);
- assertNotNull("Namespace descriptor found null.", ADMIN.getNamespaceDescriptor(nsp));
+ assertNotNull(ADMIN.getNamespaceDescriptor(nsp), "Namespace descriptor found null.");
TableName tableName = TableName.valueOf(nsp + TableName.NAMESPACE_DELIM + "table1");
TableName cloneTableName = TableName.valueOf(nsp + TableName.NAMESPACE_DELIM + "table2");
ColumnFamilyDescriptor columnFamilyDescriptor =
@@ -630,7 +625,7 @@ public void testCloneSnapshotQuotaExceed() throws Exception {
ADMIN.createTable(tableDescOne.build());
String snapshot = "snapshot_testTableQuotaExceedWithCloneSnapshot";
ADMIN.snapshot(snapshot, tableName);
- ADMIN.cloneSnapshot(snapshot, cloneTableName);
+ assertThrows(QuotaExceededException.class, () -> ADMIN.cloneSnapshot(snapshot, cloneTableName));
ADMIN.deleteSnapshot(snapshot);
}
@@ -641,7 +636,7 @@ public void testCloneSnapshot() throws Exception {
NamespaceDescriptor.create(nsp).addConfiguration(TableNamespaceManager.KEY_MAX_TABLES, "2")
.addConfiguration(TableNamespaceManager.KEY_MAX_REGIONS, "20").build();
ADMIN.createNamespace(nspDesc);
- assertNotNull("Namespace descriptor found null.", ADMIN.getNamespaceDescriptor(nsp));
+ assertNotNull(ADMIN.getNamespaceDescriptor(nsp), "Namespace descriptor found null.");
TableName tableName = TableName.valueOf(nsp + TableName.NAMESPACE_DELIM + "table1");
TableName cloneTableName = TableName.valueOf(nsp + TableName.NAMESPACE_DELIM + "table2");
@@ -659,16 +654,16 @@ public void testCloneSnapshot() throws Exception {
try (RegionLocator locator = ADMIN.getConnection().getRegionLocator(tableName)) {
tableLength = locator.getStartKeys().length;
}
- assertEquals(tableName.getNameAsString() + " should have four regions.", 4, tableLength);
+ assertEquals(4, tableLength, tableName.getNameAsString() + " should have four regions.");
try (RegionLocator locator = ADMIN.getConnection().getRegionLocator(cloneTableName)) {
tableLength = locator.getStartKeys().length;
}
- assertEquals(cloneTableName.getNameAsString() + " should have four regions.", 4, tableLength);
+ assertEquals(4, tableLength, cloneTableName.getNameAsString() + " should have four regions.");
NamespaceTableAndRegionInfo nstate = getNamespaceState(nsp);
- assertEquals("Total tables count should be 2.", 2, nstate.getTables().size());
- assertEquals("Total regions count should be.", 8, nstate.getRegionCount());
+ assertEquals(2, nstate.getTables().size(), "Total tables count should be 2.");
+ assertEquals(8, nstate.getRegionCount(), "Total regions count should be.");
ADMIN.deleteSnapshot(snapshot);
}
@@ -679,7 +674,7 @@ public void testRestoreSnapshot() throws Exception {
NamespaceDescriptor nspDesc = NamespaceDescriptor.create(nsp)
.addConfiguration(TableNamespaceManager.KEY_MAX_REGIONS, "10").build();
ADMIN.createNamespace(nspDesc);
- assertNotNull("Namespace descriptor found null.", ADMIN.getNamespaceDescriptor(nsp));
+ assertNotNull(ADMIN.getNamespaceDescriptor(nsp), "Namespace descriptor found null.");
TableName tableName1 = TableName.valueOf(nsp + TableName.NAMESPACE_DELIM + "table1");
ColumnFamilyDescriptor columnFamilyDescriptor =
ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes("fam1")).build();
@@ -688,7 +683,7 @@ public void testRestoreSnapshot() throws Exception {
ADMIN.createTable(tableDescOne.build(), Bytes.toBytes("AAA"), Bytes.toBytes("ZZZ"), 4);
NamespaceTableAndRegionInfo nstate = getNamespaceState(nsp);
- assertEquals("Intial region count should be 4.", 4, nstate.getRegionCount());
+ assertEquals(4, nstate.getRegionCount(), "Intial region count should be 4.");
String snapshot = "snapshot_testRestoreSnapshot";
ADMIN.snapshot(snapshot, tableName1);
@@ -698,12 +693,12 @@ public void testRestoreSnapshot() throws Exception {
ADMIN.split(tableName1, Bytes.toBytes("JJJ"));
Thread.sleep(2000);
- assertEquals("Total regions count should be 5.", 5, nstate.getRegionCount());
+ assertEquals(5, nstate.getRegionCount(), "Total regions count should be 5.");
ADMIN.disableTable(tableName1);
ADMIN.restoreSnapshot(snapshot);
- assertEquals("Total regions count should be 4 after restore.", 4, nstate.getRegionCount());
+ assertEquals(4, nstate.getRegionCount(), "Total regions count should be 4 after restore.");
ADMIN.enableTable(tableName1);
ADMIN.deleteSnapshot(snapshot);
@@ -716,7 +711,7 @@ public void testRestoreSnapshotQuotaExceed() throws Exception {
.addConfiguration(TableNamespaceManager.KEY_MAX_REGIONS, "10").build();
ADMIN.createNamespace(nspDesc);
NamespaceDescriptor ndesc = ADMIN.getNamespaceDescriptor(nsp);
- assertNotNull("Namespace descriptor found null.", ndesc);
+ assertNotNull(ndesc, "Namespace descriptor found null.");
TableName tableName1 = TableName.valueOf(nsp + TableName.NAMESPACE_DELIM + "table1");
ColumnFamilyDescriptor columnFamilyDescriptor =
ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes("fam1")).build();
@@ -726,7 +721,7 @@ public void testRestoreSnapshotQuotaExceed() throws Exception {
ADMIN.createTable(tableDescOne.build(), Bytes.toBytes("AAA"), Bytes.toBytes("ZZZ"), 4);
NamespaceTableAndRegionInfo nstate = getNamespaceState(nsp);
- assertEquals("Intial region count should be 4.", 4, nstate.getRegionCount());
+ assertEquals(4, nstate.getRegionCount(), "Intial region count should be 4.");
String snapshot = "snapshot_testRestoreSnapshotQuotaExceed";
// snapshot has 4 regions
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/EnableRSGroupsTestBase.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/EnableRSGroupsTestBase.java
index 29274cb3e5ca..d21fd3586b6e 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/EnableRSGroupsTestBase.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/EnableRSGroupsTestBase.java
@@ -18,16 +18,16 @@
package org.apache.hadoop.hbase.rsgroup;
import static java.lang.Thread.sleep;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -37,14 +37,14 @@ public abstract class EnableRSGroupsTestBase {
private static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
final Configuration conf = TEST_UTIL.getConfiguration();
conf.setBoolean(CoprocessorHost.COPROCESSORS_ENABLED_CONF_KEY, true);
TEST_UTIL.startMiniCluster(5);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
LOG.info("to stop miniCluster");
TEST_UTIL.shutdownMiniCluster();
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestEnableRSGroups.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestEnableRSGroups.java
index 6a9812d2371d..0d04c6ada478 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestEnableRSGroups.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestEnableRSGroups.java
@@ -18,19 +18,14 @@
package org.apache.hadoop.hbase.rsgroup;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.RSGroupTests;
-import org.junit.ClassRule;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
-@Category({ RSGroupTests.class, MediumTests.class })
+@Tag(RSGroupTests.TAG)
+@Tag(MediumTests.TAG)
public class TestEnableRSGroups extends EnableRSGroupsTestBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestEnableRSGroups.class);
-
@Override
protected void enableRSGroup(Configuration conf) {
conf.setBoolean(RSGroupUtil.RS_GROUP_ENABLED, true);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestEnableRSGroupsCompatibility.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestEnableRSGroupsCompatibility.java
index 514227c42bde..95765d47c84e 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestEnableRSGroupsCompatibility.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestEnableRSGroupsCompatibility.java
@@ -18,25 +18,20 @@
package org.apache.hadoop.hbase.rsgroup;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.RSGroupTests;
-import org.junit.ClassRule;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
/**
* Test enable RSGroup using the old coprocessor way, to make sure that we keep compatible with old
* config way.
*/
-@Category({ RSGroupTests.class, MediumTests.class })
+@Tag(RSGroupTests.TAG)
+@Tag(MediumTests.TAG)
public class TestEnableRSGroupsCompatibility extends EnableRSGroupsTestBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestEnableRSGroupsCompatibility.class);
-
@Override
protected void enableRSGroup(Configuration conf) {
conf.set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY, RSGroupAdminEndpoint.class.getName());
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestMigrateRSGroupInfo.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestMigrateRSGroupInfo.java
index 64470b9d3878..099d4f91cf28 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestMigrateRSGroupInfo.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestMigrateRSGroupInfo.java
@@ -20,13 +20,12 @@
import static org.apache.hadoop.hbase.rsgroup.RSGroupInfoManagerImpl.META_FAMILY_BYTES;
import static org.apache.hadoop.hbase.rsgroup.RSGroupInfoManagerImpl.META_QUALIFIER_BYTES;
import static org.apache.hadoop.hbase.rsgroup.RSGroupInfoManagerImpl.RSGROUP_TABLE_NAME;
-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.concurrent.CountDownLatch;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableDescriptors;
import org.apache.hadoop.hbase.TableName;
@@ -41,11 +40,11 @@
import org.apache.hadoop.hbase.testclassification.RSGroupTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.zookeeper.KeeperException;
-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.junit.jupiter.api.TestInfo;
import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupProtos;
@@ -53,13 +52,10 @@
/**
* Testcase for HBASE-22819
*/
-@Category({ RSGroupTests.class, MediumTests.class })
+@Tag(RSGroupTests.TAG)
+@Tag(MediumTests.TAG)
public class TestMigrateRSGroupInfo extends TestRSGroupsBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestMigrateRSGroupInfo.class);
-
private static String TABLE_NAME_PREFIX = "Table_";
private static int NUM_TABLES = 10;
@@ -68,7 +64,7 @@ public class TestMigrateRSGroupInfo extends TestRSGroupsBase {
private static RSGroupAdminClient RS_GROUP_ADMIN_CLIENT;
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
TEST_UTIL.getConfiguration().setClass(HConstants.MASTER_IMPL, HMasterForTest.class,
HMaster.class);
@@ -83,7 +79,7 @@ public static void setUp() throws Exception {
}
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
tearDownAfterClass();
}
@@ -115,8 +111,8 @@ public TableDescriptors getTableDescriptors() {
}
@Test
- public void testMigrate() throws IOException, InterruptedException {
- String groupName = getNameWithoutIndex(name.getMethodName());
+ public void testMigrate(TestInfo testInfo) throws IOException, InterruptedException {
+ String groupName = getNameWithoutIndex(testInfo.getTestMethod().get().getName());
addGroup(groupName, TEST_UTIL.getMiniHBaseCluster().getRegionServerThreads().size() - 1);
RSGroupInfo rsGroupInfo = ADMIN.getRSGroup(groupName);
assertTrue(rsGroupInfo.getTables().isEmpty());
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupConfig.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupConfig.java
index c8f64f9409db..a53f4a6daa89 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupConfig.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupConfig.java
@@ -17,43 +17,34 @@
*/
package org.apache.hadoop.hbase.rsgroup;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.HashMap;
import java.util.Map;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.constraint.ConstraintException;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.RSGroupTests;
-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.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ RSGroupTests.class, MediumTests.class })
+@Tag(RSGroupTests.TAG)
+@Tag(MediumTests.TAG)
public class TestRSGroupConfig extends TestRSGroupsBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRSGroupConfig.class);
-
- @Rule
- public TestName name = new TestName();
-
protected static final Logger LOG = LoggerFactory.getLogger(TestRSGroupConfig.class);
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
TestRSGroupsBase.setUpTestBeforeClass();
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() throws Exception {
TestRSGroupsBase.tearDownAfterClass();
}
@@ -64,8 +55,8 @@ public void testSetDefaultGroupConfiguration() {
}
@Test
- public void testSetNonDefaultGroupConfiguration() throws Exception {
- String group = GROUP_PREFIX + name.getMethodName();
+ public void testSetNonDefaultGroupConfiguration(TestInfo testInfo) throws Exception {
+ String group = GROUP_PREFIX + testInfo.getTestMethod().get().getName();
ADMIN.addRSGroup(group);
testSetConfiguration(group);
ADMIN.removeRSGroup(group);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupMappingScript.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupMappingScript.java
index 21a70a157c7d..b2bd797c98a0 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupMappingScript.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupMappingScript.java
@@ -17,47 +17,43 @@
*/
package org.apache.hadoop.hbase.rsgroup;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.rsgroup.RSGroupInfoManagerImpl.RSGroupMappingScript;
import org.apache.hadoop.hbase.testclassification.RSGroupTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
-import org.junit.After;
-import org.junit.Assert;
-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;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ RSGroupTests.class, SmallTests.class })
+@Tag(RSGroupTests.TAG)
+@Tag(SmallTests.TAG)
public class TestRSGroupMappingScript {
-
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRSGroupMappingScript.class);
private static final Logger LOG = LoggerFactory.getLogger(TestRSGroupMappingScript.class);
private static final HBaseTestingUtil UTIL = new HBaseTestingUtil();
private File script;
- @BeforeClass
+ @BeforeAll
public static void setupScript() throws Exception {
String currentDir = new File("").getAbsolutePath();
UTIL.getConfiguration().set(RSGroupInfoManagerImpl.RSGroupMappingScript.RS_GROUP_MAPPING_SCRIPT,
currentDir + "/rsgroup_table_mapping.sh");
}
- @Before
+ @BeforeEach
public void setup() throws Exception {
script = new File(UTIL.getConfiguration().get(RSGroupMappingScript.RS_GROUP_MAPPING_SCRIPT));
if (!script.createNewFile()) {
@@ -99,19 +95,19 @@ public void testScript() throws Exception {
TableName testNamespace = TableName.valueOf("test", "should_be_in_test");
String rsgroup =
script.getRSGroup(testNamespace.getNamespaceAsString(), testNamespace.getQualifierAsString());
- Assert.assertEquals("test", rsgroup);
+ assertEquals("test", rsgroup);
TableName otherName = TableName.valueOf("whatever", "oh_foo_should_be_in_other");
rsgroup = script.getRSGroup(otherName.getNamespaceAsString(), otherName.getQualifierAsString());
- Assert.assertEquals("other", rsgroup);
+ assertEquals("other", rsgroup);
TableName defaultName = TableName.valueOf("nono", "should_be_in_default");
rsgroup =
script.getRSGroup(defaultName.getNamespaceAsString(), defaultName.getQualifierAsString());
- Assert.assertEquals("default", rsgroup);
+ assertEquals("default", rsgroup);
}
- @After
+ @AfterEach
public void teardown() throws Exception {
if (script.exists()) {
script.delete();
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin1.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin1.java
index 4cdb7c208743..f4e6b4e71e57 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin1.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin1.java
@@ -17,18 +17,17 @@
*/
package org.apache.hadoop.hbase.rsgroup;
-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.Assert.fail;
+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.junit.jupiter.api.Assertions.fail;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableExistsException;
@@ -45,43 +44,40 @@
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.RSGroupTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.After;
-import org.junit.AfterClass;
-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.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.Test;
+import org.junit.jupiter.api.TestInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hbase.thirdparty.com.google.common.collect.Sets;
-@Category({ RSGroupTests.class, MediumTests.class })
+@Tag(RSGroupTests.TAG)
+@Tag(MediumTests.TAG)
public class TestRSGroupsAdmin1 extends TestRSGroupsBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRSGroupsAdmin1.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestRSGroupsAdmin1.class);
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
setUpTestBeforeClass();
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
tearDownAfterClass();
}
- @Before
- public void beforeMethod() throws Exception {
- setUpBeforeMethod();
+ @BeforeEach
+ public void beforeMethod(TestInfo testInfo) throws Exception {
+ setUpBeforeMethod(testInfo);
}
- @After
+ @AfterEach
public void afterMethod() throws Exception {
tearDownAfterMethod();
}
@@ -437,8 +433,8 @@ public void testRSGroupListDoesNotContainFailedTableCreation() throws Exception
assertTrue(exp instanceof IOException);
constraintViolated = true;
} finally {
- assertTrue("Constraint not violated for table " + tableDescTwo.getTableName(),
- constraintViolated);
+ assertTrue(constraintViolated,
+ "Constraint not violated for table " + tableDescTwo.getTableName());
}
List rsGroupInfoList = ADMIN.listRSGroups();
boolean foundTable2 = false;
@@ -453,8 +449,8 @@ public void testRSGroupListDoesNotContainFailedTableCreation() throws Exception
foundTable1 = true;
}
}
- assertFalse("Found table2 in rsgroup list.", foundTable2);
- assertTrue("Did not find table1 in rsgroup list", foundTable1);
+ assertFalse(foundTable2, "Found table2 in rsgroup list.");
+ assertTrue(foundTable1, "Did not find table1 in rsgroup list");
TEST_UTIL.deleteTable(tableDescOne.getTableName());
ADMIN.deleteNamespace(nspDesc.getName());
@@ -486,7 +482,7 @@ public boolean evaluate() throws Exception {
}
});
Set tables = Sets.newHashSet(ADMIN.listTablesInRSGroup(RSGroupInfo.DEFAULT_GROUP));
- assertTrue("Table 't1' must be in 'default' rsgroup", tables.contains(tn1));
+ assertTrue(tables.contains(tn1), "Table 't1' must be in 'default' rsgroup");
// Cleanup
TEST_UTIL.deleteTable(tn1);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin2.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin2.java
index d58667b89d52..024a3164de14 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin2.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin2.java
@@ -18,10 +18,10 @@
package org.apache.hadoop.hbase.rsgroup;
import static org.apache.hadoop.hbase.util.Threads.sleep;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-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.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.IOException;
import java.util.ArrayList;
@@ -35,7 +35,6 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function;
import org.apache.hadoop.hbase.ClusterMetrics.Option;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.Waiter;
@@ -49,44 +48,41 @@
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.Pair;
-import org.junit.After;
-import org.junit.AfterClass;
-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.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.Test;
+import org.junit.jupiter.api.TestInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hbase.thirdparty.com.google.common.base.Preconditions;
import org.apache.hbase.thirdparty.com.google.common.collect.Sets;
-@Category({ RSGroupTests.class, LargeTests.class })
+@Tag(RSGroupTests.TAG)
+@Tag(LargeTests.TAG)
public class TestRSGroupsAdmin2 extends TestRSGroupsBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRSGroupsAdmin2.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestRSGroupsAdmin2.class);
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
setUpTestBeforeClass();
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
tearDownAfterClass();
}
- @Before
- public void beforeMethod() throws Exception {
- setUpBeforeMethod();
+ @BeforeEach
+ public void beforeMethod(TestInfo testInfo) throws Exception {
+ setUpBeforeMethod(testInfo);
}
- @After
+ @AfterEach
public void afterMethod() throws Exception {
tearDownAfterMethod();
}
@@ -193,7 +189,7 @@ public void testMoveServers() throws Exception {
} catch (IOException ex) {
String exp = "Server foo:9999 is either offline or it does not exist.";
String msg = "Expected '" + exp + "' in exception message: ";
- assertTrue(msg + " " + ex.getMessage(), ex.getMessage().contains(exp));
+ assertTrue(ex.getMessage().contains(exp), msg + " " + ex.getMessage());
}
// test success case
@@ -242,7 +238,7 @@ public void testRemoveServers() throws Exception {
String exp =
"Server " + targetServer.getAddress() + " is an online server, not allowed to remove.";
String msg = "Expected '" + exp + "' in exception message: ";
- assertTrue(msg + " " + ex.getMessage(), ex.getMessage().contains(exp));
+ assertTrue(ex.getMessage().contains(exp), msg + " " + ex.getMessage());
}
assertTrue(newGroup.getServers().contains(targetServer.getAddress()));
@@ -273,7 +269,7 @@ public boolean evaluate() throws Exception {
String exp = "Server " + targetServer.getAddress() + " is on the dead servers list,"
+ " Maybe it will come back again, not allowed to remove.";
String msg = "Expected '" + exp + "' in exception message: ";
- assertTrue(msg + " " + ex.getMessage(), ex.getMessage().contains(exp));
+ assertTrue(ex.getMessage().contains(exp), msg + " " + ex.getMessage());
}
assertTrue(newGroup.getServers().contains(targetServer.getAddress()));
@@ -343,7 +339,7 @@ public boolean evaluate() throws Exception {
} catch (IOException ex) {
String exp = "Server foo:9999 is either offline or it does not exist.";
String msg = "Expected '" + exp + "' in exception message: ";
- assertTrue(msg + " " + ex.getMessage(), ex.getMessage().contains(exp));
+ assertTrue(ex.getMessage().contains(exp), msg + " " + ex.getMessage());
}
// test move when src = dst
@@ -726,7 +722,7 @@ public boolean evaluate() throws Exception {
// This test case is meant to be used for verifying the performance quickly by a developer.
// Moving 100 regions takes much less than 15000 ms. Given 15000 ms so test cases passes
// on all environment.
- assertTrue(msg, timeTaken < 15000);
+ assertTrue(timeTaken < 15000, msg);
LOG.info("Time taken to move a table with 100 region is {} ms", timeTaken);
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBalance.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBalance.java
index fc87c00dfe2d..e596145218a9 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBalance.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBalance.java
@@ -17,13 +17,12 @@
*/
package org.apache.hadoop.hbase.rsgroup;
-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 java.util.List;
import java.util.Map;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.ServerName;
@@ -40,41 +39,38 @@
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.RSGroupTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.After;
-import org.junit.AfterClass;
-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.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.Test;
+import org.junit.jupiter.api.TestInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ RSGroupTests.class, MediumTests.class })
+@Tag(RSGroupTests.TAG)
+@Tag(MediumTests.TAG)
public class TestRSGroupsBalance extends TestRSGroupsBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRSGroupsBalance.class);
-
protected static final Logger LOG = LoggerFactory.getLogger(TestRSGroupsBalance.class);
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
setUpTestBeforeClass();
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
tearDownAfterClass();
}
- @Before
- public void beforeMethod() throws Exception {
- setUpBeforeMethod();
+ @BeforeEach
+ public void beforeMethod(TestInfo testInfo) throws Exception {
+ setUpBeforeMethod(testInfo);
}
- @After
+ @AfterEach
public void afterMethod() throws Exception {
tearDownAfterMethod();
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBase.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBase.java
index 86d73b03f500..468b03963c4b 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBase.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBase.java
@@ -17,7 +17,7 @@
*/
package org.apache.hadoop.hbase.rsgroup;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.util.ArrayList;
@@ -58,8 +58,7 @@
import org.apache.hadoop.hbase.master.snapshot.SnapshotManager;
import org.apache.hadoop.hbase.net.Address;
import org.apache.hadoop.hbase.quotas.QuotaUtil;
-import org.junit.Rule;
-import org.junit.rules.TestName;
+import org.junit.jupiter.api.TestInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -85,9 +84,20 @@ public abstract class TestRSGroupsBase extends AbstractTestUpdateConfiguration {
public final static int NUM_SLAVES_BASE = 4; // number of slaves for the smallest cluster
public static int NUM_DEAD_SERVERS = 0;
+ protected static final class MethodName {
+ private String methodName;
+
+ public String getMethodName() {
+ return methodName;
+ }
+
+ void setMethodName(String methodName) {
+ this.methodName = methodName;
+ }
+ }
+
// Per test variables
- @Rule
- public TestName name = new TestName();
+ protected final MethodName name = new MethodName();
protected TableName tableName;
public static String getNameWithoutIndex(String name) {
@@ -138,7 +148,8 @@ public static void tearDownAfterClass() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
- public void setUpBeforeMethod() throws Exception {
+ public void setUpBeforeMethod(TestInfo testInfo) throws Exception {
+ name.setMethodName(testInfo.getTestMethod().get().getName());
LOG.info(name.getMethodName());
tableName = TableName.valueOf(TABLE_PREFIX + "_" + name.getMethodName().split("\\[")[0]);
if (!INIT) {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBasics.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBasics.java
index 8bd4489559bc..03ceee04bbfe 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBasics.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBasics.java
@@ -17,14 +17,13 @@
*/
package org.apache.hadoop.hbase.rsgroup;
-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 java.io.IOException;
import java.util.List;
import java.util.Set;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
@@ -37,44 +36,40 @@
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.RSGroupTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Assert;
-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.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.Test;
+import org.junit.jupiter.api.TestInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hbase.thirdparty.com.google.common.collect.Lists;
-@Category({ RSGroupTests.class, MediumTests.class })
+@Tag(RSGroupTests.TAG)
+@Tag(MediumTests.TAG)
public class TestRSGroupsBasics extends TestRSGroupsBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRSGroupsBasics.class);
-
protected static final Logger LOG = LoggerFactory.getLogger(TestRSGroupsBasics.class);
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
setUpTestBeforeClass();
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
tearDownAfterClass();
}
- @Before
- public void beforeMethod() throws Exception {
- setUpBeforeMethod();
+ @BeforeEach
+ public void beforeMethod(TestInfo testInfo) throws Exception {
+ setUpBeforeMethod(testInfo);
}
- @After
+ @AfterEach
public void afterMethod() throws Exception {
tearDownAfterMethod();
}
@@ -132,7 +127,7 @@ public boolean evaluate() throws Exception {
});
ServerName targetServer = getServerName(appInfo.getServers().iterator().next());
// verify it was assigned to the right group
- Assert.assertEquals(1, ADMIN.getRegions(targetServer).size());
+ assertEquals(1, ADMIN.getRegions(targetServer).size());
}
@Test
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsCPHookCalled.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsCPHookCalled.java
index cb53f77bce56..7c2f6003b31e 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsCPHookCalled.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsCPHookCalled.java
@@ -17,45 +17,41 @@
*/
package org.apache.hadoop.hbase.rsgroup;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.SingleProcessHBaseCluster;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.RSGroupTests;
-import org.junit.After;
-import org.junit.AfterClass;
-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.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.Test;
+import org.junit.jupiter.api.TestInfo;
-@Category({ RSGroupTests.class, MediumTests.class })
+@Tag(RSGroupTests.TAG)
+@Tag(MediumTests.TAG)
public class TestRSGroupsCPHookCalled extends TestRSGroupsBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRSGroupsCPHookCalled.class);
-
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
setUpTestBeforeClass();
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
tearDownAfterClass();
}
- @Before
- public void beforeMethod() throws Exception {
- setUpBeforeMethod();
+ @BeforeEach
+ public void beforeMethod(TestInfo testInfo) throws Exception {
+ setUpBeforeMethod(testInfo);
}
- @After
+ @AfterEach
public void afterMethod() throws Exception {
tearDownAfterMethod();
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsFallback.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsFallback.java
index 8cb35cbad1e2..ab1ed04fcf79 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsFallback.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsFallback.java
@@ -17,12 +17,11 @@
*/
package org.apache.hadoop.hbase.rsgroup;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.util.Collections;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName;
@@ -37,28 +36,25 @@
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.JVMClusterUtil;
import org.apache.hadoop.hbase.util.Threads;
-import org.junit.After;
-import org.junit.AfterClass;
-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.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.Test;
+import org.junit.jupiter.api.TestInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Category({ RSGroupTests.class, MediumTests.class })
+@Tag(RSGroupTests.TAG)
+@Tag(MediumTests.TAG)
public class TestRSGroupsFallback extends TestRSGroupsBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRSGroupsFallback.class);
-
protected static final Logger LOG = LoggerFactory.getLogger(TestRSGroupsFallback.class);
private static final String FALLBACK_GROUP = "fallback";
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
Configuration conf = TEST_UTIL.getConfiguration();
conf.setBoolean(RSGroupBasedLoadBalancer.FALLBACK_GROUP_ENABLE_KEY, true);
@@ -67,17 +63,17 @@ public static void setUp() throws Exception {
MASTER.balanceSwitch(true);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
tearDownAfterClass();
}
- @Before
- public void beforeMethod() throws Exception {
- setUpBeforeMethod();
+ @BeforeEach
+ public void beforeMethod(TestInfo testInfo) throws Exception {
+ setUpBeforeMethod(testInfo);
}
- @After
+ @AfterEach
public void afterMethod() throws Exception {
tearDownAfterMethod();
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsKillRS.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsKillRS.java
index 9b73e71263d8..b22c8317baca 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsKillRS.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsKillRS.java
@@ -18,8 +18,8 @@
package org.apache.hadoop.hbase.rsgroup;
import static org.apache.hadoop.hbase.util.Threads.sleep;
-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.lang.reflect.Field;
import java.util.ArrayList;
@@ -27,7 +27,6 @@
import java.util.List;
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.NamespaceDescriptor;
import org.apache.hadoop.hbase.ServerName;
@@ -47,28 +46,25 @@
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.JVMClusterUtil;
import org.apache.hadoop.hbase.util.VersionInfo;
-import org.junit.After;
-import org.junit.AfterClass;
-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.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.Test;
+import org.junit.jupiter.api.TestInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hbase.thirdparty.com.google.common.collect.Sets;
-@Category({ RSGroupTests.class, LargeTests.class })
+@Tag(RSGroupTests.TAG)
+@Tag(LargeTests.TAG)
public class TestRSGroupsKillRS extends TestRSGroupsBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRSGroupsKillRS.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestRSGroupsKillRS.class);
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
// avoid all the handlers blocked when meta is offline, and regionServerReport can not be
// processed which causes dead lock.
@@ -78,17 +74,17 @@ public static void setUp() throws Exception {
setUpTestBeforeClass();
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
tearDownAfterClass();
}
- @Before
- public void beforeMethod() throws Exception {
- setUpBeforeMethod();
+ @BeforeEach
+ public void beforeMethod(TestInfo testInfo) throws Exception {
+ setUpBeforeMethod(testInfo);
}
- @After
+ @AfterEach
public void afterMethod() throws Exception {
tearDownAfterMethod();
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsOfflineMode.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsOfflineMode.java
index 7d8af16b9a1c..89a8fdeec367 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsOfflineMode.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsOfflineMode.java
@@ -17,10 +17,9 @@
*/
package org.apache.hadoop.hbase.rsgroup;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseClusterInterface;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.SingleProcessHBaseCluster;
@@ -35,13 +34,11 @@
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.RSGroupTests;
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.rules.TestName;
+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.TestInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -57,13 +54,10 @@
* online. In new master, RSGroupInfoManagerImpl gets the data from zk and waits for the expected
* assignment with a timeout.
*/
-@Category({ RSGroupTests.class, MediumTests.class })
+@Tag(RSGroupTests.TAG)
+@Tag(MediumTests.TAG)
public class TestRSGroupsOfflineMode extends TestRSGroupsBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRSGroupsOfflineMode.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestRSGroupsOfflineMode.class);
private static HMaster master;
private static Admin hbaseAdmin;
@@ -71,10 +65,7 @@ public class TestRSGroupsOfflineMode extends TestRSGroupsBase {
private static HBaseClusterInterface cluster;
private final static long WAIT_TIMEOUT = 60000 * 5;
- @Rule
- public TestName name = new TestName();
-
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
TEST_UTIL = new HBaseTestingUtil();
RSGroupUtil.enableRSGroup(TEST_UTIL.getConfiguration());
@@ -97,15 +88,16 @@ public boolean evaluate() throws Exception {
});
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
@Test
- public void testOffline() throws Exception, InterruptedException {
+ public void testOffline(TestInfo testInfo) throws Exception, InterruptedException {
// Table should be after group table name so it gets assigned later.
- final TableName failoverTable = TableName.valueOf(getNameWithoutIndex(name.getMethodName()));
+ final TableName failoverTable =
+ TableName.valueOf(getNameWithoutIndex(testInfo.getTestMethod().get().getName()));
TEST_UTIL.createTable(failoverTable, Bytes.toBytes("f"));
final HRegionServer killRS = ((SingleProcessHBaseCluster) cluster).getRegionServer(0);
final HRegionServer groupRS = ((SingleProcessHBaseCluster) cluster).getRegionServer(1);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsWithACL.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsWithACL.java
index 542bd60d0d29..170cb5e607b5 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsWithACL.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsWithACL.java
@@ -18,13 +18,12 @@
package org.apache.hadoop.hbase.rsgroup;
import static org.apache.hadoop.hbase.AuthUtil.toGroupEntry;
-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.Optional;
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.TableNotFoundException;
@@ -43,11 +42,10 @@
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.SecurityTests;
import org.apache.hadoop.hbase.util.Bytes;
-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;
@@ -55,13 +53,10 @@
* Performs authorization checks for rsgroup operations, according to different levels of authorized
* users.
*/
-@Category({ SecurityTests.class, MediumTests.class })
+@Tag(SecurityTests.TAG)
+@Tag(MediumTests.TAG)
public class TestRSGroupsWithACL extends SecureTestUtil {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestRSGroupsWithACL.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestRSGroupsWithACL.class);
private static TableName TEST_TABLE = TableName.valueOf("testtable1");
private static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
@@ -98,7 +93,7 @@ public class TestRSGroupsWithACL extends SecureTestUtil {
private static AccessChecker accessChecker;
private static UserProvider userProvider;
- @BeforeClass
+ @BeforeAll
public static void setupBeforeClass() throws Exception {
// setup configuration
conf = TEST_UTIL.getConfiguration();
@@ -207,7 +202,7 @@ private static void cleanUp() throws Exception {
PermissionStorage.getNamespacePermissions(conf, TEST_TABLE.getNamespaceAsString()).size());
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() throws Exception {
cleanUp();
TEST_UTIL.shutdownMiniCluster();
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestUpdateRSGroupConfiguration.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestUpdateRSGroupConfiguration.java
index b530e8768113..73b96e12140f 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestUpdateRSGroupConfiguration.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestUpdateRSGroupConfiguration.java
@@ -17,54 +17,49 @@
*/
package org.apache.hadoop.hbase.rsgroup;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.net.Address;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.JVMClusterUtil;
-import org.junit.After;
-import org.junit.AfterClass;
-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.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.Test;
+import org.junit.jupiter.api.TestInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hbase.thirdparty.com.google.common.collect.Iterables;
-@Category({ MediumTests.class })
+@Tag(MediumTests.TAG)
public class TestUpdateRSGroupConfiguration extends TestRSGroupsBase {
protected static final Logger LOG = LoggerFactory.getLogger(TestUpdateRSGroupConfiguration.class);
-
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestUpdateRSGroupConfiguration.class);
private static final String TEST_GROUP = "test";
private static final String TEST2_GROUP = "test2";
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
setUpConfigurationFiles(TEST_UTIL);
setUpTestBeforeClass();
addResourceToRegionServerConfiguration(TEST_UTIL);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
tearDownAfterClass();
}
- @Before
- public void beforeMethod() throws Exception {
- setUpBeforeMethod();
+ @BeforeEach
+ public void beforeMethod(TestInfo testInfo) throws Exception {
+ setUpBeforeMethod(testInfo);
}
- @After
+ @AfterEach
public void afterMethod() throws Exception {
tearDownAfterMethod();
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/VerifyingRSGroupAdmin.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/VerifyingRSGroupAdmin.java
index a13a00ddef10..79364e813c24 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/VerifyingRSGroupAdmin.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/VerifyingRSGroupAdmin.java
@@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hbase.rsgroup;
-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.Closeable;
| |