YARN-10256. Refactor TestContainerSchedulerQueuing.testContainerUpdateExecTypeGuaranteedToOpportunistic (Ahmed Hussein via jeagles)
Signed-off-by: Jonathan Eagles <jeagles@gmail.com>
(cherry picked from commit f5081a9a5d
)
This commit is contained in:
parent
69163f5e5d
commit
e25ac17e2b
|
@ -28,7 +28,6 @@ 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;
|
||||
|
@ -1256,37 +1255,24 @@ public class TestContainerSchedulerQueuing extends BaseContainerManagerTest {
|
|||
1, updateResponse.getSuccessfullyUpdatedContainers().size());
|
||||
Assert.assertTrue(updateResponse.getFailedRequests().isEmpty());
|
||||
|
||||
GetContainerStatusesRequest statRequest =
|
||||
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());
|
||||
final GetContainerStatusesRequest statRequest =
|
||||
GetContainerStatusesRequest.newInstance(
|
||||
Collections.singletonList(cId));
|
||||
final org.apache.hadoop.yarn.api.records.ContainerState expectedState =
|
||||
org.apache.hadoop.yarn.api.records.ContainerState.RUNNING;
|
||||
|
||||
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());
|
||||
for (ContainerStatus status : containerStatuses) {
|
||||
Assert.assertEquals(
|
||||
org.apache.hadoop.yarn.api.records.ContainerState.RUNNING,
|
||||
status.getState());
|
||||
Assert
|
||||
.assertEquals(ExecutionType.OPPORTUNISTIC, status.getExecutionType());
|
||||
}
|
||||
GenericTestUtils.waitFor(() -> {
|
||||
List<ContainerStatus> containerStatuses;
|
||||
try {
|
||||
containerStatuses = containerManager
|
||||
.getContainerStatuses(statRequest).getContainerStatuses();
|
||||
} catch (YarnException | IOException e) {
|
||||
return false;
|
||||
}
|
||||
Assert.assertEquals(1, containerStatuses.size());
|
||||
ContainerStatus status = containerStatuses.get(0);
|
||||
return (status.getState() == expectedState
|
||||
&& status.getExecutionType() == ExecutionType.OPPORTUNISTIC);
|
||||
}, 20, 10000);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue