YARN-8388. TestCGroupElasticMemoryController.testNormalExit() hangs on Linux. (Miklos Szegedi via Haibo Chen)

This commit is contained in:
Haibo Chen 2018-06-04 11:13:40 -07:00
parent dad1bb868f
commit 04cf699dd5
2 changed files with 5 additions and 22 deletions

View File

@ -25,7 +25,6 @@
public final class PlatformAssumptions { public final class PlatformAssumptions {
public static final String OS_NAME = System.getProperty("os.name"); public static final String OS_NAME = System.getProperty("os.name");
public static final boolean WINDOWS = OS_NAME.startsWith("Windows"); public static final boolean WINDOWS = OS_NAME.startsWith("Windows");
public static final boolean MAC_OS = OS_NAME.startsWith("Mac OS X");
private PlatformAssumptions() { } private PlatformAssumptions() { }
@ -45,11 +44,4 @@ public static void assumeWindows() {
"Expected Windows platform but got " + OS_NAME); "Expected Windows platform but got " + OS_NAME);
} }
} }
public static void assumeMacOS() {
if (!MAC_OS) {
throw new AssumptionViolatedException(
"Expected MacOS platform but got " + OS_NAME);
}
}
} }

View File

@ -38,7 +38,6 @@
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import static org.apache.hadoop.test.PlatformAssumptions.assumeMacOS;
/** /**
* Test for elastic non-strict memory controller based on cgroups. * Test for elastic non-strict memory controller based on cgroups.
@ -257,26 +256,20 @@ public void testNothingToKill() throws Exception {
/** /**
* Test that node manager can exit listening. * Test that node manager can exit listening.
* This is done by running a long running listener for 10 seconds. * This is done by running a long running listener for 10000 seconds.
* Then we wait for 2 seconds and stop listening. * Then we wait for 2 seconds and stop listening.
* We do not use a script this time to avoid leaking the child process.
* @throws Exception exception occurred * @throws Exception exception occurred
*/ */
@Test(timeout = 20000) @Test(timeout = 20000)
public void testNormalExit() throws Exception { public void testNormalExit() throws Exception {
// TODO This may hang on Linux
assumeMacOS();
conf.set(YarnConfiguration.NM_ELASTIC_MEMORY_CONTROL_OOM_LISTENER_PATH, conf.set(YarnConfiguration.NM_ELASTIC_MEMORY_CONTROL_OOM_LISTENER_PATH,
script.getAbsolutePath()); "sleep");
ExecutorService service = Executors.newFixedThreadPool(1); ExecutorService service = Executors.newFixedThreadPool(1);
try { try {
FileUtils.writeStringToFile(script,
"#!/bin/bash\nsleep 10000;",
Charset.defaultCharset(), false);
assertTrue("Could not set executable",
script.setExecutable(true));
CGroupsHandler cgroups = mock(CGroupsHandler.class); CGroupsHandler cgroups = mock(CGroupsHandler.class);
when(cgroups.getPathForCGroup(any(), any())).thenReturn(""); // This will be passed to sleep as an argument
when(cgroups.getPathForCGroup(any(), any())).thenReturn("10000");
when(cgroups.getCGroupParam(any(), any(), any())) when(cgroups.getCGroupParam(any(), any(), any()))
.thenReturn("under_oom 0"); .thenReturn("under_oom 0");
@ -308,8 +301,6 @@ public void testNormalExit() throws Exception {
controller.run(); controller.run();
} finally { } finally {
service.shutdown(); service.shutdown();
assertTrue(String.format("Could not clean up script %s",
script.getAbsolutePath()), script.delete());
} }
} }