From d311bf9c240b622a50c93d17d553f7e70e3c7b3b Mon Sep 17 00:00:00 2001 From: Alejandro Abdelnur Date: Mon, 18 Mar 2013 19:44:23 +0000 Subject: [PATCH] YARN-485. TestProcfsProcessTree#testProcessTree() doesn't wait long enough for the process to die. (kkambatl via tucu) git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1457938 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-yarn-project/CHANGES.txt | 3 +++ .../yarn/util/TestProcfsBasedProcessTree.java | 21 ++++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 21ae6260bc6..0a6f76c06c6 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -52,6 +52,9 @@ Release 2.0.5-beta - UNRELEASED YARN-196. Nodemanager should be more robust in handling connection failure to ResourceManager when a cluster is started (Xuan Gong via hitesh) + YARN-485. TestProcfsProcessTree#testProcessTree() doesn't wait long enough + for the process to die. (kkambatl via tucu) + Release 2.0.4-alpha - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestProcfsBasedProcessTree.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestProcfsBasedProcessTree.java index 528e03e4ead..13cf8689abe 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestProcfsBasedProcessTree.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestProcfsBasedProcessTree.java @@ -18,6 +18,8 @@ package org.apache.hadoop.yarn.util; +import static org.junit.Assert.fail; + import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; @@ -183,11 +185,20 @@ public class TestProcfsBasedProcessTree { // destroy the process and all its subprocesses destroyProcessTree(pid); - if (isSetsidAvailable()) { // whole processtree should be gone - Assert.assertFalse("Proceesses in process group live", - isAnyProcessInTreeAlive(p)); - } else {// process should be gone - Assert.assertFalse("ProcessTree must have been gone", isAlive(pid)); + boolean isAlive = true; + for (int tries = 100; tries > 0; tries--) { + if (isSetsidAvailable()) {// whole processtree + isAlive = isAnyProcessInTreeAlive(p); + } else {// process + isAlive = isAlive(pid); + } + if (!isAlive) { + break; + } + Thread.sleep(100); + } + if (isAlive) { + fail("ProcessTree shouldn't be alive"); } LOG.info("Process-tree dump follows: \n" + processTreeDump);