From common-commits-return-83677-archive-asf-public=cust-asf.ponee.io@hadoop.apache.org Sat Jun 2 01:29:33 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 7714118063A for ; Sat, 2 Jun 2018 01:29:32 +0200 (CEST) Received: (qmail 47417 invoked by uid 500); 1 Jun 2018 23:29:31 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 47408 invoked by uid 99); 1 Jun 2018 23:29:31 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Jun 2018 23:29:31 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 45D6CE10FF; Fri, 1 Jun 2018 23:29:31 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: haibochen@apache.org To: common-commits@hadoop.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: hadoop git commit: YARN-8375. TestCGroupElasticMemoryController fails surefire build. (Miklos Szegedi via Haibo Chen) Date: Fri, 1 Jun 2018 23:29:31 +0000 (UTC) Repository: hadoop Updated Branches: refs/heads/trunk 34710c66d -> 4880d890e YARN-8375. TestCGroupElasticMemoryController fails surefire build. (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/4880d890 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/4880d890 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/4880d890 Branch: refs/heads/trunk Commit: 4880d890ee4716dafc5ff464c92a3c6d83b1db9b Parents: 34710c6 Author: Haibo Chen Authored: Fri Jun 1 16:28:13 2018 -0700 Committer: Haibo Chen Committed: Fri Jun 1 16:29:13 2018 -0700 ---------------------------------------------------------------------- .../apache/hadoop/test/PlatformAssumptions.java | 8 +++ .../TestCGroupElasticMemoryController.java | 65 +++++++++++--------- 2 files changed, 45 insertions(+), 28 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/4880d890/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 4e83162..fdbb71f 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,6 +25,7 @@ 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() { } @@ -44,4 +45,11 @@ 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/4880d890/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 118d172..c263c79 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 @@ -18,6 +18,8 @@ package org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources; import org.apache.commons.io.FileUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.exceptions.YarnException; import org.apache.hadoop.yarn.exceptions.YarnRuntimeException; @@ -36,11 +38,14 @@ 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. */ public class TestCGroupElasticMemoryController { + protected static final Log LOG = LogFactory + .getLog(TestCGroupElasticMemoryController.class); private YarnConfiguration conf = new YarnConfiguration(); private File script = new File("target/" + TestCGroupElasticMemoryController.class.getName()); @@ -52,15 +57,14 @@ public class TestCGroupElasticMemoryController { @Test(expected = YarnException.class) public void testConstructorOff() throws YarnException { - CGroupElasticMemoryController controller = - new CGroupElasticMemoryController( - conf, - null, - null, - false, - false, - 10000 - ); + new CGroupElasticMemoryController( + conf, + null, + null, + false, + false, + 10000 + ); } /** @@ -74,22 +78,21 @@ public class TestCGroupElasticMemoryController { DummyRunnableWithContext.class, Runnable.class); CGroupsHandler handler = mock(CGroupsHandler.class); when(handler.getPathForCGroup(any(), any())).thenReturn(""); - CGroupElasticMemoryController controller = - new CGroupElasticMemoryController( - conf, - null, - handler, - true, - false, - 10000 - ); + new CGroupElasticMemoryController( + conf, + null, + handler, + true, + false, + 10000 + ); } /** * Test that the handler is notified about multiple OOM events. * @throws Exception on exception */ - @Test + @Test(timeout = 20000) public void testMultipleOOMEvents() throws Exception { conf.set(YarnConfiguration.NM_ELASTIC_MEMORY_CONTROL_OOM_LISTENER_PATH, script.getAbsolutePath()); @@ -131,7 +134,7 @@ public class TestCGroupElasticMemoryController { * the child process starts * @throws Exception one exception */ - @Test + @Test(timeout = 20000) public void testStopBeforeStart() throws Exception { conf.set(YarnConfiguration.NM_ELASTIC_MEMORY_CONTROL_OOM_LISTENER_PATH, script.getAbsolutePath()); @@ -173,7 +176,7 @@ public class TestCGroupElasticMemoryController { * Test the edge case that OOM is never resolved. * @throws Exception on exception */ - @Test(expected = YarnRuntimeException.class) + @Test(timeout = 20000, expected = YarnRuntimeException.class) public void testInfiniteOOM() throws Exception { conf.set(YarnConfiguration.NM_ELASTIC_MEMORY_CONTROL_OOM_LISTENER_PATH, script.getAbsolutePath()); @@ -215,7 +218,7 @@ public class TestCGroupElasticMemoryController { * containers. * @throws Exception on exception */ - @Test(expected = YarnRuntimeException.class) + @Test(timeout = 20000, expected = YarnRuntimeException.class) public void testNothingToKill() throws Exception { conf.set(YarnConfiguration.NM_ELASTIC_MEMORY_CONTROL_OOM_LISTENER_PATH, script.getAbsolutePath()); @@ -258,13 +261,16 @@ public class TestCGroupElasticMemoryController { * Then we wait for 2 seconds and stop listening. * @throws Exception exception occurred */ - @Test + @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()); + ExecutorService service = Executors.newFixedThreadPool(1); try { FileUtils.writeStringToFile(script, - "#!/bin/bash\nsleep 10000;\n", + "#!/bin/bash\nsleep 10000;", Charset.defaultCharset(), false); assertTrue("Could not set executable", script.setExecutable(true)); @@ -287,17 +293,21 @@ public class TestCGroupElasticMemoryController { 10000, handler ); - ExecutorService service = Executors.newFixedThreadPool(1); + long start = System.currentTimeMillis(); service.submit(() -> { try { Thread.sleep(2000); } catch (InterruptedException ex) { assertTrue("Wait interrupted.", false); } + LOG.info(String.format("Calling process destroy in %d ms", + System.currentTimeMillis() - start)); controller.stopListening(); + LOG.info("Called process destroy."); }); controller.run(); } finally { + service.shutdown(); assertTrue(String.format("Could not clean up script %s", script.getAbsolutePath()), script.delete()); } @@ -312,8 +322,7 @@ public class TestCGroupElasticMemoryController { public void testDefaultConstructor() throws YarnException{ CGroupsHandler handler = mock(CGroupsHandler.class); when(handler.getPathForCGroup(any(), any())).thenReturn(""); - CGroupElasticMemoryController controller = - new CGroupElasticMemoryController( - conf, null, handler, true, false, 10); + new CGroupElasticMemoryController( + conf, null, handler, true, false, 10); } } --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org For additional commands, e-mail: common-commits-help@hadoop.apache.org