Skip to content

Commit 47d29fd

Browse files
slfan1989cnaurothzhtttylz
authored
HADOOP-19429. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-dynamometer-infra. (#7588)
Co-authored-by: Chris Nauroth <cnauroth@apache.org> Co-authored-by: Hualong Zhang <hualong.z@hotmail.com> Reviewed-by: Chris Nauroth <cnauroth@apache.org> Reviewed-by: Hualong Zhang <hualong.z@hotmail.com> Signed-off-by: Shilun Fan <slfan1989@apache.org>
1 parent 1977eea commit 47d29fd

File tree

2 files changed

+28
-27
lines changed

2 files changed

+28
-27
lines changed

hadoop-tools/hadoop-dynamometer/hadoop-dynamometer-infra/src/test/java/org/apache/hadoop/tools/dynamometer/TestDynamometerInfra.java

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,23 @@
7171
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration;
7272
import org.apache.hadoop.yarn.util.resource.DominantResourceCalculator;
7373
import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
74-
import org.junit.After;
75-
import org.junit.AfterClass;
76-
import org.junit.Assert;
77-
import org.junit.Assume;
78-
import org.junit.BeforeClass;
79-
import org.junit.Ignore;
80-
import org.junit.Test;
74+
import org.junit.jupiter.api.AfterAll;
75+
import org.junit.jupiter.api.AfterEach;
76+
import org.junit.jupiter.api.Assertions;
77+
import org.junit.jupiter.api.BeforeAll;
78+
import org.junit.jupiter.api.Disabled;
79+
import org.junit.jupiter.api.Test;
80+
import org.junit.jupiter.api.Timeout;
81+
8182
import org.slf4j.Logger;
8283
import org.slf4j.LoggerFactory;
8384

8485
import static org.apache.hadoop.tools.dynamometer.DynoInfraUtils.fetchHadoopTarball;
8586
import static org.apache.hadoop.hdfs.MiniDFSCluster.PROP_TEST_BUILD_DATA;
86-
import static org.hamcrest.CoreMatchers.notNullValue;
87-
import static org.junit.Assert.assertEquals;
88-
import static org.junit.Assert.assertTrue;
89-
import static org.junit.Assert.fail;
87+
import static org.junit.jupiter.api.Assertions.assertEquals;
88+
import static org.junit.jupiter.api.Assertions.assertTrue;
89+
import static org.junit.jupiter.api.Assertions.fail;
90+
import static org.junit.jupiter.api.Assumptions.assumeTrue;
9091

9192
/**
9293
* Start a Dynamometer cluster in a MiniYARNCluster. Ensure that the NameNode is
@@ -112,7 +113,7 @@
112113
* property to point directly to a Hadoop tarball which is present locally and
113114
* no download will occur.
114115
*/
115-
@Ignore
116+
@Disabled
116117
public class TestDynamometerInfra {
117118

118119
private static final Logger LOG =
@@ -153,19 +154,19 @@ public class TestDynamometerInfra {
153154

154155
private ApplicationId infraAppId;
155156

156-
@BeforeClass
157+
@BeforeAll
157158
public static void setupClass() throws Exception {
158159
PlatformAssumptions.assumeNotWindows("Dynamometer will not run on Windows");
159-
Assume.assumeThat("JAVA_HOME must be set properly",
160-
System.getenv("JAVA_HOME"), notNullValue());
160+
assumeTrue(System.getenv("JAVA_HOME") != null,
161+
"JAVA_HOME must be set properly");
161162
try {
162163
Shell.ShellCommandExecutor tarCheck = new Shell.ShellCommandExecutor(
163164
new String[]{"bash", "-c", "command -v tar"});
164165
tarCheck.execute();
165-
Assume.assumeTrue("tar command is not available",
166-
tarCheck.getExitCode() == 0);
166+
assumeTrue(tarCheck.getExitCode() == 0,
167+
"tar command is not available");
167168
} catch (IOException ioe) {
168-
Assume.assumeNoException("Unable to execute a shell command", ioe);
169+
assumeTrue(false, "Unexpected exception occurred: " + ioe.getMessage());
169170
}
170171

171172
conf = new Configuration();
@@ -193,8 +194,7 @@ public static void setupClass() throws Exception {
193194
// Set up the Hadoop binary to be used as the system-level Hadoop install
194195
hadoopUnpackedDir = new File(testBaseDir,
195196
HADOOP_BIN_UNPACKED_DIR_PREFIX + UUID.randomUUID());
196-
assertTrue("Failed to make temporary directory",
197-
hadoopUnpackedDir.mkdirs());
197+
assertTrue(hadoopUnpackedDir.mkdirs(), "Failed to make temporary directory");
198198
Shell.ShellCommandExecutor shexec = new Shell.ShellCommandExecutor(
199199
new String[] {"tar", "xzf", hadoopTarballPath.getAbsolutePath(), "-C",
200200
hadoopUnpackedDir.getAbsolutePath()});
@@ -280,7 +280,7 @@ public static void setupClass() throws Exception {
280280
nodeLabelManager.addLabelsToNode(nodeLabels);
281281
}
282282

283-
@AfterClass
283+
@AfterAll
284284
public static void teardownClass() throws Exception {
285285
if (miniDFSCluster != null) {
286286
miniDFSCluster.shutdown(true);
@@ -303,15 +303,16 @@ public static void teardownClass() throws Exception {
303303
}
304304
}
305305

306-
@After
306+
@AfterEach
307307
public void tearDown() throws Exception {
308308
if (infraAppId != null && yarnClient != null) {
309309
yarnClient.killApplication(infraAppId);
310310
}
311311
infraAppId = null;
312312
}
313313

314-
@Test(timeout = 15 * 60 * 1000)
314+
@Test
315+
@Timeout(15 * 60)
315316
public void testNameNodeInYARN() throws Exception {
316317
Configuration localConf = new Configuration(yarnConf);
317318
localConf.setLong(AuditLogDirectParser.AUDIT_START_TIMESTAMP_KEY, 60000);
@@ -458,7 +459,7 @@ private void awaitApplicationStartup()
458459

459460
private Client createAndStartClient(Configuration localConf) {
460461
final Client client = new Client(JarFinder.getJar(ApplicationMaster.class),
461-
JarFinder.getJar(Assert.class));
462+
JarFinder.getJar(Assertions.class));
462463
client.setConf(localConf);
463464
Thread appThread = new Thread(() -> {
464465
try {

hadoop-tools/hadoop-dynamometer/hadoop-dynamometer-infra/src/test/java/org/apache/hadoop/tools/dynamometer/TestDynoInfraUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
package org.apache.hadoop.tools.dynamometer;
1919

2020
import java.util.Set;
21-
import org.junit.Test;
21+
import org.junit.jupiter.api.Test;
2222
import org.slf4j.Logger;
2323
import org.slf4j.LoggerFactory;
2424

25-
import static org.junit.Assert.assertEquals;
26-
import static org.junit.Assert.assertTrue;
25+
import static org.junit.jupiter.api.Assertions.assertEquals;
26+
import static org.junit.jupiter.api.Assertions.assertTrue;
2727

2828

2929
/** Tests for {@link DynoInfraUtils}. */

0 commit comments

Comments
 (0)