You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2020/02/15 22:38:49 UTC

[hbase] branch branch-2 updated: HBASE-23853 [Flakey Test] TestBlockEvictionFromClient#testBlockRefCountAfterSplits

This is an automated email from the ASF dual-hosted git repository.

stack pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2 by this push:
     new 5a3e04a  HBASE-23853 [Flakey Test] TestBlockEvictionFromClient#testBlockRefCountAfterSplits
5a3e04a is described below

commit 5a3e04a9a2e20715e9dccd12f4bc221aa8162ad4
Author: stack <st...@apache.org>
AuthorDate: Sat Feb 15 14:37:45 2020 -0800

    HBASE-23853 [Flakey Test] TestBlockEvictionFromClient#testBlockRefCountAfterSplits
---
 .../hbase/client/TestBlockEvictionFromClient.java    | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestBlockEvictionFromClient.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestBlockEvictionFromClient.java
index 3a740b3..6696df7 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestBlockEvictionFromClient.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestBlockEvictionFromClient.java
@@ -58,6 +58,7 @@ import org.apache.hadoop.hbase.regionserver.ScannerContext;
 import org.apache.hadoop.hbase.testclassification.ClientTests;
 import org.apache.hadoop.hbase.testclassification.LargeTests;
 import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.Threads;
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Before;
@@ -569,10 +570,9 @@ public class TestBlockEvictionFromClient {
 
   @Test
   public void testBlockRefCountAfterSplits() throws IOException, InterruptedException {
-    Table table = null;
-    try {
-      final TableName tableName = TableName.valueOf(name.getMethodName());
-      table = TEST_UTIL.createTable(tableName, FAMILIES_1, 1, 1024);
+    final TableName tableName = TableName.valueOf(name.getMethodName());
+    try (Table table =
+        TEST_UTIL.createTable(tableName, FAMILIES_1, 1, 1024)) {
       // get the block cache and region
       RegionLocator locator = TEST_UTIL.getConnection().getRegionLocator(tableName);
       String regionName = locator.getAllRegionLocations().get(0).getRegion().getEncodedName();
@@ -604,16 +604,18 @@ public class TestBlockEvictionFromClient {
       LOG.info("About to SPLIT on " + Bytes.toString(ROW1));
       TEST_UTIL.getAdmin().split(tableName, ROW1);
       // Wait for splits
-      TEST_UTIL.waitFor(60000, () -> TEST_UTIL.getAdmin().getRegions(rs).size() > regionCount);
+      TEST_UTIL.waitFor(60000,
+        () -> TEST_UTIL.getAdmin().getRegions(rs).size() > regionCount);
+      LOG.info("Split finished");
+      while (region.getCompactionState().compareTo(CompactionState.NONE) != 0) {
+        Threads.sleep(10);
+      }
       region.compact(true);
+      LOG.info("Compaction finished");
       Iterator<CachedBlock> iterator = cache.iterator();
       // Though the split had created the HalfStorefileReader - the firstkey and lastkey scanners
       // should be closed inorder to return those blocks
       iterateBlockCache(cache, iterator);
-    } finally {
-      if (table != null) {
-        table.close();
-      }
     }
   }