|
@@ -17,6 +17,7 @@
|
|
|
*/
|
|
|
package org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt;
|
|
|
|
|
|
+import static org.apache.hadoop.yarn.util.StringHelper.pjoin;
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
import static org.junit.Assert.assertFalse;
|
|
|
import static org.junit.Assert.assertNotNull;
|
|
@@ -43,6 +44,7 @@ import org.apache.hadoop.yarn.api.records.ContainerState;
|
|
|
import org.apache.hadoop.yarn.api.records.ContainerStatus;
|
|
|
import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
|
|
|
import org.apache.hadoop.yarn.api.records.Resource;
|
|
|
+import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
|
|
import org.apache.hadoop.yarn.event.AsyncDispatcher;
|
|
|
import org.apache.hadoop.yarn.event.EventHandler;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.ApplicationMasterService;
|
|
@@ -85,6 +87,8 @@ public class TestRMAppAttemptTransitions {
|
|
|
LogFactory.getLog(TestRMAppAttemptTransitions.class);
|
|
|
|
|
|
private static final String EMPTY_DIAGNOSTICS = "";
|
|
|
+ private static final String RM_WEBAPP_ADDR =
|
|
|
+ YarnConfiguration.getRMWebAppHostAndPort(new Configuration());
|
|
|
|
|
|
private RMContext rmContext;
|
|
|
private YarnScheduler scheduler;
|
|
@@ -203,7 +207,7 @@ public class TestRMAppAttemptTransitions {
|
|
|
application = mock(RMApp.class);
|
|
|
applicationAttempt =
|
|
|
new RMAppAttemptImpl(applicationAttemptId, null, rmContext, scheduler,
|
|
|
- masterService, submissionContext, null);
|
|
|
+ masterService, submissionContext, new Configuration());
|
|
|
when(application.getCurrentAppAttempt()).thenReturn(applicationAttempt);
|
|
|
when(application.getApplicationId()).thenReturn(applicationId);
|
|
|
|
|
@@ -216,6 +220,11 @@ public class TestRMAppAttemptTransitions {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ private String getProxyUrl(RMAppAttempt appAttempt) {
|
|
|
+ return pjoin(RM_WEBAPP_ADDR, "proxy",
|
|
|
+ appAttempt.getAppAttemptId().getApplicationId(), "");
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* {@link RMAppAttemptState#NEW}
|
|
|
*/
|
|
@@ -373,8 +382,8 @@ public class TestRMAppAttemptTransitions {
|
|
|
assertEquals(host, applicationAttempt.getHost());
|
|
|
assertEquals(rpcPort, applicationAttempt.getRpcPort());
|
|
|
assertEquals(trackingUrl, applicationAttempt.getOriginalTrackingUrl());
|
|
|
- assertEquals("null/proxy/"+applicationAttempt.getAppAttemptId().
|
|
|
- getApplicationId()+"/", applicationAttempt.getTrackingUrl());
|
|
|
+ assertEquals(getProxyUrl(applicationAttempt),
|
|
|
+ applicationAttempt.getTrackingUrl());
|
|
|
|
|
|
// TODO - need to add more checks relevant to this state
|
|
|
}
|
|
@@ -390,8 +399,8 @@ public class TestRMAppAttemptTransitions {
|
|
|
applicationAttempt.getAppAttemptState());
|
|
|
assertEquals(diagnostics, applicationAttempt.getDiagnostics());
|
|
|
assertEquals(trackingUrl, applicationAttempt.getOriginalTrackingUrl());
|
|
|
- assertEquals("null/proxy/"+applicationAttempt.getAppAttemptId().
|
|
|
- getApplicationId()+"/", applicationAttempt.getTrackingUrl());
|
|
|
+ assertEquals(getProxyUrl(applicationAttempt),
|
|
|
+ applicationAttempt.getTrackingUrl());
|
|
|
assertEquals(container, applicationAttempt.getMasterContainer());
|
|
|
assertEquals(finalStatus, applicationAttempt.getFinalApplicationStatus());
|
|
|
}
|
|
@@ -408,8 +417,8 @@ public class TestRMAppAttemptTransitions {
|
|
|
applicationAttempt.getAppAttemptState());
|
|
|
assertEquals(diagnostics, applicationAttempt.getDiagnostics());
|
|
|
assertEquals(trackingUrl, applicationAttempt.getOriginalTrackingUrl());
|
|
|
- assertEquals("null/proxy/"+applicationAttempt.getAppAttemptId().
|
|
|
- getApplicationId()+"/", applicationAttempt.getTrackingUrl());
|
|
|
+ assertEquals(getProxyUrl(applicationAttempt),
|
|
|
+ applicationAttempt.getTrackingUrl());
|
|
|
assertEquals(finishedContainerCount, applicationAttempt
|
|
|
.getJustFinishedContainers().size());
|
|
|
assertEquals(container, applicationAttempt.getMasterContainer());
|
|
@@ -596,7 +605,30 @@ public class TestRMAppAttemptTransitions {
|
|
|
diagnostics));
|
|
|
testAppAttemptFailedState(amContainer, diagnostics);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testRunningToFailed() {
|
|
|
+ Container amContainer = allocateApplicationAttempt();
|
|
|
+ launchApplicationAttempt(amContainer);
|
|
|
+ runApplicationAttempt(amContainer, "host", 8042, "oldtrackingurl");
|
|
|
+ String containerDiagMsg = "some error";
|
|
|
+ int exitCode = 123;
|
|
|
+ ContainerStatus cs = BuilderUtils.newContainerStatus(amContainer.getId(),
|
|
|
+ ContainerState.COMPLETE, containerDiagMsg, exitCode);
|
|
|
+ ApplicationAttemptId appAttemptId = applicationAttempt.getAppAttemptId();
|
|
|
+ applicationAttempt.handle(new RMAppAttemptContainerFinishedEvent(
|
|
|
+ appAttemptId, cs));
|
|
|
+ assertEquals(RMAppAttemptState.FAILED,
|
|
|
+ applicationAttempt.getAppAttemptState());
|
|
|
+ assertEquals(0,applicationAttempt.getJustFinishedContainers().size());
|
|
|
+ assertEquals(amContainer, applicationAttempt.getMasterContainer());
|
|
|
+ assertEquals(0, applicationAttempt.getRanNodes().size());
|
|
|
+ String rmAppPageUrl = pjoin(RM_WEBAPP_ADDR, "cluster", "app",
|
|
|
+ applicationAttempt.getAppAttemptId().getApplicationId());
|
|
|
+ assertEquals(rmAppPageUrl, applicationAttempt.getOriginalTrackingUrl());
|
|
|
+ assertEquals(rmAppPageUrl, applicationAttempt.getTrackingUrl());
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
public void testUnregisterToKilledFinishing() {
|
|
|
Container amContainer = allocateApplicationAttempt();
|