Repository: hadoop
Updated Branches:
  refs/heads/trunk 0477eff8b -> 480187aeb


YARN-7372. 
TestContainerSchedulerQueuing.testContainerUpdateExecTypeGuaranteedToOpportunistic
 is flaky.


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

Branch: refs/heads/trunk
Commit: 480187aebbc13547af06684820a416d22e7c4649
Parents: 0477eff
Author: Haibo Chen <haiboc...@apache.org>
Authored: Fri Oct 20 14:24:17 2017 -0700
Committer: Haibo Chen <haiboc...@apache.org>
Committed: Fri Oct 20 14:24:17 2017 -0700

----------------------------------------------------------------------
 .../TestContainerSchedulerQueuing.java          | 30 ++++++++++++++++----
 1 file changed, 25 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/480187ae/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/scheduler/TestContainerSchedulerQueuing.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/scheduler/TestContainerSchedulerQueuing.java
 
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/scheduler/TestContainerSchedulerQueuing.java
index ed4f290..5c72e7e 100644
--- 
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/scheduler/TestContainerSchedulerQueuing.java
+++ 
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/scheduler/TestContainerSchedulerQueuing.java
@@ -21,14 +21,17 @@ package 
org.apache.hadoop.yarn.server.nodemanager.containermanager.scheduler;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
+import com.google.common.base.Supplier;
 import org.apache.hadoop.fs.UnsupportedFileSystemException;
 import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.yarn.api.protocolrecords.ContainerUpdateRequest;
 import org.apache.hadoop.yarn.api.protocolrecords.ContainerUpdateResponse;
 import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusesRequest;
@@ -1247,7 +1250,7 @@ public class TestContainerSchedulerQueuing extends 
BaseContainerManagerTest {
 
   @Test
   public void testContainerUpdateExecTypeGuaranteedToOpportunistic()
-      throws IOException, YarnException, InterruptedException {
+      throws Exception {
     delayContainers = true;
     containerManager.start();
     // Construct the Container-id
@@ -1287,11 +1290,28 @@ public class TestContainerSchedulerQueuing extends 
BaseContainerManagerTest {
         1, updateResponse.getSuccessfullyUpdatedContainers().size());
     Assert.assertTrue(updateResponse.getFailedRequests().isEmpty());
 
-    //Make sure the container is running
-    List<ContainerId> statList = new ArrayList<ContainerId>();
-    statList.add(cId);
     GetContainerStatusesRequest statRequest =
-        GetContainerStatusesRequest.newInstance(statList);
+        
GetContainerStatusesRequest.newInstance(Collections.singletonList(cId));
+    GenericTestUtils.waitFor(
+        new Supplier<Boolean>() {
+          @Override
+          public Boolean get() {
+            try {
+              List<ContainerStatus> containerStatuses = containerManager
+                  .getContainerStatuses(statRequest).getContainerStatuses();
+              Assert.assertEquals(1, containerStatuses.size());
+
+              ContainerStatus status = containerStatuses.get(0);
+              Assert.assertEquals(
+                  org.apache.hadoop.yarn.api.records.ContainerState.RUNNING,
+                  status.getState());
+
+              return status.getExecutionType() == ExecutionType.OPPORTUNISTIC;
+            } catch (Exception ex) {
+              throw new RuntimeException(ex);
+            }
+          }
+        }, 100, 10000);
     List<ContainerStatus> containerStatuses = containerManager
         .getContainerStatuses(statRequest).getContainerStatuses();
     Assert.assertEquals(1, containerStatuses.size());


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