You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by in...@apache.org on 2018/01/19 17:47:47 UTC
hadoop git commit: HDFS-13028. RBF: Fix spurious
TestRouterRpc#testProxyGetStats. Contributed by Inigo Goiri.
Repository: hadoop
Updated Branches:
refs/heads/trunk d689b2d99 -> 130f8bce0
HDFS-13028. RBF: Fix spurious TestRouterRpc#testProxyGetStats. Contributed by Inigo Goiri.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/130f8bce
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/130f8bce
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/130f8bce
Branch: refs/heads/trunk
Commit: 130f8bce00e8cab59c3aa4d668e8bddd84544713
Parents: d689b2d
Author: Inigo Goiri <in...@apache.org>
Authored: Fri Jan 19 09:47:40 2018 -0800
Committer: Inigo Goiri <in...@apache.org>
Committed: Fri Jan 19 09:47:40 2018 -0800
----------------------------------------------------------------------
.../server/federation/router/TestRouterRpc.java | 46 ++++++++++++++------
1 file changed, 33 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/130f8bce/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterRpc.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterRpc.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterRpc.java
index 6a8c0e1..2b12a25 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterRpc.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterRpc.java
@@ -82,6 +82,7 @@ import org.apache.hadoop.io.erasurecode.ECSchema;
import org.apache.hadoop.io.erasurecode.ErasureCodeConstants;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.service.Service.STATE;
+import org.apache.hadoop.test.GenericTestUtils;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -89,6 +90,7 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.common.base.Supplier;
import com.google.common.collect.Maps;
/**
@@ -501,9 +503,37 @@ public class TestRouterRpc {
@Test
public void testProxyGetStats() throws Exception {
+ // Some of the statistics are out of sync because of the mini cluster
+ Supplier<Boolean> check = new Supplier<Boolean>() {
+ @Override
+ public Boolean get() {
+ try {
+ long[] combinedData = routerProtocol.getStats();
+ long[] individualData = getAggregateStats();
+ int len = Math.min(combinedData.length, individualData.length);
+ for (int i = 0; i < len; i++) {
+ if (combinedData[i] != individualData[i]) {
+ LOG.error("Stats for {} don't match: {} != {}",
+ i, combinedData[i], individualData[i]);
+ return false;
+ }
+ }
+ return true;
+ } catch (Exception e) {
+ LOG.error("Cannot get stats: {}", e.getMessage());
+ return false;
+ }
+ }
+ };
+ GenericTestUtils.waitFor(check, 500, 5 * 1000);
+ }
- long[] combinedData = routerProtocol.getStats();
-
+ /**
+ * Get the sum of each subcluster statistics.
+ * @return Aggregated statistics.
+ * @throws Exception If it cannot get the stats from the Router or Namenode.
+ */
+ private long[] getAggregateStats() throws Exception {
long[] individualData = new long[10];
for (String nameservice : cluster.getNameservices()) {
NamenodeContext n = cluster.getNamenode(nameservice, null);
@@ -513,18 +543,8 @@ public class TestRouterRpc {
for (int i = 0; i < data.length; i++) {
individualData[i] += data[i];
}
- assertEquals(data.length, combinedData.length);
- }
-
- for (int i = 0; i < combinedData.length && i < individualData.length; i++) {
- if (i == ClientProtocol.GET_STATS_REMAINING_IDX) {
- // Skip available storage as this fluctuates in mini cluster
- continue;
- }
- assertEquals("Stats for " + i + " don't match: " +
- combinedData[i] + "!=" + individualData[i],
- combinedData[i], individualData[i]);
}
+ return individualData;
}
@Test
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org