Skip to content

Commit bcbefa7

Browse files
committed
YARN-11806. Skip tests that depend on custom SecurityManager when Java doesn't support it
1 parent 160b06b commit bcbefa7

File tree

2 files changed

+19
-7
lines changed
  • hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server

2 files changed

+19
-7
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/resources/TestCGroupsHandlerImpl.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import static org.junit.jupiter.api.Assertions.assertFalse;
4747
import static org.junit.jupiter.api.Assertions.assertTrue;
4848
import static org.junit.jupiter.api.Assertions.fail;
49+
import static org.junit.jupiter.api.Assumptions.assumeTrue;
4950
import static org.mockito.ArgumentMatchers.eq;
5051
import static org.mockito.Mockito.verify;
5152
import static org.mockito.Mockito.verifyNoMoreInteractions;
@@ -371,7 +372,11 @@ private void testPreMountedControllerInitialization(String myHierarchy)
371372
assertFalse(cpuCgroupMountDir.delete(), "Could not delete cgroups");
372373
assertFalse(cpuCgroupMountDir.exists(), "Directory should be deleted");
373374
SecurityManager manager = System.getSecurityManager();
374-
System.setSecurityManager(new MockSecurityManagerDenyWrite());
375+
try {
376+
System.setSecurityManager(new MockSecurityManagerDenyWrite());
377+
} catch (UnsupportedOperationException e) {
378+
assumeTrue(false, "Test is skipped because SecurityManager cannot be set (JEP 411)");
379+
}
375380
try {
376381
cGroupsHandler.initializeCGroupController(
377382
CGroupsHandler.CGroupController.CPU);

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerAsyncScheduling.java

+13-6
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.SimpleCandidateNodeSet;
7777
import org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey;
7878
import org.apache.hadoop.yarn.util.resource.Resources;
79+
import org.junit.jupiter.api.Assumptions;
7980
import org.junit.jupiter.api.BeforeEach;
8081
import org.junit.jupiter.api.Test;
8182
import org.junit.jupiter.api.Timeout;
@@ -1103,17 +1104,23 @@ public Boolean answer(InvocationOnMock invocation) throws Exception {
11031104
@Test
11041105
@Timeout(value = 30)
11051106
public void testAsyncScheduleThreadExit() throws Exception {
1106-
// init RM & NM
1107-
final MockRM rm = new MockRM(conf);
1108-
rm.start();
1109-
rm.registerNode("192.168.0.1:1234", 8 * GB);
1110-
rm.drainEvents();
11111107

11121108
// Set no exit security manager to catch System.exit
11131109
SecurityManager originalSecurityManager = System.getSecurityManager();
11141110
NoExitSecurityManager noExitSecurityManager =
11151111
new NoExitSecurityManager(originalSecurityManager);
1116-
System.setSecurityManager(noExitSecurityManager);
1112+
try {
1113+
System.setSecurityManager(noExitSecurityManager);
1114+
} catch (UnsupportedOperationException e) {
1115+
Assumptions.assumeTrue(false,
1116+
"Test is skipped because SecurityManager cannot be set (JEP411)");
1117+
}
1118+
1119+
// init RM & NM
1120+
final MockRM rm = new MockRM(conf);
1121+
rm.start();
1122+
rm.registerNode("192.168.0.1:1234", 8 * GB);
1123+
rm.drainEvents();
11171124

11181125
// test async-scheduling thread exit
11191126
try{

0 commit comments

Comments
 (0)