hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From haiboc...@apache.org
Subject hadoop git commit: YARN-7341. TestRouterWebServiceUtil#testMergeMetrics is flakey. (Robert Kanter via Haibo Chen)
Date Tue, 17 Oct 2017 17:28:47 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-3.0 cdfcd384b -> 5334deb08


YARN-7341. TestRouterWebServiceUtil#testMergeMetrics is flakey. (Robert Kanter via Haibo Chen)

(cherry picked from commit acabc657ff5433f36ce1b238cecd3a3b5bbe87ae)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/5334deb0
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/5334deb0
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/5334deb0

Branch: refs/heads/branch-3.0
Commit: 5334deb08906fe050baa1885aa2d8ab8751eb630
Parents: cdfcd38
Author: Haibo Chen <haibochen@apache.org>
Authored: Tue Oct 17 10:15:53 2017 -0700
Committer: Haibo Chen <haibochen@apache.org>
Committed: Tue Oct 17 10:26:02 2017 -0700

----------------------------------------------------------------------
 .../router/webapp/RouterWebServiceUtil.java     | 36 +++++++++++---------
 .../router/webapp/TestRouterWebServiceUtil.java | 17 ++++++---
 2 files changed, 33 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/5334deb0/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/RouterWebServiceUtil.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/RouterWebServiceUtil.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/RouterWebServiceUtil.java
index 5528e78..76435f0 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/RouterWebServiceUtil.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/RouterWebServiceUtil.java
@@ -406,22 +406,26 @@ public final class RouterWebServiceUtil {
     metrics.setContainersPending(metrics.getPendingContainers()
         + metricsResponse.getPendingContainers());
 
-    metrics.setTotalMB(metrics.getTotalMB() + metricsResponse.getTotalMB());
-    metrics.setTotalVirtualCores(
-        metrics.getTotalVirtualCores() + metrics.getTotalVirtualCores());
-    metrics.setTotalNodes(metrics.getTotalNodes() + metrics.getTotalNodes());
-    metrics.setLostNodes(metrics.getLostNodes() + metrics.getLostNodes());
-    metrics.setUnhealthyNodes(
-        metrics.getUnhealthyNodes() + metrics.getUnhealthyNodes());
-    metrics.setDecommissioningNodes(
-        metrics.getDecommissioningNodes() + metrics.getDecommissioningNodes());
-    metrics.setDecommissionedNodes(
-        metrics.getDecommissionedNodes() + metrics.getDecommissionedNodes());
-    metrics.setRebootedNodes(
-        metrics.getRebootedNodes() + metrics.getRebootedNodes());
-    metrics.setActiveNodes(metrics.getActiveNodes() + metrics.getActiveNodes());
-    metrics.setShutdownNodes(
-        metrics.getShutdownNodes() + metrics.getShutdownNodes());
+    metrics.setTotalMB(metrics.getTotalMB()
+        + metricsResponse.getTotalMB());
+    metrics.setTotalVirtualCores(metrics.getTotalVirtualCores()
+        + metricsResponse.getTotalVirtualCores());
+    metrics.setTotalNodes(metrics.getTotalNodes()
+        + metricsResponse.getTotalNodes());
+    metrics.setLostNodes(metrics.getLostNodes()
+        + metricsResponse.getLostNodes());
+    metrics.setUnhealthyNodes(metrics.getUnhealthyNodes()
+        + metricsResponse.getUnhealthyNodes());
+    metrics.setDecommissioningNodes(metrics.getDecommissioningNodes()
+        + metricsResponse.getDecommissioningNodes());
+    metrics.setDecommissionedNodes(metrics.getDecommissionedNodes()
+        + metricsResponse.getDecommissionedNodes());
+    metrics.setRebootedNodes(metrics.getRebootedNodes()
+        + metricsResponse.getRebootedNodes());
+    metrics.setActiveNodes(metrics.getActiveNodes()
+        + metricsResponse.getActiveNodes());
+    metrics.setShutdownNodes(metrics.getShutdownNodes()
+        + metricsResponse.getShutdownNodes());
   }
 
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/5334deb0/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/TestRouterWebServiceUtil.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/TestRouterWebServiceUtil.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/TestRouterWebServiceUtil.java
index 7073b3b..edf3804 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/TestRouterWebServiceUtil.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/TestRouterWebServiceUtil.java
@@ -33,11 +33,15 @@ import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ResourceRequestI
 import org.apache.hadoop.yarn.server.uam.UnmanagedApplicationManager;
 import org.junit.Assert;
 import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Test class to validate RouterWebServiceUtil methods.
  */
 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 APPID2 = ApplicationId.newInstance(2, 1);
@@ -407,8 +411,12 @@ public class TestRouterWebServiceUtil {
     ClusterMetricsInfo metrics = new ClusterMetricsInfo();
     ClusterMetricsInfo metricsResponse = new ClusterMetricsInfo();
 
-    setUpClusterMetrics(metrics);
-    setUpClusterMetrics(metricsResponse);
+    long seed = System.currentTimeMillis();
+    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);
     RouterWebServiceUtil.mergeMetrics(metrics, metricsResponse);
 
@@ -538,8 +546,9 @@ public class TestRouterWebServiceUtil {
 
   }
 
-  private void setUpClusterMetrics(ClusterMetricsInfo metrics) {
-    Random rand = new Random(System.currentTimeMillis());
+  private void setUpClusterMetrics(ClusterMetricsInfo metrics, long seed) {
+    LOG.info("Using seed: " + seed);
+    Random rand = new Random(seed);
     metrics.setAppsSubmitted(rand.nextInt(1000));
     metrics.setAppsCompleted(rand.nextInt(1000));
     metrics.setAppsPending(rand.nextInt(1000));


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message