|
@@ -83,6 +83,7 @@ import org.apache.hadoop.yarn.api.records.ContainerState;
|
|
|
import org.apache.hadoop.yarn.api.records.ContainerStatus;
|
|
|
import org.apache.hadoop.yarn.api.records.Resource;
|
|
|
import org.apache.hadoop.yarn.api.records.ResourceRequest;
|
|
|
+import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
|
|
import org.apache.hadoop.yarn.event.Dispatcher;
|
|
|
import org.apache.hadoop.yarn.event.DrainDispatcher;
|
|
|
import org.apache.hadoop.yarn.event.Event;
|
|
@@ -1645,6 +1646,32 @@ public class TestRMContainerAllocator {
|
|
|
Assert.assertTrue(callbackCalled.get());
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ public void testCompletedContainerEvent() {
|
|
|
+ RMContainerAllocator allocator = new RMContainerAllocator(
|
|
|
+ mock(ClientService.class), mock(AppContext.class));
|
|
|
+
|
|
|
+ TaskAttemptId attemptId = MRBuilderUtils.newTaskAttemptId(
|
|
|
+ MRBuilderUtils.newTaskId(
|
|
|
+ MRBuilderUtils.newJobId(1, 1, 1), 1, TaskType.MAP), 1);
|
|
|
+ ContainerId containerId = BuilderUtils.newContainerId(1, 1, 1, 1);
|
|
|
+ ContainerStatus status = BuilderUtils.newContainerStatus(
|
|
|
+ containerId, ContainerState.RUNNING, "", 0);
|
|
|
+
|
|
|
+ ContainerStatus abortedStatus = BuilderUtils.newContainerStatus(
|
|
|
+ containerId, ContainerState.RUNNING, "",
|
|
|
+ YarnConfiguration.ABORTED_CONTAINER_EXIT_STATUS);
|
|
|
+
|
|
|
+ TaskAttemptEvent event = allocator.createContainerFinishedEvent(status,
|
|
|
+ attemptId);
|
|
|
+ Assert.assertEquals(TaskAttemptEventType.TA_CONTAINER_COMPLETED,
|
|
|
+ event.getType());
|
|
|
+
|
|
|
+ TaskAttemptEvent abortedEvent = allocator.createContainerFinishedEvent(
|
|
|
+ abortedStatus, attemptId);
|
|
|
+ Assert.assertEquals(TaskAttemptEventType.TA_KILL, abortedEvent.getType());
|
|
|
+ }
|
|
|
+
|
|
|
public static void main(String[] args) throws Exception {
|
|
|
TestRMContainerAllocator t = new TestRMContainerAllocator();
|
|
|
t.testSimple();
|