This is an automated email from the ASF dual-hosted git repository.
adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new b33768e301 HDDS-9503. Migrate simple misc. integration tests to JUnit5
(#5854)
b33768e301 is described below
commit b33768e301cfc51b5f6a6d443780402b0f21b6de
Author: david1859168 <[email protected]>
AuthorDate: Sat Dec 23 01:31:45 2023 +1100
HDDS-9503. Migrate simple misc. integration tests to JUnit5 (#5854)
---
.../hadoop/ozone/TestMiniChaosOzoneCluster.java | 10 +++---
.../hadoop/hdds/scm/storage/TestCommitWatcher.java | 34 ++++++++------------
.../org/apache/hadoop/ozone/TestBlockTokens.java | 26 +++++++--------
.../apache/hadoop/ozone/TestBlockTokensCLI.java | 24 ++++++--------
.../ozone/TestContainerBalancerOperations.java | 27 ++++++----------
.../hadoop/ozone/TestContainerOperations.java | 37 +++++++++-------------
.../TestContainerStateMachineIdempotency.java | 29 ++++++-----------
.../hadoop/ozone/TestMiniOzoneOMHACluster.java | 36 ++++++++-------------
.../hadoop/ozone/debug/TestLeaseRecoverer.java | 22 ++++++-------
.../hadoop/ozone/fsck/TestContainerMapper.java | 29 ++++++-----------
.../ozone/scm/TestContainerReportWithKeys.java | 35 +++++++-------------
.../apache/hadoop/ozone/scm/TestSecretKeysApi.java | 32 ++++++++-----------
12 files changed, 133 insertions(+), 208 deletions(-)
diff --git
a/hadoop-ozone/fault-injection-test/mini-chaos-tests/src/test/java/org/apache/hadoop/ozone/TestMiniChaosOzoneCluster.java
b/hadoop-ozone/fault-injection-test/mini-chaos-tests/src/test/java/org/apache/hadoop/ozone/TestMiniChaosOzoneCluster.java
index ab62b920b7..6894aed25a 100644
---
a/hadoop-ozone/fault-injection-test/mini-chaos-tests/src/test/java/org/apache/hadoop/ozone/TestMiniChaosOzoneCluster.java
+++
b/hadoop-ozone/fault-injection-test/mini-chaos-tests/src/test/java/org/apache/hadoop/ozone/TestMiniChaosOzoneCluster.java
@@ -30,9 +30,9 @@ import org.apache.hadoop.ozone.failure.Failures;
import org.apache.hadoop.ozone.freon.FreonReplicationOptions;
import org.apache.hadoop.ozone.loadgenerators.LoadGenerator;
import org.apache.hadoop.ozone.om.helpers.BucketLayout;
-import org.junit.BeforeClass;
-import org.junit.AfterClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Test;
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
@@ -117,7 +117,7 @@ public class TestMiniChaosOzoneCluster extends GenericCli {
private static final String OM_SERVICE_ID = "ozoneChaosTest";
private static final String SCM_SERVICE_ID = "scmChaosTest";
- @BeforeClass
+ @BeforeAll
public static void init() throws Exception {
OzoneConfiguration configuration = new OzoneConfiguration();
@@ -191,7 +191,7 @@ public class TestMiniChaosOzoneCluster extends GenericCli {
/**
* Shutdown MiniDFSCluster.
*/
- @AfterClass
+ @AfterAll
public static void shutdown() {
if (loadGenerator != null) {
loadGenerator.shutdownLoadGenerator();
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/storage/TestCommitWatcher.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/storage/TestCommitWatcher.java
index 3e648fd816..20fa713deb 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/storage/TestCommitWatcher.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/storage/TestCommitWatcher.java
@@ -56,33 +56,26 @@ import
org.apache.hadoop.ozone.container.ContainerTestHelper;
import static java.util.Collections.singletonList;
import static
org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_SCM_STALENODE_INTERVAL;
-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 org.apache.ratis.protocol.exceptions.AlreadyClosedException;
import org.apache.ratis.protocol.exceptions.NotReplicatedException;
import org.apache.ratis.protocol.exceptions.RaftRetryFailureException;
import org.apache.ratis.protocol.exceptions.TimeoutIOException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestRule;
-import org.junit.rules.Timeout;
-import org.apache.ozone.test.JUnit5AwareTimeout;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
/**
* Class to test CommitWatcher functionality.
*/
+@Timeout(value = 300, unit = TimeUnit.SECONDS)
public class TestCommitWatcher {
- /**
- * Set a timeout for each test.
- */
- @Rule
- public TestRule timeout = new JUnit5AwareTimeout(Timeout.seconds(300));
private MiniOzoneCluster cluster;
private OzoneConfiguration conf = new OzoneConfiguration();
private OzoneClient client;
@@ -104,7 +97,7 @@ public class TestCommitWatcher {
*
* @throws IOException
*/
- @Before
+ @BeforeEach
public void init() throws Exception {
chunkSize = (int)(1 * OzoneConsts.MB);
flushSize = (long) 2 * chunkSize;
@@ -165,7 +158,7 @@ public class TestCommitWatcher {
/**
* Shutdown MiniDFSCluster.
*/
- @After
+ @AfterEach
public void shutdown() {
IOUtils.closeQuietly(client);
if (cluster != null) {
@@ -324,11 +317,12 @@ public class TestCommitWatcher {
// can itself get AlreadyClosedException from the Ratis Server
// and the write may fail with RaftRetryFailureException
Throwable t = HddsClientUtils.checkForException(ioe);
- assertTrue("Unexpected exception: " + t.getClass(),
+ assertTrue(
t instanceof RaftRetryFailureException ||
t instanceof TimeoutIOException ||
t instanceof AlreadyClosedException ||
- t instanceof NotReplicatedException);
+ t instanceof NotReplicatedException,
+ "Unexpected exception: " + t.getClass());
}
if (ratisClient.getReplicatedMinCommitIndex() < replies.get(1)
.getLogIndex()) {
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestBlockTokens.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestBlockTokens.java
index e028e6741e..9cf4f53a68 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestBlockTokens.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestBlockTokens.java
@@ -47,13 +47,10 @@ import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.token.Token;
import org.apache.ozone.test.GenericTestUtils;
import org.apache.ratis.util.ExitUtils;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestRule;
-import org.junit.rules.Timeout;
-import org.apache.ozone.test.JUnit5AwareTimeout;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -64,6 +61,7 @@ import java.net.InetAddress;
import java.util.Objects;
import java.util.Properties;
import java.util.UUID;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.function.Function;
@@ -92,14 +90,15 @@ import static
org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_KERBEROS_PRINCIPA
import static
org.apache.hadoop.security.UserGroupInformation.AuthenticationMethod.KERBEROS;
import static org.apache.ozone.test.GenericTestUtils.waitFor;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-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.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Integration test to verify block tokens in a secure cluster.
*/
@InterfaceAudience.Private
+@Timeout(value = 180, unit = TimeUnit.SECONDS)
public final class TestBlockTokens {
private static final Logger LOG =
LoggerFactory.getLogger(TestBlockTokens.class);
private static final String TEST_VOLUME = "testvolume";
@@ -109,9 +108,6 @@ public final class TestBlockTokens {
private static final int EXPIRY_DURATION_IN_MS = 10000;
private static final int ROTATION_CHECK_DURATION_IN_MS = 100;
- @Rule
- public TestRule timeout = new JUnit5AwareTimeout(Timeout.seconds(180));
-
private static MiniKdc miniKdc;
private static OzoneConfiguration conf;
private static File workDir;
@@ -127,7 +123,7 @@ public final class TestBlockTokens {
private static BlockInputStreamFactory blockInputStreamFactory =
new BlockInputStreamFactoryImpl();
- @BeforeClass
+ @BeforeAll
public static void init() throws Exception {
conf = new OzoneConfiguration();
conf.set(OZONE_SCM_CLIENT_ADDRESS_KEY, "localhost");
@@ -159,7 +155,7 @@ public final class TestBlockTokens {
}
}
- @AfterClass
+ @AfterAll
public static void stop() {
miniKdc.stop();
IOUtils.close(LOG, client);
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestBlockTokensCLI.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestBlockTokensCLI.java
index 06b6b2d96d..9a98a0a189 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestBlockTokensCLI.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestBlockTokensCLI.java
@@ -33,14 +33,6 @@ import org.apache.hadoop.ozone.om.OzoneManager;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.ozone.test.GenericTestUtils;
import org.apache.ratis.util.ExitUtils;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.jupiter.api.Assertions;
-import org.junit.rules.TestRule;
-import org.junit.rules.Timeout;
-import org.apache.ozone.test.JUnit5AwareTimeout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -56,6 +48,7 @@ import java.time.Instant;
import java.util.Map;
import java.util.Properties;
import java.util.UUID;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import static java.time.Duration.between;
@@ -78,19 +71,20 @@ import static
org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_KERBEROS_KEYTAB_F
import static
org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_KERBEROS_PRINCIPAL_KEY;
import static
org.apache.hadoop.security.UserGroupInformation.AuthenticationMethod.KERBEROS;
import static org.junit.jupiter.api.Assertions.assertEquals;
-
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+import org.junit.jupiter.api.Assertions;
/**
* Integration test class to verify block token CLI commands functionality in a
* secure cluster.
*/
@InterfaceAudience.Private
+@Timeout(value = 180, unit = TimeUnit.SECONDS)
public final class TestBlockTokensCLI {
private static final Logger LOG = LoggerFactory
.getLogger(TestBlockTokensCLI.class);
-
- @Rule
- public TestRule timeout = new JUnit5AwareTimeout(Timeout.seconds(180));
-
private static MiniKdc miniKdc;
private static OzoneAdmin ozoneAdmin;
private static OzoneConfiguration conf;
@@ -105,7 +99,7 @@ public final class TestBlockTokensCLI {
private static MiniOzoneHAClusterImpl cluster;
private static OzoneClient client;
- @BeforeClass
+ @BeforeAll
public static void init() throws Exception {
conf = new OzoneConfiguration();
conf.set(OZONE_SCM_CLIENT_ADDRESS_KEY, "localhost");
@@ -128,7 +122,7 @@ public final class TestBlockTokensCLI {
ozoneAdmin = new OzoneAdmin(conf);
}
- @AfterClass
+ @AfterAll
public static void stop() {
miniKdc.stop();
IOUtils.close(LOG, client);
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestContainerBalancerOperations.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestContainerBalancerOperations.java
index 8a35f87e17..2334e3cf94 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestContainerBalancerOperations.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestContainerBalancerOperations.java
@@ -26,37 +26,30 @@ import
org.apache.hadoop.hdds.scm.container.placement.algorithms.SCMContainerPla
import org.apache.ozone.test.UnhealthyTest;
import org.apache.ozone.test.tag.Unhealthy;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.junit.experimental.categories.Category;
-import org.junit.rules.TestRule;
-import org.junit.rules.Timeout;
-import org.apache.ozone.test.JUnit5AwareTimeout;
+import org.junit.jupiter.api.Timeout;
import java.util.Optional;
+import java.util.concurrent.TimeUnit;
-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;
/**
* This class tests container balancer operations
* from cblock clients.
*/
+@Timeout(value = 300, unit = TimeUnit.MILLISECONDS)
public class TestContainerBalancerOperations {
- /**
- * Set a timeout for each test.
- */
- @Rule
- public TestRule timeout = new JUnit5AwareTimeout(Timeout.seconds(300));
-
private static ScmClient containerBalancerClient;
private static MiniOzoneCluster cluster;
private static OzoneConfiguration ozoneConf;
- @BeforeClass
+ @BeforeAll
public static void setup() throws Exception {
ozoneConf = new OzoneConfiguration();
ozoneConf.setClass(ScmConfigKeys.OZONE_SCM_CONTAINER_PLACEMENT_IMPL_KEY,
@@ -66,7 +59,7 @@ public class TestContainerBalancerOperations {
cluster.waitForClusterToBeReady();
}
- @AfterClass
+ @AfterAll
public static void cleanup() throws Exception {
if (cluster != null) {
cluster.shutdown();
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestContainerOperations.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestContainerOperations.java
index f5950dde84..56e744886b 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestContainerOperations.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestContainerOperations.java
@@ -1,4 +1,4 @@
-/**
+ /**
* 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
@@ -29,39 +29,32 @@ import org.apache.hadoop.hdds.scm.client.ScmClient;
import org.apache.hadoop.hdds.scm.ha.SCMHAUtils;
import org.apache.hadoop.hdds.scm.pipeline.PipelineID;
import org.apache.hadoop.hdds.scm.pipeline.PipelineNotFoundException;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.Rule;
-import org.junit.rules.TestRule;
-import org.junit.rules.Timeout;
-import org.apache.ozone.test.JUnit5AwareTimeout;
import java.io.IOException;
import java.util.List;
+import java.util.concurrent.TimeUnit;
import static
org.apache.hadoop.hdds.protocol.DatanodeDetails.Port.Name.REPLICATION;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+import org.junit.jupiter.api.Assertions;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* This class tests container operations (TODO currently only supports create)
* from cblock clients.
*/
+@Timeout(value = 300, unit = TimeUnit.SECONDS)
public class TestContainerOperations {
-
- /**
- * Set a timeout for each test.
- */
- @Rule
- public TestRule timeout = new JUnit5AwareTimeout(Timeout.seconds(300));
-
private static ScmClient storageClient;
private static MiniOzoneCluster cluster;
private static OzoneConfiguration ozoneConf;
- @BeforeClass
+ @BeforeAll
public static void setup() throws Exception {
ozoneConf = new OzoneConfiguration();
ozoneConf.setClass(ScmConfigKeys.OZONE_SCM_CONTAINER_PLACEMENT_IMPL_KEY,
@@ -71,7 +64,7 @@ public class TestContainerOperations {
cluster.waitForClusterToBeReady();
}
- @AfterClass
+ @AfterAll
public static void cleanup() throws Exception {
if (cluster != null) {
cluster.shutdown();
@@ -100,13 +93,13 @@ public class TestContainerOperations {
public void testGetPipeline() throws Exception {
try {
storageClient.getPipeline(PipelineID.randomId().getProtobuf());
- Assert.fail("Get Pipeline should fail");
+ Assertions.fail("Get Pipeline should fail");
} catch (Exception e) {
assertTrue(
SCMHAUtils.unwrapException(e) instanceof PipelineNotFoundException);
}
- Assert.assertFalse(storageClient.listPipelines().isEmpty());
+ Assertions.assertFalse(storageClient.listPipelines().isEmpty());
}
@Test
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestContainerStateMachineIdempotency.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestContainerStateMachineIdempotency.java
index bdf41afd41..6e76a86dd9 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestContainerStateMachineIdempotency.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestContainerStateMachineIdempotency.java
@@ -37,37 +37,28 @@ import org.apache.hadoop.hdds.scm.protocolPB.
import org.apache.hadoop.hdds.scm.storage.ContainerProtocolCalls;
import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.ozone.container.ContainerTestHelper;
-import org.junit.AfterClass;
-import org.junit.Assert;
-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.junit.jupiter.api.Timeout;
+import org.junit.jupiter.api.Assertions;
import java.io.IOException;
-
-import org.junit.Rule;
-import org.junit.rules.TestRule;
-import org.junit.rules.Timeout;
-import org.apache.ozone.test.JUnit5AwareTimeout;
+import java.util.concurrent.TimeUnit;
import static java.nio.charset.StandardCharsets.UTF_8;
/**
* Tests the idempotent operations in ContainerStateMachine.
*/
+@Timeout(value = 300, unit = TimeUnit.SECONDS)
public class TestContainerStateMachineIdempotency {
-
- /**
- * Set a timeout for each test.
- */
- @Rule
- public TestRule timeout = new JUnit5AwareTimeout(Timeout.seconds(300));
private static MiniOzoneCluster cluster;
private static OzoneConfiguration ozoneConfig;
private static StorageContainerLocationProtocolClientSideTranslatorPB
storageContainerLocationClient;
private static XceiverClientManager xceiverClientManager;
- @BeforeClass
+ @BeforeAll
public static void init() throws Exception {
ozoneConfig = new OzoneConfiguration();
ozoneConfig.setClass(ScmConfigKeys.OZONE_SCM_CONTAINER_PLACEMENT_IMPL_KEY,
@@ -80,7 +71,7 @@ public class TestContainerStateMachineIdempotency {
xceiverClientManager = new XceiverClientManager(ozoneConfig);
}
- @AfterClass
+ @AfterAll
public static void shutdown() {
if (cluster != null) {
cluster.shutdown();
@@ -124,7 +115,7 @@ public class TestContainerStateMachineIdempotency {
ContainerProtocolCalls.closeContainer(client, containerID, null);
ContainerProtocolCalls.closeContainer(client, containerID, null);
} catch (IOException ioe) {
- Assert.fail("Container operation failed" + ioe);
+ Assertions.fail("Container operation failed" + ioe);
}
xceiverClientManager.releaseClient(client, false);
}
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestMiniOzoneOMHACluster.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestMiniOzoneOMHACluster.java
index 87cd2f831d..a3e0be5a85 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestMiniOzoneOMHACluster.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestMiniOzoneOMHACluster.java
@@ -21,27 +21,25 @@ package org.apache.hadoop.ozone;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.ozone.om.OzoneManager;
import org.apache.ozone.test.GenericTestUtils;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.rules.TestRule;
-import org.junit.rules.Timeout;
-import org.apache.ozone.test.JUnit5AwareTimeout;
-import java.io.IOException;
import java.util.UUID;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicReference;
import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_ACL_ENABLED;
import static
org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_ADMINISTRATORS_WILDCARD;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+import org.junit.jupiter.api.Assertions;
+
/**
* This class tests MiniOzoneHAClusterImpl.
*/
+@Timeout(value = 300, unit = TimeUnit.SECONDS)
public class TestMiniOzoneOMHACluster {
private MiniOzoneHAClusterImpl cluster = null;
@@ -51,18 +49,12 @@ public class TestMiniOzoneOMHACluster {
private String omServiceId;
private int numOfOMs = 3;
- @Rule
- public ExpectedException exception = ExpectedException.none();
-
- @Rule
- public TestRule timeout = new JUnit5AwareTimeout(Timeout.seconds(300));
-
/**
* Create a MiniOzoneHAClusterImpl for testing.
*
* @throws IOException
*/
- @Before
+ @BeforeEach
public void init() throws Exception {
conf = new OzoneConfiguration();
clusterId = UUID.randomUUID().toString();
@@ -83,7 +75,7 @@ public class TestMiniOzoneOMHACluster {
/**
* Shutdown MiniOzoneHAClusterImpl.
*/
- @After
+ @AfterEach
public void shutdown() {
if (cluster != null) {
cluster.shutdown();
@@ -99,9 +91,9 @@ public class TestMiniOzoneOMHACluster {
ozoneManager.set(om);
return om != null;
}, 100, 120000);
- Assert.assertNotNull("Timed out waiting OM leader election to finish: "
- + "no leader or more than one leader.", ozoneManager);
- Assert.assertTrue("Should have gotten the leader!",
- ozoneManager.get().isLeaderReady());
+ Assertions.assertNotNull(ozoneManager, "Timed out waiting OM leader
election to finish: "
+ + "no leader or more than one leader.");
+ Assertions.assertTrue(ozoneManager.get().isLeaderReady(),
+ "Should have gotten the leader!");
}
}
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/debug/TestLeaseRecoverer.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/debug/TestLeaseRecoverer.java
index 1351d028b7..f35506eccd 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/debug/TestLeaseRecoverer.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/debug/TestLeaseRecoverer.java
@@ -21,14 +21,12 @@ import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.TimeUnit;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestRule;
-import org.junit.rules.Timeout;
-import org.apache.ozone.test.JUnit5AwareTimeout;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
import picocli.CommandLine;
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
@@ -49,28 +47,26 @@ import org.apache.hadoop.ozone.om.helpers.BucketLayout;
import static org.apache.hadoop.ozone.OzoneConsts.OZONE_OFS_URI_SCHEME;
import static org.apache.hadoop.ozone.OzoneConsts.OZONE_URI_DELIMITER;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_ADDRESS_KEY;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Test cases for LeaseRecoverer.
*/
+@Timeout(value = 120000, unit = TimeUnit.MILLISECONDS)
public class TestLeaseRecoverer {
private static MiniOzoneCluster cluster = null;
private static OzoneConfiguration conf;
private static OzoneBucket fsoOzoneBucket;
private static OzoneClient client;
- @Rule
- public TestRule timeout = new JUnit5AwareTimeout(new Timeout(120000));
-
/**
* Create a MiniDFSCluster for testing.
* <p>
*
* @throws IOException
*/
- @BeforeClass
+ @BeforeAll
public static void init() throws Exception {
conf = new OzoneConfiguration();
conf.setBoolean(OzoneConfigKeys.OZONE_FS_HSYNC_ENABLED, true);
@@ -88,7 +84,7 @@ public class TestLeaseRecoverer {
.createVolumeAndBucket(client, BucketLayout.FILE_SYSTEM_OPTIMIZED);
}
- @AfterClass
+ @AfterAll
public static void teardownClass() {
IOUtils.closeQuietly(client);
if (cluster != null) {
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/fsck/TestContainerMapper.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/fsck/TestContainerMapper.java
index aa181e91bb..77815698c3 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/fsck/TestContainerMapper.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/fsck/TestContainerMapper.java
@@ -37,9 +37,11 @@ import org.apache.hadoop.ozone.om.OzoneManager;
import org.apache.hadoop.ozone.om.helpers.BucketLayout;
import org.apache.ozone.test.GenericTestUtils;
import org.apache.ratis.util.FileUtils;
-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.junit.jupiter.api.Timeout;
+
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -48,28 +50,17 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
-
-import org.junit.Rule;
-import org.junit.rules.TestRule;
-import org.junit.rules.Timeout;
-import org.apache.ozone.test.JUnit5AwareTimeout;
+import java.util.concurrent.TimeUnit;
import static
org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_DATANODE_RATIS_VOLUME_FREE_SPACE_MIN;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_DB_DIRS;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Test cases for ContainerMapper.
*/
-
+@Timeout(value = 300, unit = TimeUnit.SECONDS)
public class TestContainerMapper {
-
- /**
- * Set a timeout for each test.
- */
- @Rule
- public TestRule timeout = new JUnit5AwareTimeout(Timeout.seconds(300));
-
private static MiniOzoneCluster cluster = null;
private static OzoneClient ozClient = null;
private static ObjectStore store = null;
@@ -84,7 +75,7 @@ public class TestContainerMapper {
private static String dbPath;
- @BeforeClass
+ @BeforeAll
public static void init() throws Exception {
conf = new OzoneConfiguration();
dbPath = GenericTestUtils.getRandomizedTempPath();
@@ -144,7 +135,7 @@ public class TestContainerMapper {
return chars;
}
- @AfterClass
+ @AfterAll
public static void shutdown() throws IOException {
IOUtils.closeQuietly(ozClient);
cluster.shutdown();
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/scm/TestContainerReportWithKeys.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/scm/TestContainerReportWithKeys.java
index a30e3db221..bba363d540 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/scm/TestContainerReportWithKeys.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/scm/TestContainerReportWithKeys.java
@@ -37,34 +37,25 @@ import
org.apache.hadoop.ozone.container.common.impl.ContainerSet;
import org.apache.hadoop.ozone.om.helpers.OmKeyArgs;
import org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfo;
import org.apache.hadoop.hdds.scm.server.StorageContainerManager;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.rules.TestRule;
-import org.junit.rules.Timeout;
-import org.apache.ozone.test.JUnit5AwareTimeout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+import org.junit.jupiter.api.Assertions;
import java.io.IOException;
import java.util.HashMap;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
import static java.nio.charset.StandardCharsets.UTF_8;
/**
* This class tests container report with DN container state info.
*/
+@Timeout(value = 300, unit = TimeUnit.SECONDS)
public class TestContainerReportWithKeys {
-
- /**
- * Set a timeout for each test.
- */
- @Rule
- public TestRule timeout = new JUnit5AwareTimeout(Timeout.seconds(300));
private static final Logger LOG = LoggerFactory.getLogger(
TestContainerReportWithKeys.class);
private static MiniOzoneCluster cluster = null;
@@ -72,9 +63,6 @@ public class TestContainerReportWithKeys {
private static OzoneConfiguration conf;
private static StorageContainerManager scm;
- @Rule
- public ExpectedException exception = ExpectedException.none();
-
/**
* Create a MiniDFSCluster for testing.
* <p>
@@ -82,7 +70,7 @@ public class TestContainerReportWithKeys {
*
* @throws IOException
*/
- @BeforeClass
+ @BeforeAll
public static void init() throws Exception {
conf = new OzoneConfiguration();
cluster = MiniOzoneCluster.newBuilder(conf).build();
@@ -94,7 +82,7 @@ public class TestContainerReportWithKeys {
/**
* Shutdown MiniDFSCluster.
*/
- @AfterClass
+ @AfterAll
public static void shutdown() {
IOUtils.closeQuietly(client);
if (cluster != null) {
@@ -140,8 +128,9 @@ public class TestContainerReportWithKeys {
Set<ContainerReplica> replicas =
scm.getContainerManager().getContainerReplicas(
ContainerID.valueOf(keyInfo.getContainerID()));
- Assert.assertEquals(1, replicas.size());
- replicas.stream().forEach(rp ->
Assert.assertNotNull(rp.getDatanodeDetails().getParent()));
+ Assertions.assertEquals(1, replicas.size());
+ replicas.stream().forEach(rp ->
+ Assertions.assertNotNull(rp.getDatanodeDetails().getParent()));
LOG.info("SCM Container Info keyCount: {} usedBytes: {}",
cinfo.getNumberOfKeys(), cinfo.getUsedBytes());
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/scm/TestSecretKeysApi.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/scm/TestSecretKeysApi.java
index 0d73f43772..1b8c284399 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/scm/TestSecretKeysApi.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/scm/TestSecretKeysApi.java
@@ -36,13 +36,10 @@ import org.apache.hadoop.util.ExitUtil;
import org.apache.ozone.test.GenericTestUtils;
import org.apache.ratis.util.ExitUtils;
import org.jetbrains.annotations.NotNull;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestRule;
-import org.junit.rules.Timeout;
-import org.apache.ozone.test.JUnit5AwareTimeout;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -52,6 +49,7 @@ import java.net.InetAddress;
import java.util.List;
import java.util.Properties;
import java.util.UUID;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import static
org.apache.hadoop.fs.CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHENTICATION;
@@ -76,23 +74,21 @@ import static
org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_HTTP_KERBEROS_PRI
import static
org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_KERBEROS_KEYTAB_FILE_KEY;
import static
org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_KERBEROS_PRINCIPAL_KEY;
import static
org.apache.hadoop.security.UserGroupInformation.AuthenticationMethod.KERBEROS;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThrows;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Integration test to verify symmetric SecretKeys APIs in a secure cluster.
*/
+
+@Timeout(value = 500, unit = TimeUnit.SECONDS)
@InterfaceAudience.Private
public final class TestSecretKeysApi {
private static final Logger LOG = LoggerFactory
.getLogger(TestSecretKeysApi.class);
-
- @Rule
- public TestRule timeout = new JUnit5AwareTimeout(Timeout.seconds(500));
-
private MiniKdc miniKdc;
private OzoneConfiguration conf;
private File workDir;
@@ -105,7 +101,7 @@ public final class TestSecretKeysApi {
private String scmId;
private MiniOzoneHAClusterImpl cluster;
- @Before
+ @BeforeEach
public void init() throws Exception {
conf = new OzoneConfiguration();
conf.set(OZONE_SCM_CLIENT_ADDRESS_KEY, "localhost");
@@ -122,7 +118,7 @@ public final class TestSecretKeysApi {
createCredentialsInKDC();
}
- @After
+ @AfterEach
public void stop() {
miniKdc.stop();
if (cluster != null) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]