You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2022/03/07 00:17:46 UTC
[hbase] branch master updated: HBASE-26805 Addendum forward port the test improvements in HBASE-26304 for branch-2
This is an automated email from the ASF dual-hosted git repository.
zhangduo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/master by this push:
new 19ad3d6 HBASE-26805 Addendum forward port the test improvements in HBASE-26304 for branch-2
19ad3d6 is described below
commit 19ad3d66547fe7ebf68ca4cec23c6ccdccf692b9
Author: Duo Zhang <zh...@apache.org>
AuthorDate: Mon Mar 7 08:16:21 2022 +0800
HBASE-26805 Addendum forward port the test improvements in HBASE-26304 for branch-2
---
.../master/balancer/TestRegionHDFSBlockLocationFinder.java | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/hbase-balancer/src/test/java/org/apache/hadoop/hbase/master/balancer/TestRegionHDFSBlockLocationFinder.java b/hbase-balancer/src/test/java/org/apache/hadoop/hbase/master/balancer/TestRegionHDFSBlockLocationFinder.java
index b98dccf..807b5ff 100644
--- a/hbase-balancer/src/test/java/org/apache/hadoop/hbase/master/balancer/TestRegionHDFSBlockLocationFinder.java
+++ b/hbase-balancer/src/test/java/org/apache/hadoop/hbase/master/balancer/TestRegionHDFSBlockLocationFinder.java
@@ -231,9 +231,17 @@ public class TestRegionHDFSBlockLocationFinder {
finder.setClusterMetrics(getMetricsWithLocality(testServer, testRegion.getRegionName(),
0.345f));
- // there is no way to test whether the refresh for a guava cache is finished, so here we just
- // add a one second sleep, usually this is enough for the refresh
- Thread.sleep(1000);
+
+ // cache refresh happens in a background thread, so we need to wait for the value to
+ // update before running assertions.
+ long now = System.currentTimeMillis();
+ HDFSBlocksDistribution cached = cache.get(testRegion);
+ HDFSBlocksDistribution newValue;
+ do {
+ Thread.sleep(1_000);
+ newValue = finder.getBlockDistribution(testRegion);
+ } while (cached == newValue && System.currentTimeMillis() - now < 30_000);
+
// locality changed just for our test region, so it should no longer be the same
for (RegionInfo region : REGIONS) {
HDFSBlocksDistribution hbd = finder.getBlockDistribution(region);