From 446313734ef8c02d09a256730c716264f83fde10 Mon Sep 17 00:00:00 2001 From: Duo Zhang Date: Sun, 6 Mar 2022 20:47:08 +0800 Subject: [PATCH] HBASE-26805 TestRegionHDFSBlockLocationFinder is flaky --- .../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 a011793c0cb4..b98dccf062ec 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 void testGetTopBlockLocations() { } @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 void testRefreshRegionsWithChangedLocality() { 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);