YARN-10256. Refactor TestContainerSchedulerQueuing.testContainerUpdateExecTypeGuaranteedToOpportunistic (Ahmed Hussein via jeagles)
Signed-off-by: Jonathan Eagles <jeagles@gmail.com>
This commit is contained in:
parent
8dace8ff3a
commit
f5081a9a5d
|
@ -28,7 +28,6 @@ import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
|
||||||
import org.apache.hadoop.fs.UnsupportedFileSystemException;
|
import org.apache.hadoop.fs.UnsupportedFileSystemException;
|
||||||
import org.apache.hadoop.security.UserGroupInformation;
|
import org.apache.hadoop.security.UserGroupInformation;
|
||||||
import org.apache.hadoop.test.GenericTestUtils;
|
import org.apache.hadoop.test.GenericTestUtils;
|
||||||
|
@ -1291,37 +1290,24 @@ public class TestContainerSchedulerQueuing extends BaseContainerManagerTest {
|
||||||
1, updateResponse.getSuccessfullyUpdatedContainers().size());
|
1, updateResponse.getSuccessfullyUpdatedContainers().size());
|
||||||
Assert.assertTrue(updateResponse.getFailedRequests().isEmpty());
|
Assert.assertTrue(updateResponse.getFailedRequests().isEmpty());
|
||||||
|
|
||||||
GetContainerStatusesRequest statRequest =
|
final GetContainerStatusesRequest statRequest =
|
||||||
GetContainerStatusesRequest.newInstance(Collections.singletonList(cId));
|
GetContainerStatusesRequest.newInstance(
|
||||||
GenericTestUtils.waitFor(
|
Collections.singletonList(cId));
|
||||||
new Supplier<Boolean>() {
|
final org.apache.hadoop.yarn.api.records.ContainerState expectedState =
|
||||||
@Override
|
org.apache.hadoop.yarn.api.records.ContainerState.RUNNING;
|
||||||
public Boolean get() {
|
|
||||||
try {
|
|
||||||
List<ContainerStatus> containerStatuses = containerManager
|
|
||||||
.getContainerStatuses(statRequest).getContainerStatuses();
|
|
||||||
Assert.assertEquals(1, containerStatuses.size());
|
|
||||||
|
|
||||||
ContainerStatus status = containerStatuses.get(0);
|
GenericTestUtils.waitFor(() -> {
|
||||||
Assert.assertEquals(
|
List<ContainerStatus> containerStatuses;
|
||||||
org.apache.hadoop.yarn.api.records.ContainerState.RUNNING,
|
try {
|
||||||
status.getState());
|
containerStatuses = containerManager
|
||||||
|
.getContainerStatuses(statRequest).getContainerStatuses();
|
||||||
return status.getExecutionType() == ExecutionType.OPPORTUNISTIC;
|
} catch (YarnException | IOException e) {
|
||||||
} catch (Exception ex) {
|
return false;
|
||||||
throw new RuntimeException(ex);
|
}
|
||||||
}
|
Assert.assertEquals(1, containerStatuses.size());
|
||||||
}
|
ContainerStatus status = containerStatuses.get(0);
|
||||||
}, 100, 10000);
|
return (status.getState() == expectedState
|
||||||
List<ContainerStatus> containerStatuses = containerManager
|
&& status.getExecutionType() == ExecutionType.OPPORTUNISTIC);
|
||||||
.getContainerStatuses(statRequest).getContainerStatuses();
|
}, 20, 10000);
|
||||||
Assert.assertEquals(1, containerStatuses.size());
|
|
||||||
for (ContainerStatus status : containerStatuses) {
|
|
||||||
Assert.assertEquals(
|
|
||||||
org.apache.hadoop.yarn.api.records.ContainerState.RUNNING,
|
|
||||||
status.getState());
|
|
||||||
Assert
|
|
||||||
.assertEquals(ExecutionType.OPPORTUNISTIC, status.getExecutionType());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue