org.bouncycastle
bcprov-jdk18on
diff --git a/hbase-asyncfs/src/test/java/org/apache/hadoop/hbase/io/asyncfs/TestExcludeDatanodeManager.java b/hbase-asyncfs/src/test/java/org/apache/hadoop/hbase/io/asyncfs/TestExcludeDatanodeManager.java
index f7ca1639ec60..2a6f517c8378 100644
--- a/hbase-asyncfs/src/test/java/org/apache/hadoop/hbase/io/asyncfs/TestExcludeDatanodeManager.java
+++ b/hbase-asyncfs/src/test/java/org/apache/hadoop/hbase/io/asyncfs/TestExcludeDatanodeManager.java
@@ -17,27 +17,23 @@
*/
package org.apache.hadoop.hbase.io.asyncfs;
-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.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.io.asyncfs.monitor.ExcludeDatanodeManager;
import org.apache.hadoop.hbase.io.asyncfs.monitor.StreamSlowMonitor;
+import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category({ SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
public class TestExcludeDatanodeManager {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestExcludeDatanodeManager.class);
-
@Test
public void testExcludeSlowDNBySpeed() {
Configuration conf = HBaseConfiguration.create();
diff --git a/hbase-asyncfs/src/test/java/org/apache/hadoop/hbase/io/asyncfs/TestFanOutOneBlockAsyncDFSOutput.java b/hbase-asyncfs/src/test/java/org/apache/hadoop/hbase/io/asyncfs/TestFanOutOneBlockAsyncDFSOutput.java
index f0910684eddf..63be7bc9cf55 100644
--- a/hbase-asyncfs/src/test/java/org/apache/hadoop/hbase/io/asyncfs/TestFanOutOneBlockAsyncDFSOutput.java
+++ b/hbase-asyncfs/src/test/java/org/apache/hadoop/hbase/io/asyncfs/TestFanOutOneBlockAsyncDFSOutput.java
@@ -21,9 +21,9 @@
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_CLIENT_SOCKET_TIMEOUT_KEY;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -38,7 +38,6 @@
import org.apache.hadoop.fs.FSDataInputStream;
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.io.asyncfs.monitor.ExcludeDatanodeManager;
import org.apache.hadoop.hbase.io.asyncfs.monitor.StreamSlowMonitor;
@@ -49,15 +48,12 @@
import org.apache.hadoop.hdfs.MiniDFSCluster.DataNodeProperties;
import org.apache.hadoop.hdfs.server.datanode.DataNode;
import org.apache.hadoop.ipc.RemoteException;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.FixMethodOrder;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TestName;
-import org.junit.runners.MethodSorters;
+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;
@@ -67,14 +63,10 @@
import org.apache.hbase.thirdparty.io.netty.channel.nio.NioEventLoopGroup;
import org.apache.hbase.thirdparty.io.netty.channel.socket.nio.NioSocketChannel;
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-@Category({ MiscTests.class, MediumTests.class })
+@Tag(MiscTests.TAG)
+@Tag(MediumTests.TAG)
public class TestFanOutOneBlockAsyncDFSOutput extends AsyncFSTestBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestFanOutOneBlockAsyncDFSOutput.class);
-
private static final Logger LOG = LoggerFactory.getLogger(TestFanOutOneBlockAsyncDFSOutput.class);
private static DistributedFileSystem FS;
private static EventLoopGroup EVENT_LOOP_GROUP;
@@ -83,10 +75,9 @@ public class TestFanOutOneBlockAsyncDFSOutput extends AsyncFSTestBase {
private static StreamSlowMonitor MONITOR;
- @Rule
- public TestName name = new TestName();
+ private Path file;
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
UTIL.getConfiguration().setInt(DFS_CLIENT_SOCKET_TIMEOUT_KEY, READ_TIMEOUT_MS);
startMiniDFSCluster(3);
@@ -96,7 +87,7 @@ public static void setUp() throws Exception {
MONITOR = StreamSlowMonitor.create(UTIL.getConfiguration(), "testMonitor");
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
if (EVENT_LOOP_GROUP != null) {
EVENT_LOOP_GROUP.shutdownGracefully().get();
@@ -136,13 +127,17 @@ static void writeAndVerify(FileSystem fs, Path f, AsyncFSOutput out)
}
}
+ @BeforeEach
+ public void setUpBeforeEach(TestInfo testInfo) {
+ file = new Path("/" + testInfo.getTestMethod().get().getName());
+ }
+
@Test
public void test() throws IOException, InterruptedException, ExecutionException {
- Path f = new Path("/" + name.getMethodName());
EventLoop eventLoop = EVENT_LOOP_GROUP.next();
- FanOutOneBlockAsyncDFSOutput out = FanOutOneBlockAsyncDFSOutputHelper.createOutput(FS, f, true,
- false, (short) 3, FS.getDefaultBlockSize(), eventLoop, CHANNEL_CLASS, MONITOR, true);
- writeAndVerify(FS, f, out);
+ FanOutOneBlockAsyncDFSOutput out = FanOutOneBlockAsyncDFSOutputHelper.createOutput(FS, file,
+ true, false, (short) 3, FS.getDefaultBlockSize(), eventLoop, CHANNEL_CLASS, MONITOR, true);
+ writeAndVerify(FS, file, out);
}
/**
@@ -151,10 +146,9 @@ public void test() throws IOException, InterruptedException, ExecutionException
*/
@Test
public void test0Recover() throws IOException, InterruptedException, ExecutionException {
- Path f = new Path("/" + name.getMethodName());
EventLoop eventLoop = EVENT_LOOP_GROUP.next();
- FanOutOneBlockAsyncDFSOutput out = FanOutOneBlockAsyncDFSOutputHelper.createOutput(FS, f, true,
- false, (short) 3, FS.getDefaultBlockSize(), eventLoop, CHANNEL_CLASS, MONITOR, true);
+ FanOutOneBlockAsyncDFSOutput out = FanOutOneBlockAsyncDFSOutputHelper.createOutput(FS, file,
+ true, false, (short) 3, FS.getDefaultBlockSize(), eventLoop, CHANNEL_CLASS, MONITOR, true);
byte[] b = new byte[10];
Bytes.random(b);
out.write(b, 0, b.length);
@@ -162,17 +156,12 @@ public void test0Recover() throws IOException, InterruptedException, ExecutionEx
// restart one datanode which causes one connection broken
CLUSTER.restartDataNode(0);
out.write(b, 0, b.length);
- try {
- out.flush(false).get();
- fail("flush should fail");
- } catch (ExecutionException e) {
- // we restarted one datanode so the flush should fail
- LOG.info("expected exception caught", e);
- }
+ ExecutionException e = assertThrows(ExecutionException.class, () -> out.flush(false).get());
+ LOG.info("expected exception caught", e);
out.recoverAndClose(null);
- assertEquals(b.length, FS.getFileStatus(f).getLen());
+ assertEquals(b.length, FS.getFileStatus(file).getLen());
byte[] actual = new byte[b.length];
- try (FSDataInputStream in = FS.open(f)) {
+ try (FSDataInputStream in = FS.open(file)) {
in.readFully(actual);
}
assertArrayEquals(b, actual);
@@ -180,13 +169,12 @@ public void test0Recover() throws IOException, InterruptedException, ExecutionEx
@Test
public void testHeartbeat() throws IOException, InterruptedException, ExecutionException {
- Path f = new Path("/" + name.getMethodName());
EventLoop eventLoop = EVENT_LOOP_GROUP.next();
- FanOutOneBlockAsyncDFSOutput out = FanOutOneBlockAsyncDFSOutputHelper.createOutput(FS, f, true,
- false, (short) 3, FS.getDefaultBlockSize(), eventLoop, CHANNEL_CLASS, MONITOR, true);
+ FanOutOneBlockAsyncDFSOutput out = FanOutOneBlockAsyncDFSOutputHelper.createOutput(FS, file,
+ true, false, (short) 3, FS.getDefaultBlockSize(), eventLoop, CHANNEL_CLASS, MONITOR, true);
Thread.sleep(READ_TIMEOUT_MS * 2);
// the connection to datanode should still alive.
- writeAndVerify(FS, f, out);
+ writeAndVerify(FS, file, out);
}
/**
@@ -194,16 +182,13 @@ public void testHeartbeat() throws IOException, InterruptedException, ExecutionE
*/
@Test
public void testCreateParentFailed() throws IOException {
- Path f = new Path("/" + name.getMethodName() + "/test");
+ Path f = new Path(file, "test");
EventLoop eventLoop = EVENT_LOOP_GROUP.next();
- try {
- FanOutOneBlockAsyncDFSOutputHelper.createOutput(FS, f, true, false, (short) 3,
- FS.getDefaultBlockSize(), eventLoop, CHANNEL_CLASS, MONITOR, true);
- fail("should fail with parent does not exist");
- } catch (RemoteException e) {
- LOG.info("expected exception caught", e);
- assertThat(e.unwrapRemoteException(), instanceOf(FileNotFoundException.class));
- }
+ RemoteException e = assertThrows(RemoteException.class,
+ () -> FanOutOneBlockAsyncDFSOutputHelper.createOutput(FS, f, true, false, (short) 3,
+ FS.getDefaultBlockSize(), eventLoop, CHANNEL_CLASS, MONITOR, true));
+ LOG.info("expected exception caught", e);
+ assertThat(e.unwrapRemoteException(), instanceOf(FileNotFoundException.class));
}
@Test
@@ -264,19 +249,18 @@ public void testExcludeFailedConnectToDatanode()
@Test
public void testWriteLargeChunk() throws IOException, InterruptedException, ExecutionException {
- Path f = new Path("/" + name.getMethodName());
EventLoop eventLoop = EVENT_LOOP_GROUP.next();
- FanOutOneBlockAsyncDFSOutput out = FanOutOneBlockAsyncDFSOutputHelper.createOutput(FS, f, true,
- false, (short) 3, 1024 * 1024 * 1024, eventLoop, CHANNEL_CLASS, MONITOR, true);
+ FanOutOneBlockAsyncDFSOutput out = FanOutOneBlockAsyncDFSOutputHelper.createOutput(FS, file,
+ true, false, (short) 3, 1024 * 1024 * 1024, eventLoop, CHANNEL_CLASS, MONITOR, true);
byte[] b = new byte[50 * 1024 * 1024];
Bytes.random(b);
out.write(b);
consume(out.flush(false));
assertEquals(b.length, out.flush(false).get().longValue());
out.close();
- assertEquals(b.length, FS.getFileStatus(f).getLen());
+ assertEquals(b.length, FS.getFileStatus(file).getLen());
byte[] actual = new byte[b.length];
- try (FSDataInputStream in = FS.open(f)) {
+ try (FSDataInputStream in = FS.open(file)) {
in.readFully(actual);
}
assertArrayEquals(b, actual);
diff --git a/hbase-asyncfs/src/test/java/org/apache/hadoop/hbase/io/asyncfs/TestFanOutOneBlockAsyncDFSOutputHang.java b/hbase-asyncfs/src/test/java/org/apache/hadoop/hbase/io/asyncfs/TestFanOutOneBlockAsyncDFSOutputHang.java
index 7f6535a93a93..4f70aaab421c 100644
--- a/hbase-asyncfs/src/test/java/org/apache/hadoop/hbase/io/asyncfs/TestFanOutOneBlockAsyncDFSOutputHang.java
+++ b/hbase-asyncfs/src/test/java/org/apache/hadoop/hbase/io/asyncfs/TestFanOutOneBlockAsyncDFSOutputHang.java
@@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hbase.io.asyncfs;
-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.util.ArrayList;
import java.util.Iterator;
@@ -28,7 +28,6 @@
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.ExecutionException;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.io.asyncfs.monitor.StreamSlowMonitor;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.MiscTests;
@@ -37,13 +36,10 @@
import org.apache.hadoop.hdfs.MiniDFSCluster.DataNodeProperties;
import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
import org.apache.hadoop.hdfs.server.datanode.DataNode;
-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.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -65,13 +61,10 @@
* in this test class we use the default value for timeout which is 60 seconds and it is enough for
* this test.
*/
-@Category({ MiscTests.class, MediumTests.class })
+@Tag(MiscTests.TAG)
+@Tag(MediumTests.TAG)
public class TestFanOutOneBlockAsyncDFSOutputHang extends AsyncFSTestBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestFanOutOneBlockAsyncDFSOutputHang.class);
-
private static final Logger LOG =
LoggerFactory.getLogger(TestFanOutOneBlockAsyncDFSOutputHang.class);
@@ -85,10 +78,7 @@ public class TestFanOutOneBlockAsyncDFSOutputHang extends AsyncFSTestBase {
private static FanOutOneBlockAsyncDFSOutput OUT;
- @Rule
- public TestName name = new TestName();
-
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
startMiniDFSCluster(2);
FS = CLUSTER.getFileSystem();
@@ -101,7 +91,7 @@ public static void setUp() throws Exception {
FS.getDefaultBlockSize(), eventLoop, CHANNEL_CLASS, MONITOR, true);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
if (OUT != null) {
OUT.recoverAndClose(null);
diff --git a/hbase-asyncfs/src/test/java/org/apache/hadoop/hbase/io/asyncfs/TestLeaseRenewal.java b/hbase-asyncfs/src/test/java/org/apache/hadoop/hbase/io/asyncfs/TestLeaseRenewal.java
index e8f7188518d0..02c15e78591a 100644
--- a/hbase-asyncfs/src/test/java/org/apache/hadoop/hbase/io/asyncfs/TestLeaseRenewal.java
+++ b/hbase-asyncfs/src/test/java/org/apache/hadoop/hbase/io/asyncfs/TestLeaseRenewal.java
@@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hbase.io.asyncfs;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mockConstruction;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
@@ -27,7 +27,6 @@
import java.lang.reflect.Method;
import java.util.Optional;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.io.asyncfs.monitor.StreamSlowMonitor;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.MiscTests;
@@ -35,11 +34,10 @@
import org.apache.hadoop.hdfs.DFSOutputStream;
import org.apache.hadoop.hdfs.DistributedFileSystem;
import org.apache.hadoop.hdfs.DummyDFSOutputStream;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.mockito.MockedConstruction;
import org.apache.hbase.thirdparty.io.netty.channel.Channel;
@@ -54,19 +52,16 @@
*
* See HBASE-28955 for more details.
*/
-@Category({ MiscTests.class, MediumTests.class })
+@Tag(MiscTests.TAG)
+@Tag(MediumTests.TAG)
public class TestLeaseRenewal extends AsyncFSTestBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestLeaseRenewal.class);
-
private static DistributedFileSystem FS;
private static EventLoopGroup EVENT_LOOP_GROUP;
private static Class extends Channel> CHANNEL_CLASS;
private static StreamSlowMonitor MONITOR;
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
startMiniDFSCluster(3);
FS = CLUSTER.getFileSystem();
@@ -75,7 +70,7 @@ public static void setUp() throws Exception {
MONITOR = StreamSlowMonitor.create(UTIL.getConfiguration(), "testMonitor");
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
if (EVENT_LOOP_GROUP != null) {
EVENT_LOOP_GROUP.shutdownGracefully().get();
diff --git a/hbase-asyncfs/src/test/java/org/apache/hadoop/hbase/io/asyncfs/TestLocalAsyncOutput.java b/hbase-asyncfs/src/test/java/org/apache/hadoop/hbase/io/asyncfs/TestLocalAsyncOutput.java
index 4171b60c5b82..957ed4f51166 100644
--- a/hbase-asyncfs/src/test/java/org/apache/hadoop/hbase/io/asyncfs/TestLocalAsyncOutput.java
+++ b/hbase-asyncfs/src/test/java/org/apache/hadoop/hbase/io/asyncfs/TestLocalAsyncOutput.java
@@ -21,29 +21,24 @@
import java.util.concurrent.ExecutionException;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseCommonTestingUtil;
import org.apache.hadoop.hbase.io.asyncfs.monitor.StreamSlowMonitor;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.CommonFSUtils;
-import org.junit.AfterClass;
-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.Tag;
+import org.junit.jupiter.api.Test;
import org.apache.hbase.thirdparty.io.netty.channel.Channel;
import org.apache.hbase.thirdparty.io.netty.channel.EventLoopGroup;
import org.apache.hbase.thirdparty.io.netty.channel.nio.NioEventLoopGroup;
import org.apache.hbase.thirdparty.io.netty.channel.socket.nio.NioSocketChannel;
-@Category({ MiscTests.class, SmallTests.class })
+@Tag(MiscTests.TAG)
+@Tag(SmallTests.TAG)
public class TestLocalAsyncOutput {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestLocalAsyncOutput.class);
-
private static EventLoopGroup GROUP = new NioEventLoopGroup();
private static Class extends Channel> CHANNEL_CLASS = NioSocketChannel.class;
@@ -52,7 +47,7 @@ public class TestLocalAsyncOutput {
private static StreamSlowMonitor MONITOR;
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() throws Exception {
TEST_UTIL.cleanupTestDir();
GROUP.shutdownGracefully().get();
diff --git a/hbase-asyncfs/src/test/java/org/apache/hadoop/hbase/io/asyncfs/TestOverwriteFileUnderConstruction.java b/hbase-asyncfs/src/test/java/org/apache/hadoop/hbase/io/asyncfs/TestOverwriteFileUnderConstruction.java
index 7a3a6de10f09..a5bb0de9b339 100644
--- a/hbase-asyncfs/src/test/java/org/apache/hadoop/hbase/io/asyncfs/TestOverwriteFileUnderConstruction.java
+++ b/hbase-asyncfs/src/test/java/org/apache/hadoop/hbase/io/asyncfs/TestOverwriteFileUnderConstruction.java
@@ -19,8 +19,8 @@
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
-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.FileNotFoundException;
import java.io.IOException;
@@ -28,49 +28,40 @@
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hdfs.protocol.AlreadyBeingCreatedException;
import org.apache.hadoop.hdfs.server.namenode.LeaseExpiredException;
import org.apache.hadoop.ipc.RemoteException;
-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;
/**
* Used to confirm that it is OK to overwrite a file which is being written currently.
*/
-@Category({ MiscTests.class, MediumTests.class })
+@Tag(MiscTests.TAG)
+@Tag(MediumTests.TAG)
public class TestOverwriteFileUnderConstruction extends AsyncFSTestBase {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestOverwriteFileUnderConstruction.class);
-
private static FileSystem FS;
- @Rule
- public final TestName name = new TestName();
-
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
startMiniDFSCluster(3);
FS = CLUSTER.getFileSystem();
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
shutdownMiniDFSCluster();
}
@Test
- public void testNotOverwrite() throws IOException {
- Path file = new Path("/" + name.getMethodName());
+ public void testNotOverwrite(TestInfo testInfo) throws IOException {
+ Path file = new Path("/" + testInfo.getDisplayName());
try (FSDataOutputStream out1 = FS.create(file)) {
try {
FS.create(file, false);
@@ -83,8 +74,8 @@ public void testNotOverwrite() throws IOException {
}
@Test
- public void testOverwrite() throws IOException {
- Path file = new Path("/" + name.getMethodName());
+ public void testOverwrite(TestInfo testInfo) throws IOException {
+ Path file = new Path("/" + testInfo.getDisplayName());
FSDataOutputStream out1 = FS.create(file);
FSDataOutputStream out2 = FS.create(file, true);
out1.write(2);
diff --git a/hbase-asyncfs/src/test/java/org/apache/hadoop/hbase/io/asyncfs/TestSaslFanOutOneBlockAsyncDFSOutput.java b/hbase-asyncfs/src/test/java/org/apache/hadoop/hbase/io/asyncfs/TestSaslFanOutOneBlockAsyncDFSOutput.java
index 99048ff2bed1..2e11cdd5326c 100644
--- a/hbase-asyncfs/src/test/java/org/apache/hadoop/hbase/io/asyncfs/TestSaslFanOutOneBlockAsyncDFSOutput.java
+++ b/hbase-asyncfs/src/test/java/org/apache/hadoop/hbase/io/asyncfs/TestSaslFanOutOneBlockAsyncDFSOutput.java
@@ -31,6 +31,7 @@
import java.util.List;
import java.util.Properties;
import java.util.concurrent.ExecutionException;
+import java.util.stream.Stream;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.conf.Configuration;
@@ -38,7 +39,7 @@
import org.apache.hadoop.crypto.key.KeyProvider;
import org.apache.hadoop.crypto.key.KeyProviderFactory;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HBaseParameterizedTestTemplate;
import org.apache.hadoop.hbase.io.asyncfs.monitor.StreamSlowMonitor;
import org.apache.hadoop.hbase.security.HBaseKerberosUtils;
import org.apache.hadoop.hbase.security.SecurityConstants;
@@ -47,19 +48,14 @@
import org.apache.hadoop.hdfs.DistributedFileSystem;
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.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TestName;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameter;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.TestInfo;
+import org.junit.jupiter.api.TestTemplate;
+import org.junit.jupiter.params.provider.Arguments;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -69,17 +65,14 @@
import org.apache.hbase.thirdparty.io.netty.channel.nio.NioEventLoopGroup;
import org.apache.hbase.thirdparty.io.netty.channel.socket.nio.NioSocketChannel;
-@RunWith(Parameterized.class)
-@Category({ MiscTests.class, LargeTests.class })
+@Tag(MiscTests.TAG)
+@Tag(LargeTests.TAG)
+@HBaseParameterizedTestTemplate(name = "[{index}] protection = {0}, encryption = {1}, cipher = {2}")
public class TestSaslFanOutOneBlockAsyncDFSOutput extends AsyncFSTestBase {
private static final Logger LOG =
LoggerFactory.getLogger(TestSaslFanOutOneBlockAsyncDFSOutput.class);
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestSaslFanOutOneBlockAsyncDFSOutput.class);
-
private static DistributedFileSystem FS;
private static EventLoopGroup EVENT_LOOP_GROUP;
@@ -104,29 +97,27 @@ public class TestSaslFanOutOneBlockAsyncDFSOutput extends AsyncFSTestBase {
private static StreamSlowMonitor MONITOR;
- @Rule
- public TestName name = new TestName();
-
- @Parameter(0)
- public String protection;
+ private String protection;
+ private String encryptionAlgorithm;
+ private String cipherSuite;
- @Parameter(1)
- public String encryptionAlgorithm;
-
- @Parameter(2)
- public String cipherSuite;
+ public TestSaslFanOutOneBlockAsyncDFSOutput(String protection, String encryptionAlgorithm,
+ String cipherSuite) {
+ this.protection = protection;
+ this.encryptionAlgorithm = encryptionAlgorithm;
+ this.cipherSuite = cipherSuite;
+ }
- @Parameters(name = "{index}: protection={0}, encryption={1}, cipherSuite={2}")
- public static Iterable