|
@@ -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());
|