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);