Skip to content

Commit cf4f97d

Browse files
authored
HADOOP-19617. [JDK17] Remove JUnit4 Dependency (YARN) . (#7798)
* HADOOP-19617 - [JDK17] Remove JUnit4 Dependency - YARN.
1 parent a630b31 commit cf4f97d

File tree

28 files changed

+88
-214
lines changed

28 files changed

+88
-214
lines changed

hadoop-project/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
--enable-native-access=ALL-UNNAMED
187187
</extraJavaTestArgs>
188188
<!-- Plugin versions and config -->
189-
<maven-surefire-plugin.argLine>-Xmx4096m -Xss2m -XX:+HeapDumpOnOutOfMemoryError ${extraJavaTestArgs}</maven-surefire-plugin.argLine>
189+
<maven-surefire-plugin.argLine>-Xmx4096m -Xss4m -XX:+HeapDumpOnOutOfMemoryError ${extraJavaTestArgs}</maven-surefire-plugin.argLine>
190190
<maven-surefire-plugin.version>3.5.3</maven-surefire-plugin.version>
191191
<maven-surefire-report-plugin.version>${maven-surefire-plugin.version}</maven-surefire-report-plugin.version>
192192
<maven-failsafe-plugin.version>${maven-surefire-plugin.version}</maven-failsafe-plugin.version>

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/pom.xml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,6 @@
8080
</exclusions>
8181
</dependency>
8282

83-
<dependency>
84-
<groupId>junit</groupId>
85-
<artifactId>junit</artifactId>
86-
<scope>test</scope>
87-
</dependency>
8883
<dependency>
8984
<groupId>org.junit.jupiter</groupId>
9085
<artifactId>junit-jupiter-api</artifactId>
@@ -95,11 +90,6 @@
9590
<artifactId>junit-jupiter-engine</artifactId>
9691
<scope>test</scope>
9792
</dependency>
98-
<dependency>
99-
<groupId>org.junit.vintage</groupId>
100-
<artifactId>junit-vintage-engine</artifactId>
101-
<scope>test</scope>
102-
</dependency>
10393
<!-- Only required to run tests in an IDE that bundles an older version -->
10494
<dependency>
10595
<groupId>org.junit.platform</groupId>

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/pom.xml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@
3939
<scope>provided</scope>
4040
</dependency>
4141

42-
<dependency>
43-
<groupId>junit</groupId>
44-
<artifactId>junit</artifactId>
45-
<scope>test</scope>
46-
</dependency>
47-
4842
<dependency>
4943
<groupId>ch.qos.reload4j</groupId>
5044
<artifactId>reload4j</artifactId>
@@ -182,11 +176,6 @@
182176
<artifactId>junit-platform-launcher</artifactId>
183177
<scope>test</scope>
184178
</dependency>
185-
<dependency>
186-
<groupId>org.junit.vintage</groupId>
187-
<artifactId>junit-vintage-engine</artifactId>
188-
<scope>test</scope>
189-
</dependency>
190179

191180
</dependencies>
192181

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/test/java/org/apache/hadoop/yarn/applications/distributedshell/DistributedShellBaseTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.util.concurrent.atomic.AtomicReference;
3434
import java.util.function.Supplier;
3535

36+
import org.apache.hadoop.security.UserGroupInformation;
3637
import org.junit.jupiter.api.AfterEach;
3738
import org.junit.jupiter.api.AfterAll;
3839
import org.junit.jupiter.api.BeforeEach;
@@ -545,6 +546,20 @@ protected void setupInternal(int numNodeManagers,
545546
getTimelineVersion());
546547
// setup the configuration of relevant for each TimelineService version.
547548
customizeConfiguration(conf);
549+
550+
// To avoid data conflicts between unit tests caused by sharing the common directory
551+
// file:/tmp/hadoop-yarn-jenkins/node-labels—such as one test reading data written by another
552+
// and resulting in failures—we have optimized the directory logic.
553+
// Each unit test will now generate a unique directory path based on its method name.
554+
// For example:
555+
// file:/tmp/hadoop-yarn-jenkins/<method-name>/node-labels
556+
String nodeLabels = "file:///tmp/hadoop-yarn-" +
557+
UserGroupInformation.getCurrentUser().getShortUserName() +
558+
"/" + methodName + "/node-labels";
559+
java.nio.file.Path nodeLabelsPath = Paths.get(nodeLabels);
560+
Files.deleteIfExists(nodeLabelsPath);
561+
conf.set(YarnConfiguration.FS_NODE_LABELS_STORE_ROOT_DIR, nodeLabels);
562+
548563
// setup the yarn cluster.
549564
setUpYarnCluster(numNodeManagers, conf);
550565
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-unmanaged-am-launcher/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@
3232
</properties>
3333

3434
<dependencies>
35-
<dependency>
36-
<groupId>junit</groupId>
37-
<artifactId>junit</artifactId>
38-
<scope>test</scope>
39-
</dependency>
4035
<dependency>
4136
<groupId>commons-cli</groupId>
4237
<artifactId>commons-cli</artifactId>

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-api/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,6 @@
186186
<artifactId>hadoop-common</artifactId>
187187
<type>test-jar</type>
188188
</dependency>
189-
<dependency>
190-
<groupId>junit</groupId>
191-
<artifactId>junit</artifactId>
192-
<scope>test</scope>
193-
</dependency>
194189
<dependency>
195190
<groupId>org.apache.hadoop</groupId>
196191
<artifactId>hadoop-yarn-services-core</artifactId>

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/pom.xml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,6 @@
244244
<!-- Test dependencies -->
245245
<!-- ======================================================== -->
246246

247-
<dependency>
248-
<groupId>junit</groupId>
249-
<artifactId>junit</artifactId>
250-
<scope>test</scope>
251-
</dependency>
252-
253247
<dependency>
254248
<groupId>org.mockito</groupId>
255249
<artifactId>mockito-inline</artifactId>
@@ -289,11 +283,6 @@
289283
<artifactId>junit-platform-launcher</artifactId>
290284
<scope>test</scope>
291285
</dependency>
292-
<dependency>
293-
<groupId>org.junit.vintage</groupId>
294-
<artifactId>junit-vintage-engine</artifactId>
295-
<scope>test</scope>
296-
</dependency>
297286
</dependencies>
298287

299288
</project>

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/pom.xml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,6 @@
118118
<artifactId>snappy-java</artifactId>
119119
<scope>provided</scope>
120120
</dependency>
121-
<dependency>
122-
<groupId>junit</groupId>
123-
<artifactId>junit</artifactId>
124-
<scope>test</scope>
125-
</dependency>
126121
<dependency>
127122
<groupId>org.assertj</groupId>
128123
<artifactId>assertj-core</artifactId>
@@ -191,11 +186,6 @@
191186
<artifactId>junit-platform-launcher</artifactId>
192187
<scope>test</scope>
193188
</dependency>
194-
<dependency>
195-
<groupId>org.junit.vintage</groupId>
196-
<artifactId>junit-vintage-engine</artifactId>
197-
<scope>test</scope>
198-
</dependency>
199189

200190
</dependencies>
201191

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestGetGroups.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131
import org.apache.hadoop.util.Tool;
3232
import org.apache.hadoop.yarn.conf.YarnConfiguration;
3333
import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
34-
import org.junit.AfterClass;
35-
import org.junit.Assert;
36-
import org.junit.Before;
37-
import org.junit.BeforeClass;
34+
import org.junit.jupiter.api.AfterAll;
35+
import org.junit.jupiter.api.Assertions;
36+
import org.junit.jupiter.api.BeforeEach;
37+
import org.junit.jupiter.api.BeforeAll;
3838
import org.slf4j.Logger;
3939
import org.slf4j.LoggerFactory;
4040

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

4848
private static Configuration conf;
4949

50-
@BeforeClass
50+
@BeforeAll
5151
public static void setUpResourceManager() throws InterruptedException {
5252
conf = new YarnConfiguration();
5353
resourceManager = new ResourceManager() {
@@ -77,19 +77,19 @@ public void run() {
7777
}.start();
7878

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

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

8686
@SuppressWarnings("static-access")
87-
@Before
87+
@BeforeEach
8888
public void setUpConf() {
8989
super.conf = this.conf;
9090
}
9191

92-
@AfterClass
92+
@AfterAll
9393
public static void tearDownResourceManager() throws InterruptedException {
9494
if (resourceManager != null) {
9595
LOG.info("Stopping ResourceManager...");

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestRMFailover.java

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818

1919
package org.apache.hadoop.yarn.client;
2020

21-
import static org.junit.Assert.assertEquals;
22-
import static org.junit.Assert.assertFalse;
23-
import static org.junit.Assert.assertTrue;
24-
import static org.junit.Assert.assertNull;
25-
import static org.junit.Assert.assertSame;
26-
import static org.junit.Assert.fail;
21+
import static org.junit.jupiter.api.Assertions.assertEquals;
22+
import static org.junit.jupiter.api.Assertions.assertFalse;
23+
import static org.junit.jupiter.api.Assertions.assertTrue;
24+
import static org.junit.jupiter.api.Assertions.assertNull;
25+
import static org.junit.jupiter.api.Assertions.assertSame;
26+
import static org.junit.jupiter.api.Assertions.fail;
2727
import static org.mockito.Mockito.spy;
2828
import static org.mockito.Mockito.verify;
2929

@@ -56,10 +56,10 @@
5656
import org.apache.hadoop.yarn.server.resourcemanager.RMFatalEventType;
5757
import org.apache.hadoop.yarn.server.webproxy.WebAppProxyServer;
5858
import org.apache.hadoop.yarn.webapp.YarnWebParams;
59-
import org.junit.After;
60-
import org.junit.Assert;
61-
import org.junit.Before;
62-
import org.junit.Test;
59+
import org.junit.jupiter.api.AfterEach;
60+
import org.junit.jupiter.api.Assertions;
61+
import org.junit.jupiter.api.BeforeEach;
62+
import org.junit.jupiter.api.Test;
6363

6464
import java.util.function.Supplier;
6565
import org.slf4j.Logger;
@@ -81,7 +81,7 @@ public class TestRMFailover extends ClientBaseWithFixes {
8181
private MiniYARNCluster cluster;
8282
private ApplicationId fakeAppId;
8383

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

101-
@After
101+
@AfterEach
102102
public void teardown() {
103103
cluster.stop();
104104
}
@@ -123,8 +123,8 @@ private void verifyClientConnection() {
123123
}
124124

125125
private void verifyConnections() throws InterruptedException, YarnException {
126-
assertTrue("NMs failed to connect to the RM",
127-
cluster.waitForNodeManagersToConnect(20000));
126+
assertTrue(
127+
cluster.waitForNodeManagersToConnect(20000), "NMs failed to connect to the RM");
128128
verifyClientConnection();
129129
}
130130

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

143143
private void failover()
144144
throws IOException, InterruptedException, YarnException {
145145
int activeRMIndex = cluster.getActiveRMIndex();
146146
cluster.stopResourceManager(activeRMIndex);
147-
assertEquals("Failover failed",
148-
(activeRMIndex + 1) % 2, cluster.getActiveRMIndex());
147+
assertEquals(
148+
(activeRMIndex + 1) % 2, cluster.getActiveRMIndex(), "Failover failed");
149149
cluster.restartResourceManager(activeRMIndex);
150150
}
151151

@@ -155,7 +155,7 @@ public void testExplicitFailover()
155155
conf.setBoolean(YarnConfiguration.AUTO_FAILOVER_ENABLED, false);
156156
cluster.init(conf);
157157
cluster.start();
158-
assertFalse("RM never turned active", -1 == cluster.getActiveRMIndex());
158+
assertFalse(-1 == cluster.getActiveRMIndex(), "RM never turned active");
159159
verifyConnections();
160160

161161
explicitFailover();
@@ -189,7 +189,7 @@ public void testAutomaticFailover()
189189

190190
cluster.init(conf);
191191
cluster.start();
192-
assertFalse("RM never turned active", -1 == cluster.getActiveRMIndex());
192+
assertFalse(-1 == cluster.getActiveRMIndex(), "RM never turned active");
193193
verifyConnections();
194194

195195
failover();
@@ -220,14 +220,14 @@ public void testWebAppProxyInStandAloneMode() throws YarnException,
220220
cluster.init(conf);
221221
cluster.start();
222222
getAdminService(0).transitionToActive(req);
223-
assertFalse("RM never turned active", -1 == cluster.getActiveRMIndex());
223+
assertFalse(-1 == cluster.getActiveRMIndex(), "RM never turned active");
224224
verifyConnections();
225225
webAppProxyServer.init(conf);
226226

227227
// Start webAppProxyServer
228-
Assert.assertEquals(STATE.INITED, webAppProxyServer.getServiceState());
228+
Assertions.assertEquals(STATE.INITED, webAppProxyServer.getServiceState());
229229
webAppProxyServer.start();
230-
Assert.assertEquals(STATE.STARTED, webAppProxyServer.getServiceState());
230+
Assertions.assertEquals(STATE.STARTED, webAppProxyServer.getServiceState());
231231

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

259259
// send httpRequest with fakeApplicationId
@@ -391,7 +391,7 @@ public void testUncaughtExceptionHandlerWithHAEnabled()
391391
conf.set(YarnConfiguration.RM_ZK_ADDRESS, hostPort);
392392
cluster.init(conf);
393393
cluster.start();
394-
assertFalse("RM never turned active", -1 == cluster.getActiveRMIndex());
394+
assertFalse(-1 == cluster.getActiveRMIndex(), "RM never turned active");
395395

396396
ResourceManager resourceManager = cluster.getResourceManager(
397397
cluster.getActiveRMIndex());

0 commit comments

Comments
 (0)