From e54c65a32663b717d8c91abc259f0a41c55e66da Mon Sep 17 00:00:00 2001 From: Robert Kanter Date: Tue, 16 Jan 2018 10:16:42 -0800 Subject: [PATCH] YARN-7479. TestContainerManagerSecurity.testContainerManager[Simple] flaky in trunk (ajisakaa via rkanter) (cherry picked from commit 5ac109909a29fab30363b752b5215be7f5dc616b) --- .../server/TestContainerManagerSecurity.java | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestContainerManagerSecurity.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestContainerManagerSecurity.java index ad2f68ab8fd..77a021c5cf9 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestContainerManagerSecurity.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestContainerManagerSecurity.java @@ -30,12 +30,10 @@ import java.util.LinkedList; import java.util.List; import java.util.concurrent.TimeoutException; -import com.google.common.base.Supplier; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.CommonConfigurationKeysPublic; import org.apache.hadoop.io.DataInputBuffer; import org.apache.hadoop.minikdc.KerberosSecurityTestcase; -import org.apache.hadoop.net.NetUtils; import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.security.token.SecretManager.InvalidToken; import org.apache.hadoop.test.GenericTestUtils; @@ -52,7 +50,6 @@ import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; import org.apache.hadoop.yarn.api.records.ContainerState; -import org.apache.hadoop.yarn.api.records.ContainerStatus; import org.apache.hadoop.yarn.api.records.NodeId; import org.apache.hadoop.yarn.api.records.Priority; import org.apache.hadoop.yarn.api.records.Resource; @@ -409,9 +406,10 @@ public class TestContainerManagerSecurity extends KerberosSecurityTestcase { } private void waitForContainerToFinishOnNM(ContainerId containerId) - throws TimeoutException, InterruptedException { + throws InterruptedException { Context nmContext = yarnCluster.getNodeManager(0).getNMContext(); - int interval = 4 * 60; // Max time for container token to expire. + // Max time for container token to expire. + final int timeout = 4 * 60 * 1000; // If the container is null, then it has already completed and been removed // from the Context by asynchronous calls. @@ -420,14 +418,11 @@ public class TestContainerManagerSecurity extends KerberosSecurityTestcase { try { LOG.info("Waiting for " + containerId + " to get to state " + ContainerState.COMPLETE); - GenericTestUtils.waitFor(new Supplier() { - @Override - public Boolean get() { - return ContainerState.COMPLETE.equals( - waitContainer.cloneAndGetContainerStatus().getState()); - } - }, 10, interval); + GenericTestUtils.waitFor(() -> ContainerState.COMPLETE.equals( + waitContainer.cloneAndGetContainerStatus().getState()), + 500, timeout); } catch (TimeoutException te) { + LOG.error("TimeoutException", te); fail("Was waiting for " + containerId + " to get to state " + ContainerState.COMPLETE + " but was in state " + waitContainer.cloneAndGetContainerStatus().getState() +