This is an automated email from the ASF dual-hosted git repository.

slfan1989 pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 0928d15c2d3 YARN-11806. Skip tests that depend on custom 
SecurityManager when Java doesn't support it (#7568) Contributed by Istvan Toth.
0928d15c2d3 is described below

commit 0928d15c2d388ad0d32a8cce9498f9eddea98c5c
Author: Istvan Toth <st...@apache.org>
AuthorDate: Wed Apr 9 04:06:21 2025 +0200

    YARN-11806. Skip tests that depend on custom SecurityManager when Java 
doesn't support it (#7568) Contributed by Istvan Toth.
    
    Signed-off-by: Shilun Fan <slfan1...@apache.org>
---
 .../linux/resources/TestCGroupsHandlerImpl.java       |  7 ++++++-
 .../TestCapacitySchedulerAsyncScheduling.java         | 19 +++++++++++++------
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git 
a/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
 
b/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
index 668877a74cc..388d501e80a 100644
--- 
a/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
+++ 
b/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
@@ -46,6 +46,7 @@
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyNoMoreInteractions;
@@ -371,7 +372,11 @@ private void testPreMountedControllerInitialization(String 
myHierarchy)
       assertFalse(cpuCgroupMountDir.delete(), "Could not delete cgroups");
       assertFalse(cpuCgroupMountDir.exists(), "Directory should be deleted");
       SecurityManager manager = System.getSecurityManager();
-      System.setSecurityManager(new MockSecurityManagerDenyWrite());
+      try {
+        System.setSecurityManager(new MockSecurityManagerDenyWrite());
+      } catch (UnsupportedOperationException e) {
+        assumeTrue(false, "Test is skipped because SecurityManager cannot be 
set (JEP 411)");
+      }
       try {
         cGroupsHandler.initializeCGroupController(
             CGroupsHandler.CGroupController.CPU);
diff --git 
a/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
 
b/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
index ac88d09868e..4e63d3858ab 100644
--- 
a/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
+++ 
b/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
@@ -76,6 +76,7 @@
 import 
org.apache.hadoop.yarn.server.resourcemanager.scheduler.placement.SimpleCandidateNodeSet;
 import org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey;
 import org.apache.hadoop.yarn.util.resource.Resources;
+import org.junit.jupiter.api.Assumptions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.Timeout;
@@ -1103,17 +1104,23 @@ public Boolean answer(InvocationOnMock invocation) 
throws Exception {
   @Test
   @Timeout(value = 30)
   public void testAsyncScheduleThreadExit() throws Exception {
-    // init RM & NM
-    final MockRM rm = new MockRM(conf);
-    rm.start();
-    rm.registerNode("192.168.0.1:1234", 8 * GB);
-    rm.drainEvents();
 
     // Set no exit security manager to catch System.exit
     SecurityManager originalSecurityManager = System.getSecurityManager();
     NoExitSecurityManager noExitSecurityManager =
         new NoExitSecurityManager(originalSecurityManager);
-    System.setSecurityManager(noExitSecurityManager);
+    try {
+      System.setSecurityManager(noExitSecurityManager);
+    } catch (UnsupportedOperationException e) {
+      Assumptions.assumeTrue(false,
+          "Test is skipped because SecurityManager cannot be set (JEP411)");
+    }
+
+    // init RM & NM
+    final MockRM rm = new MockRM(conf);
+    rm.start();
+    rm.registerNode("192.168.0.1:1234", 8 * GB);
+    rm.drainEvents();
 
     // test async-scheduling thread exit
     try{


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-commits-h...@hadoop.apache.org

Reply via email to