Skip to content

Commit 1b6245c

Browse files
committed
HADOOP-19429. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-dynamometer-infra.
1 parent e8a64d0 commit 1b6245c

2 files changed

Lines changed: 22 additions & 27 deletions

File tree

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

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,16 @@
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.*;
8175
import org.slf4j.Logger;
8276
import org.slf4j.LoggerFactory;
8377

8478
import static org.apache.hadoop.tools.dynamometer.DynoInfraUtils.fetchHadoopTarball;
8579
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;
80+
import static org.junit.jupiter.api.Assertions.assertEquals;
81+
import static org.junit.jupiter.api.Assertions.assertTrue;
82+
import static org.junit.jupiter.api.Assertions.fail;
83+
import static org.junit.jupiter.api.Assumptions.assumeTrue;
9084

9185
/**
9286
* Start a Dynamometer cluster in a MiniYARNCluster. Ensure that the NameNode is
@@ -112,7 +106,7 @@
112106
* property to point directly to a Hadoop tarball which is present locally and
113107
* no download will occur.
114108
*/
115-
@Ignore
109+
@Disabled
116110
public class TestDynamometerInfra {
117111

118112
private static final Logger LOG =
@@ -153,19 +147,19 @@ public class TestDynamometerInfra {
153147

154148
private ApplicationId infraAppId;
155149

156-
@BeforeClass
150+
@BeforeAll
157151
public static void setupClass() throws Exception {
158152
PlatformAssumptions.assumeNotWindows("Dynamometer will not run on Windows");
159-
Assume.assumeThat("JAVA_HOME must be set properly",
160-
System.getenv("JAVA_HOME"), notNullValue());
153+
assumeTrue(System.getenv("JAVA_HOME") != null,
154+
"JAVA_HOME must be set properly");
161155
try {
162156
Shell.ShellCommandExecutor tarCheck = new Shell.ShellCommandExecutor(
163157
new String[]{"bash", "-c", "command -v tar"});
164158
tarCheck.execute();
165-
Assume.assumeTrue("tar command is not available",
166-
tarCheck.getExitCode() == 0);
159+
assumeTrue(tarCheck.getExitCode() == 0,
160+
"tar command is not available");
167161
} catch (IOException ioe) {
168-
Assume.assumeNoException("Unable to execute a shell command", ioe);
162+
assumeTrue(false, "Unexpected exception occurred: " + ioe.getMessage());
169163
}
170164

171165
conf = new Configuration();
@@ -193,8 +187,8 @@ public static void setupClass() throws Exception {
193187
// Set up the Hadoop binary to be used as the system-level Hadoop install
194188
hadoopUnpackedDir = new File(testBaseDir,
195189
HADOOP_BIN_UNPACKED_DIR_PREFIX + UUID.randomUUID());
196-
assertTrue("Failed to make temporary directory",
197-
hadoopUnpackedDir.mkdirs());
190+
assertTrue(
191+
hadoopUnpackedDir.mkdirs(), "Failed to make temporary directory");
198192
Shell.ShellCommandExecutor shexec = new Shell.ShellCommandExecutor(
199193
new String[] {"tar", "xzf", hadoopTarballPath.getAbsolutePath(), "-C",
200194
hadoopUnpackedDir.getAbsolutePath()});
@@ -280,7 +274,7 @@ public static void setupClass() throws Exception {
280274
nodeLabelManager.addLabelsToNode(nodeLabels);
281275
}
282276

283-
@AfterClass
277+
@AfterAll
284278
public static void teardownClass() throws Exception {
285279
if (miniDFSCluster != null) {
286280
miniDFSCluster.shutdown(true);
@@ -303,15 +297,16 @@ public static void teardownClass() throws Exception {
303297
}
304298
}
305299

306-
@After
300+
@AfterEach
307301
public void tearDown() throws Exception {
308302
if (infraAppId != null && yarnClient != null) {
309303
yarnClient.killApplication(infraAppId);
310304
}
311305
infraAppId = null;
312306
}
313307

314-
@Test(timeout = 15 * 60 * 1000)
308+
@Test
309+
@Timeout(15 * 60)
315310
public void testNameNodeInYARN() throws Exception {
316311
Configuration localConf = new Configuration(yarnConf);
317312
localConf.setLong(AuditLogDirectParser.AUDIT_START_TIMESTAMP_KEY, 60000);
@@ -458,7 +453,7 @@ private void awaitApplicationStartup()
458453

459454
private Client createAndStartClient(Configuration localConf) {
460455
final Client client = new Client(JarFinder.getJar(ApplicationMaster.class),
461-
JarFinder.getJar(Assert.class));
456+
JarFinder.getJar(Assertions.class));
462457
client.setConf(localConf);
463458
Thread appThread = new Thread(() -> {
464459
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)