Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,17 @@
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration;
import org.apache.hadoop.yarn.util.resource.DominantResourceCalculator;
import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Assume;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.*;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could wildcard imports (import org.junit.jupiter.api.*;) be avoided, and specific classes imported instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reviewing the code! I have fixed this issue.


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static org.apache.hadoop.tools.dynamometer.DynoInfraUtils.fetchHadoopTarball;
import static org.apache.hadoop.hdfs.MiniDFSCluster.PROP_TEST_BUILD_DATA;
import static org.hamcrest.CoreMatchers.notNullValue;
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 static org.junit.jupiter.api.Assumptions.assumeTrue;

/**
* Start a Dynamometer cluster in a MiniYARNCluster. Ensure that the NameNode is
Expand All @@ -112,7 +107,7 @@
* property to point directly to a Hadoop tarball which is present locally and
* no download will occur.
*/
@Ignore
@Disabled
public class TestDynamometerInfra {

private static final Logger LOG =
Expand Down Expand Up @@ -153,19 +148,19 @@ public class TestDynamometerInfra {

private ApplicationId infraAppId;

@BeforeClass
@BeforeAll
public static void setupClass() throws Exception {
PlatformAssumptions.assumeNotWindows("Dynamometer will not run on Windows");
Assume.assumeThat("JAVA_HOME must be set properly",
System.getenv("JAVA_HOME"), notNullValue());
assumeTrue(System.getenv("JAVA_HOME") != null,
"JAVA_HOME must be set properly");
try {
Shell.ShellCommandExecutor tarCheck = new Shell.ShellCommandExecutor(
new String[]{"bash", "-c", "command -v tar"});
tarCheck.execute();
Assume.assumeTrue("tar command is not available",
tarCheck.getExitCode() == 0);
assumeTrue(tarCheck.getExitCode() == 0,
"tar command is not available");
} catch (IOException ioe) {
Assume.assumeNoException("Unable to execute a shell command", ioe);
assumeTrue(false, "Unexpected exception occurred: " + ioe.getMessage());
}

conf = new Configuration();
Expand Down Expand Up @@ -193,8 +188,7 @@ public static void setupClass() throws Exception {
// Set up the Hadoop binary to be used as the system-level Hadoop install
hadoopUnpackedDir = new File(testBaseDir,
HADOOP_BIN_UNPACKED_DIR_PREFIX + UUID.randomUUID());
assertTrue("Failed to make temporary directory",
hadoopUnpackedDir.mkdirs());
assertTrue(hadoopUnpackedDir.mkdirs(), "Failed to make temporary directory");
Shell.ShellCommandExecutor shexec = new Shell.ShellCommandExecutor(
new String[] {"tar", "xzf", hadoopTarballPath.getAbsolutePath(), "-C",
hadoopUnpackedDir.getAbsolutePath()});
Expand Down Expand Up @@ -280,7 +274,7 @@ public static void setupClass() throws Exception {
nodeLabelManager.addLabelsToNode(nodeLabels);
}

@AfterClass
@AfterAll
public static void teardownClass() throws Exception {
if (miniDFSCluster != null) {
miniDFSCluster.shutdown(true);
Expand All @@ -303,15 +297,16 @@ public static void teardownClass() throws Exception {
}
}

@After
@AfterEach
public void tearDown() throws Exception {
if (infraAppId != null && yarnClient != null) {
yarnClient.killApplication(infraAppId);
}
infraAppId = null;
}

@Test(timeout = 15 * 60 * 1000)
@Test
@Timeout(15 * 60)
public void testNameNodeInYARN() throws Exception {
Configuration localConf = new Configuration(yarnConf);
localConf.setLong(AuditLogDirectParser.AUDIT_START_TIMESTAMP_KEY, 60000);
Expand Down Expand Up @@ -458,7 +453,7 @@ private void awaitApplicationStartup()

private Client createAndStartClient(Configuration localConf) {
final Client client = new Client(JarFinder.getJar(ApplicationMaster.class),
JarFinder.getJar(Assert.class));
JarFinder.getJar(Assertions.class));
client.setConf(localConf);
Thread appThread = new Thread(() -> {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
package org.apache.hadoop.tools.dynamometer;

import java.util.Set;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

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;


/** Tests for {@link DynoInfraUtils}. */
Expand Down