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


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/04cf699d
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/04cf699d
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/04cf699d

Branch: refs/heads/YARN-1011
Commit: 04cf699dd54aab3595eb80295652dcde9a2f4dd5
Parents: dad1bb8
Author: Haibo Chen <haiboc...@apache.org>
Authored: Mon Jun 4 11:13:40 2018 -0700
Committer: Haibo Chen <haiboc...@apache.org>
Committed: Mon Jun 4 14:23:08 2018 -0700

----------------------------------------------------------------------
 .../apache/hadoop/test/PlatformAssumptions.java  |  8 --------
 .../TestCGroupElasticMemoryController.java       | 19 +++++--------------
 2 files changed, 5 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/04cf699d/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/PlatformAssumptions.java
----------------------------------------------------------------------
diff --git 
a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/PlatformAssumptions.java
 
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/PlatformAssumptions.java
index fdbb71f..4e83162 100644
--- 
a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/PlatformAssumptions.java
+++ 
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/PlatformAssumptions.java
@@ -25,7 +25,6 @@ import org.junit.internal.AssumptionViolatedException;
 public final class PlatformAssumptions {
   public static final String OS_NAME = System.getProperty("os.name");
   public static final boolean WINDOWS = OS_NAME.startsWith("Windows");
-  public static final boolean MAC_OS = OS_NAME.startsWith("Mac OS X");
 
   private PlatformAssumptions() { }
 
@@ -45,11 +44,4 @@ public final class PlatformAssumptions {
           "Expected Windows platform but got " + OS_NAME);
     }
   }
-
-  public static void assumeMacOS() {
-    if (!MAC_OS) {
-      throw new AssumptionViolatedException(
-          "Expected MacOS platform but got " + OS_NAME);
-    }
-  }
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/04cf699d/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/resources/TestCGroupElasticMemoryController.java
----------------------------------------------------------------------
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/TestCGroupElasticMemoryController.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/TestCGroupElasticMemoryController.java
index c263c79..e93bc5d 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/TestCGroupElasticMemoryController.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/TestCGroupElasticMemoryController.java
@@ -38,7 +38,6 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
-import static org.apache.hadoop.test.PlatformAssumptions.assumeMacOS;
 
 /**
  * Test for elastic non-strict memory controller based on cgroups.
@@ -257,26 +256,20 @@ public class TestCGroupElasticMemoryController {
 
   /**
    * 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.
+   * We do not use a script this time to avoid leaking the child process.
    * @throws Exception exception occurred
    */
   @Test(timeout = 20000)
   public void testNormalExit() throws Exception {
-    // TODO This may hang on Linux
-    assumeMacOS();
     conf.set(YarnConfiguration.NM_ELASTIC_MEMORY_CONTROL_OOM_LISTENER_PATH,
-        script.getAbsolutePath());
+        "sleep");
     ExecutorService service = Executors.newFixedThreadPool(1);
     try {
-      FileUtils.writeStringToFile(script,
-          "#!/bin/bash\nsleep 10000;",
-          Charset.defaultCharset(), false);
-      assertTrue("Could not set executable",
-          script.setExecutable(true));
-
       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()))
           .thenReturn("under_oom 0");
 
@@ -308,8 +301,6 @@ public class TestCGroupElasticMemoryController {
       controller.run();
     } finally {
       service.shutdown();
-      assertTrue(String.format("Could not clean up script %s",
-          script.getAbsolutePath()), script.delete());
     }
   }
 


---------------------------------------------------------------------
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