From 480db06e46792f8e28e9fcc66be478bbaf901e01 Mon Sep 17 00:00:00 2001 From: Duo Zhang Date: Mon, 7 Mar 2022 08:08:04 +0800 Subject: [PATCH] HBASE-26805 TestRegionHDFSBlockLocationFinder is flaky (#4169) Signed-off-by: GeorryHuang --- .../hbase/master/balancer/TestRegionHDFSBlockLocationFinder.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 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 a011793c0c..b98dccf062 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 @@ -209,7 +209,7 @@ public class TestRegionHDFSBlockLocationFinder { } @Test - public void testRefreshRegionsWithChangedLocality() { + public void testRefreshRegionsWithChangedLocality() throws InterruptedException { ServerName testServer = ServerName.valueOf("host-0", 12345, 12345); RegionInfo testRegion = REGIONS.get(0); @@ -231,7 +231,9 @@ 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); // locality changed just for our test region, so it should no longer be the same for (RegionInfo region : REGIONS) { HDFSBlocksDistribution hbd = finder.getBlockDistribution(region); -- 2.11.4.GIT