YARN-7372. TestContainerSchedulerQueuing.testContainerUpdateExecTypeGuaranteedToOpportunistic is flaky.

This commit is contained in:
Haibo Chen 2017-10-20 14:24:17 -07:00
parent 0477eff8be
commit 480187aebb

View File

@ -21,14 +21,17 @@
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 void testPromotionOfOpportunisticContainers() throws Exception {
@Test
public void testContainerUpdateExecTypeGuaranteedToOpportunistic()
throws IOException, YarnException, InterruptedException {
throws Exception {
delayContainers = true;
containerManager.start();
// Construct the Container-id
@ -1287,11 +1290,28 @@ public void testContainerUpdateExecTypeGuaranteedToOpportunistic()
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());