YARN-7341. TestRouterWebServiceUtil#testMergeMetrics is flakey. (Robert Kanter via Haibo Chen)
(cherry picked from commit acabc657ff
)
This commit is contained in:
parent
cdfcd384b2
commit
5334deb089
|
@ -406,22 +406,26 @@ public final class RouterWebServiceUtil {
|
||||||
metrics.setContainersPending(metrics.getPendingContainers()
|
metrics.setContainersPending(metrics.getPendingContainers()
|
||||||
+ metricsResponse.getPendingContainers());
|
+ metricsResponse.getPendingContainers());
|
||||||
|
|
||||||
metrics.setTotalMB(metrics.getTotalMB() + metricsResponse.getTotalMB());
|
metrics.setTotalMB(metrics.getTotalMB()
|
||||||
metrics.setTotalVirtualCores(
|
+ metricsResponse.getTotalMB());
|
||||||
metrics.getTotalVirtualCores() + metrics.getTotalVirtualCores());
|
metrics.setTotalVirtualCores(metrics.getTotalVirtualCores()
|
||||||
metrics.setTotalNodes(metrics.getTotalNodes() + metrics.getTotalNodes());
|
+ metricsResponse.getTotalVirtualCores());
|
||||||
metrics.setLostNodes(metrics.getLostNodes() + metrics.getLostNodes());
|
metrics.setTotalNodes(metrics.getTotalNodes()
|
||||||
metrics.setUnhealthyNodes(
|
+ metricsResponse.getTotalNodes());
|
||||||
metrics.getUnhealthyNodes() + metrics.getUnhealthyNodes());
|
metrics.setLostNodes(metrics.getLostNodes()
|
||||||
metrics.setDecommissioningNodes(
|
+ metricsResponse.getLostNodes());
|
||||||
metrics.getDecommissioningNodes() + metrics.getDecommissioningNodes());
|
metrics.setUnhealthyNodes(metrics.getUnhealthyNodes()
|
||||||
metrics.setDecommissionedNodes(
|
+ metricsResponse.getUnhealthyNodes());
|
||||||
metrics.getDecommissionedNodes() + metrics.getDecommissionedNodes());
|
metrics.setDecommissioningNodes(metrics.getDecommissioningNodes()
|
||||||
metrics.setRebootedNodes(
|
+ metricsResponse.getDecommissioningNodes());
|
||||||
metrics.getRebootedNodes() + metrics.getRebootedNodes());
|
metrics.setDecommissionedNodes(metrics.getDecommissionedNodes()
|
||||||
metrics.setActiveNodes(metrics.getActiveNodes() + metrics.getActiveNodes());
|
+ metricsResponse.getDecommissionedNodes());
|
||||||
metrics.setShutdownNodes(
|
metrics.setRebootedNodes(metrics.getRebootedNodes()
|
||||||
metrics.getShutdownNodes() + metrics.getShutdownNodes());
|
+ metricsResponse.getRebootedNodes());
|
||||||
|
metrics.setActiveNodes(metrics.getActiveNodes()
|
||||||
|
+ metricsResponse.getActiveNodes());
|
||||||
|
metrics.setShutdownNodes(metrics.getShutdownNodes()
|
||||||
|
+ metricsResponse.getShutdownNodes());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,11 +33,15 @@ import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ResourceRequestI
|
||||||
import org.apache.hadoop.yarn.server.uam.UnmanagedApplicationManager;
|
import org.apache.hadoop.yarn.server.uam.UnmanagedApplicationManager;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class to validate RouterWebServiceUtil methods.
|
* Test class to validate RouterWebServiceUtil methods.
|
||||||
*/
|
*/
|
||||||
public class TestRouterWebServiceUtil {
|
public class TestRouterWebServiceUtil {
|
||||||
|
private static final Logger LOG =
|
||||||
|
LoggerFactory.getLogger(TestRouterWebServiceUtil.class);
|
||||||
|
|
||||||
private static final ApplicationId APPID1 = ApplicationId.newInstance(1, 1);
|
private static final ApplicationId APPID1 = ApplicationId.newInstance(1, 1);
|
||||||
private static final ApplicationId APPID2 = ApplicationId.newInstance(2, 1);
|
private static final ApplicationId APPID2 = ApplicationId.newInstance(2, 1);
|
||||||
|
@ -407,8 +411,12 @@ public class TestRouterWebServiceUtil {
|
||||||
ClusterMetricsInfo metrics = new ClusterMetricsInfo();
|
ClusterMetricsInfo metrics = new ClusterMetricsInfo();
|
||||||
ClusterMetricsInfo metricsResponse = new ClusterMetricsInfo();
|
ClusterMetricsInfo metricsResponse = new ClusterMetricsInfo();
|
||||||
|
|
||||||
setUpClusterMetrics(metrics);
|
long seed = System.currentTimeMillis();
|
||||||
setUpClusterMetrics(metricsResponse);
|
setUpClusterMetrics(metrics, seed);
|
||||||
|
// ensure that we don't reuse the same seed when setting up metricsResponse
|
||||||
|
// or it might mask bugs
|
||||||
|
seed += 1000000000;
|
||||||
|
setUpClusterMetrics(metricsResponse, seed);
|
||||||
ClusterMetricsInfo metricsClone = createClusterMetricsClone(metrics);
|
ClusterMetricsInfo metricsClone = createClusterMetricsClone(metrics);
|
||||||
RouterWebServiceUtil.mergeMetrics(metrics, metricsResponse);
|
RouterWebServiceUtil.mergeMetrics(metrics, metricsResponse);
|
||||||
|
|
||||||
|
@ -538,8 +546,9 @@ public class TestRouterWebServiceUtil {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpClusterMetrics(ClusterMetricsInfo metrics) {
|
private void setUpClusterMetrics(ClusterMetricsInfo metrics, long seed) {
|
||||||
Random rand = new Random(System.currentTimeMillis());
|
LOG.info("Using seed: " + seed);
|
||||||
|
Random rand = new Random(seed);
|
||||||
metrics.setAppsSubmitted(rand.nextInt(1000));
|
metrics.setAppsSubmitted(rand.nextInt(1000));
|
||||||
metrics.setAppsCompleted(rand.nextInt(1000));
|
metrics.setAppsCompleted(rand.nextInt(1000));
|
||||||
metrics.setAppsPending(rand.nextInt(1000));
|
metrics.setAppsPending(rand.nextInt(1000));
|
||||||
|
|
Loading…
Reference in New Issue