Skip to content

YARN-11806. Skip tests that depend on custom SecurityManager when Java doesn't support it #7568

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

Merged
merged 1 commit into from
Apr 9, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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{
Expand Down