Skip to content

HADOOP-19617. [JDK17] Remove JUnit4 Dependency (YARN) . #7798

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
10 changes: 0 additions & 10 deletions hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,6 @@
</exclusions>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
Expand All @@ -95,11 +90,6 @@
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<!-- Only required to run tests in an IDE that bundles an older version -->
<dependency>
<groupId>org.junit.platform</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>ch.qos.reload4j</groupId>
<artifactId>reload4j</artifactId>
Expand Down Expand Up @@ -182,11 +176,6 @@
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,6 @@ protected float getTimelineVersion() {
return 1.0f;
}

@Override
protected void cleanUpDFSClient() {

}

@Test
public void testDSShellWithDomain(TestInfo testInfo) throws Exception {
baseTestDSShell(getMethodName(testInfo), true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,6 @@
<artifactId>hadoop-common</artifactId>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-yarn-services-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,6 @@
<!-- Test dependencies -->
<!-- ======================================================== -->

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
Expand Down Expand Up @@ -289,11 +283,6 @@
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
10 changes: 0 additions & 10 deletions hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,6 @@
<artifactId>snappy-java</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
Expand Down Expand Up @@ -191,11 +186,6 @@
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.BeforeAll;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -47,7 +47,7 @@ public class TestGetGroups extends GetGroupsTestBase {

private static Configuration conf;

@BeforeClass
@BeforeAll
public static void setUpResourceManager() throws InterruptedException {
conf = new YarnConfiguration();
resourceManager = new ResourceManager() {
Expand Down Expand Up @@ -77,19 +77,19 @@ public void run() {
}.start();

boolean rmStarted = rmStartedSignal.await(60000L, TimeUnit.MILLISECONDS);
Assert.assertTrue("ResourceManager failed to start up.", rmStarted);
Assertions.assertTrue(rmStarted, "ResourceManager failed to start up.");

LOG.info("ResourceManager RMAdmin address: {}.",
conf.get(YarnConfiguration.RM_ADMIN_ADDRESS));
}

@SuppressWarnings("static-access")
@Before
@BeforeEach
public void setUpConf() {
super.conf = this.conf;
}

@AfterClass
@AfterAll
public static void tearDownResourceManager() throws InterruptedException {
if (resourceManager != null) {
LOG.info("Stopping ResourceManager...");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@

package org.apache.hadoop.yarn.client;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
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.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;

Expand Down Expand Up @@ -56,10 +56,10 @@
import org.apache.hadoop.yarn.server.resourcemanager.RMFatalEventType;
import org.apache.hadoop.yarn.server.webproxy.WebAppProxyServer;
import org.apache.hadoop.yarn.webapp.YarnWebParams;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.function.Supplier;
import org.slf4j.Logger;
Expand All @@ -81,7 +81,7 @@ public class TestRMFailover extends ClientBaseWithFixes {
private MiniYARNCluster cluster;
private ApplicationId fakeAppId;

@Before
@BeforeEach
public void setup() throws IOException {
fakeAppId = ApplicationId.newInstance(System.currentTimeMillis(), 0);
conf = new YarnConfiguration();
Expand All @@ -98,7 +98,7 @@ public void setup() throws IOException {
cluster = new MiniYARNCluster(TestRMFailover.class.getName(), 2, 1, 1, 1);
}

@After
@AfterEach
public void teardown() {
cluster.stop();
}
Expand All @@ -123,8 +123,8 @@ private void verifyClientConnection() {
}

private void verifyConnections() throws InterruptedException, YarnException {
assertTrue("NMs failed to connect to the RM",
cluster.waitForNodeManagersToConnect(20000));
assertTrue(
cluster.waitForNodeManagersToConnect(20000), "NMs failed to connect to the RM");
verifyClientConnection();
}

Expand All @@ -137,15 +137,15 @@ private void explicitFailover() throws IOException {
int newActiveRMIndex = (activeRMIndex + 1) % 2;
getAdminService(activeRMIndex).transitionToStandby(req);
getAdminService(newActiveRMIndex).transitionToActive(req);
assertEquals("Failover failed", newActiveRMIndex, cluster.getActiveRMIndex());
assertEquals(newActiveRMIndex, cluster.getActiveRMIndex(), "Failover failed");
}

private void failover()
throws IOException, InterruptedException, YarnException {
int activeRMIndex = cluster.getActiveRMIndex();
cluster.stopResourceManager(activeRMIndex);
assertEquals("Failover failed",
(activeRMIndex + 1) % 2, cluster.getActiveRMIndex());
assertEquals(
(activeRMIndex + 1) % 2, cluster.getActiveRMIndex(), "Failover failed");
cluster.restartResourceManager(activeRMIndex);
}

Expand All @@ -155,7 +155,7 @@ public void testExplicitFailover()
conf.setBoolean(YarnConfiguration.AUTO_FAILOVER_ENABLED, false);
cluster.init(conf);
cluster.start();
assertFalse("RM never turned active", -1 == cluster.getActiveRMIndex());
assertFalse(-1 == cluster.getActiveRMIndex(), "RM never turned active");
verifyConnections();

explicitFailover();
Expand Down Expand Up @@ -189,7 +189,7 @@ public void testAutomaticFailover()

cluster.init(conf);
cluster.start();
assertFalse("RM never turned active", -1 == cluster.getActiveRMIndex());
assertFalse(-1 == cluster.getActiveRMIndex(), "RM never turned active");
verifyConnections();

failover();
Expand Down Expand Up @@ -220,14 +220,14 @@ public void testWebAppProxyInStandAloneMode() throws YarnException,
cluster.init(conf);
cluster.start();
getAdminService(0).transitionToActive(req);
assertFalse("RM never turned active", -1 == cluster.getActiveRMIndex());
assertFalse(-1 == cluster.getActiveRMIndex(), "RM never turned active");
verifyConnections();
webAppProxyServer.init(conf);

// Start webAppProxyServer
Assert.assertEquals(STATE.INITED, webAppProxyServer.getServiceState());
Assertions.assertEquals(STATE.INITED, webAppProxyServer.getServiceState());
webAppProxyServer.start();
Assert.assertEquals(STATE.STARTED, webAppProxyServer.getServiceState());
Assertions.assertEquals(STATE.STARTED, webAppProxyServer.getServiceState());

// send httpRequest with fakeApplicationId
// expect to get "Not Found" response and 404 response code
Expand All @@ -253,7 +253,7 @@ public void testEmbeddedWebAppProxy() throws YarnException,
conf.setBoolean(YarnConfiguration.AUTO_FAILOVER_ENABLED, false);
cluster.init(conf);
cluster.start();
assertFalse("RM never turned active", -1 == cluster.getActiveRMIndex());
assertFalse(-1 == cluster.getActiveRMIndex(), "RM never turned active");
verifyConnections();

// send httpRequest with fakeApplicationId
Expand Down Expand Up @@ -391,7 +391,7 @@ public void testUncaughtExceptionHandlerWithHAEnabled()
conf.set(YarnConfiguration.RM_ZK_ADDRESS, hostPort);
cluster.init(conf);
cluster.start();
assertFalse("RM never turned active", -1 == cluster.getActiveRMIndex());
assertFalse(-1 == cluster.getActiveRMIndex(), "RM never turned active");

ResourceManager resourceManager = cluster.getResourceManager(
cluster.getActiveRMIndex());
Expand Down
5 changes: 0 additions & 5 deletions hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,6 @@
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-annotations</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
*/

package org.apache.hadoop.yarn.util;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;

public class TestLRUCache {
public static final int CACHE_EXPIRE_TIME = 200;
Expand All @@ -29,21 +32,21 @@ public void testLRUCache() throws InterruptedException {
lruCache.put("2", 1);
lruCache.put("3", 3);
lruCache.put("4", 4);
Assert.assertEquals(lruCache.size(), 3);
Assert.assertNull(lruCache.get("1"));
Assert.assertNotNull(lruCache.get("2"));
Assert.assertNotNull(lruCache.get("3"));
Assert.assertNotNull(lruCache.get("3"));
assertEquals(lruCache.size(), 3);
assertNull(lruCache.get("1"));
assertNotNull(lruCache.get("2"));
assertNotNull(lruCache.get("3"));
assertNotNull(lruCache.get("3"));
lruCache.clear();

lruCache.put("1", 1);
Thread.sleep(201);
Assert.assertEquals(lruCache.size(), 1);
assertEquals(lruCache.size(), 1);
lruCache.get("1");
Assert.assertEquals(lruCache.size(), 0);
assertEquals(lruCache.size(), 0);
lruCache.put("2", 2);
Assert.assertEquals(lruCache.size(), 1);
assertEquals(lruCache.size(), 1);
lruCache.put("3", 3);
Assert.assertEquals(lruCache.size(), 2);
assertEquals(lruCache.size(), 2);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import org.glassfish.jersey.jettison.internal.entity.JettisonObjectProvider;
import org.glassfish.jersey.test.JerseyTest;
import org.junit.Before;
import org.junit.jupiter.api.BeforeEach;

import javax.ws.rs.client.WebTarget;
Expand All @@ -35,7 +34,6 @@ protected Application configure() {
}

@BeforeEach
@Before
@Override
public void setUp() throws Exception {
super.setUp();
Expand Down
Loading