YARN-1854. Fixed test failure in TestRMHA#testStartAndTransitions. Contributed by Rohith Sharma KS.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1580097 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a764e9a7a4
commit
dc594101cc
@ -549,6 +549,9 @@ Release 2.4.0 - UNRELEASED
|
||||
YARN-1863. Fixed test failure in TestRMFailover after YARN-1859. (Xuan Gong
|
||||
via vinodkv)
|
||||
|
||||
YARN-1854. Fixed test failure in TestRMHA#testStartAndTransitions. (Rohith
|
||||
Sharma KS via vinodkv)
|
||||
|
||||
Release 2.3.1 - UNRELEASED
|
||||
|
||||
INCOMPATIBLE CHANGES
|
||||
|
@ -32,6 +32,9 @@
|
||||
import org.apache.hadoop.yarn.event.Dispatcher;
|
||||
import org.apache.hadoop.yarn.event.EventHandler;
|
||||
import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
|
||||
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
|
||||
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt;
|
||||
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptState;
|
||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueMetrics;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@ -49,6 +52,8 @@ public class TestRMHA {
|
||||
private Log LOG = LogFactory.getLog(TestRMHA.class);
|
||||
private final Configuration configuration = new YarnConfiguration();
|
||||
private MockRM rm = null;
|
||||
private RMApp app = null;
|
||||
private RMAppAttempt attempt = null;
|
||||
private static final String STATE_ERR =
|
||||
"ResourceManager is in wrong HA state";
|
||||
|
||||
@ -103,7 +108,9 @@ private void checkActiveRMFunctionality() throws IOException {
|
||||
try {
|
||||
rm.getNewAppId();
|
||||
rm.registerNode("127.0.0.1:0", 2048);
|
||||
rm.submitApp(1024);
|
||||
app = rm.submitApp(1024);
|
||||
attempt = app.getCurrentAppAttempt();
|
||||
rm.waitForState(attempt.getAppAttemptId(), RMAppAttemptState.SCHEDULED);
|
||||
} catch (Exception e) {
|
||||
fail("Unable to perform Active RM functions");
|
||||
LOG.error("ActiveRM check failed", e);
|
||||
@ -122,7 +129,7 @@ private void checkActiveRMFunctionality() throws IOException {
|
||||
* become Active
|
||||
*/
|
||||
@Test (timeout = 30000)
|
||||
public void testStartAndTransitions() throws IOException {
|
||||
public void testStartAndTransitions() throws Exception {
|
||||
configuration.setBoolean(YarnConfiguration.AUTO_FAILOVER_ENABLED, false);
|
||||
Configuration conf = new YarnConfiguration(configuration);
|
||||
rm = new MockRM(conf);
|
||||
@ -377,19 +384,34 @@ public void testHAWithRMHostName() {
|
||||
|
||||
private void verifyClusterMetrics(int activeNodes, int appsSubmitted,
|
||||
int appsPending, int containersPending, int availableMB,
|
||||
int activeApplications) {
|
||||
int activeApplications) throws Exception {
|
||||
int timeoutSecs = 0;
|
||||
QueueMetrics metrics = rm.getResourceScheduler().getRootQueueMetrics();
|
||||
// verify queue metrics
|
||||
assertMetric("appsSubmitted", appsSubmitted, metrics.getAppsSubmitted());
|
||||
assertMetric("appsPending", appsPending, metrics.getAppsPending());
|
||||
assertMetric("containersPending", containersPending,
|
||||
metrics.getPendingContainers());
|
||||
assertMetric("availableMB", availableMB, metrics.getAvailableMB());
|
||||
assertMetric("activeApplications", activeApplications,
|
||||
metrics.getActiveApps());
|
||||
// verify node metric
|
||||
ClusterMetrics clusterMetrics = ClusterMetrics.getMetrics();
|
||||
assertMetric("activeNodes", activeNodes, clusterMetrics.getNumActiveNMs());
|
||||
boolean isAllMetricAssertionDone = false;
|
||||
String message = null;
|
||||
while (timeoutSecs++ < 5) {
|
||||
try {
|
||||
// verify queue metrics
|
||||
assertMetric("appsSubmitted", appsSubmitted, metrics.getAppsSubmitted());
|
||||
assertMetric("appsPending", appsPending, metrics.getAppsPending());
|
||||
assertMetric("containersPending", containersPending,
|
||||
metrics.getPendingContainers());
|
||||
assertMetric("availableMB", availableMB, metrics.getAvailableMB());
|
||||
assertMetric("activeApplications", activeApplications,
|
||||
metrics.getActiveApps());
|
||||
// verify node metric
|
||||
assertMetric("activeNodes", activeNodes,
|
||||
clusterMetrics.getNumActiveNMs());
|
||||
isAllMetricAssertionDone = true;
|
||||
break;
|
||||
} catch (AssertionError e) {
|
||||
message = e.getMessage();
|
||||
System.out.println("Waiting for metrics assertion to complete");
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
}
|
||||
assertTrue(message, isAllMetricAssertionDone);
|
||||
}
|
||||
|
||||
private void assertMetric(String metricName, int expected, int actual) {
|
||||
|
Loading…
Reference in New Issue
Block a user