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

wchevreuil 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 e082405d8e7 HBASE-28976 Fix UT flakeyness in 
TestBucketCache.testBlockAdditionWaitWhenCache and 
TestVerifyBucketCacheFile.testRetrieveFromFile (#6463)
e082405d8e7 is described below

commit e082405d8e7fa5c9b89e7af3153f022731168ecb
Author: Wellington Ramos Chevreuil <[email protected]>
AuthorDate: Fri Nov 15 10:58:39 2024 +0000

    HBASE-28976 Fix UT flakeyness in 
TestBucketCache.testBlockAdditionWaitWhenCache and 
TestVerifyBucketCacheFile.testRetrieveFromFile (#6463)
    
    Signed-off-by: Peter Somogyi <[email protected]>
---
 .../hadoop/hbase/io/hfile/bucket/BucketCache.java      |  3 +--
 .../hadoop/hbase/io/hfile/bucket/TestBucketCache.java  |  4 ++++
 .../io/hfile/bucket/TestVerifyBucketCacheFile.java     | 18 +++++++++++-------
 3 files changed, 16 insertions(+), 9 deletions(-)

diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java
 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java
index 5c65e42e5f8..8516ae0e2a0 100644
--- 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java
+++ 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java
@@ -288,8 +288,7 @@ public class BucketCache implements BlockCache, HeapSize {
     "hbase.bucketcache.persistent.file.integrity.check.algorithm";
   private static final String DEFAULT_FILE_VERIFY_ALGORITHM = "MD5";
 
-  private static final String QUEUE_ADDITION_WAIT_TIME =
-    "hbase.bucketcache.queue.addition.waittime";
+  public static final String QUEUE_ADDITION_WAIT_TIME = 
"hbase.bucketcache.queue.addition.waittime";
   private static final long DEFAULT_QUEUE_ADDITION_WAIT_TIME = 0;
   private long queueAdditionWaitTime;
   /**
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestBucketCache.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestBucketCache.java
index 3af648e6cf4..fc18d6373bd 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestBucketCache.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestBucketCache.java
@@ -21,6 +21,7 @@ import static 
org.apache.hadoop.hbase.io.hfile.bucket.BucketCache.ACCEPT_FACTOR_
 import static 
org.apache.hadoop.hbase.io.hfile.bucket.BucketCache.BLOCK_ORPHAN_GRACE_PERIOD;
 import static 
org.apache.hadoop.hbase.io.hfile.bucket.BucketCache.EXTRA_FREE_FACTOR_CONFIG_NAME;
 import static 
org.apache.hadoop.hbase.io.hfile.bucket.BucketCache.MIN_FACTOR_CONFIG_NAME;
+import static 
org.apache.hadoop.hbase.io.hfile.bucket.BucketCache.QUEUE_ADDITION_WAIT_TIME;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotEquals;
@@ -865,6 +866,9 @@ public class TestBucketCache {
       String ioEngineName = "file:" + dataTestDir + "/bucketNoRecycler.cache";
       String persistencePath = dataTestDir + "/bucketNoRecycler.persistence";
 
+      Configuration config = HBASE_TESTING_UTILITY.getConfiguration();
+      config.setLong(QUEUE_ADDITION_WAIT_TIME, 1000);
+
       bucketCache = new BucketCache(ioEngineName, capacitySize, 
constructedBlockSize,
         constructedBlockSizes, 1, 1, persistencePath);
       assertTrue(bucketCache.waitForCacheInitialization(10000));
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestVerifyBucketCacheFile.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestVerifyBucketCacheFile.java
index 4d4784167c6..a618965323d 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestVerifyBucketCacheFile.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestVerifyBucketCacheFile.java
@@ -39,6 +39,7 @@ import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hbase.HBaseClassTestRule;
 import org.apache.hadoop.hbase.HBaseConfiguration;
 import org.apache.hadoop.hbase.HBaseTestingUtil;
+import org.apache.hadoop.hbase.Waiter;
 import org.apache.hadoop.hbase.io.hfile.BlockCacheKey;
 import org.apache.hadoop.hbase.io.hfile.CacheConfig;
 import org.apache.hadoop.hbase.io.hfile.CacheTestUtils;
@@ -127,20 +128,23 @@ public class TestVerifyBucketCacheFile {
       FileSystems.getDefault().getPath(testDir.toString(), "bucket.cache");
     assertTrue(Files.deleteIfExists(cacheFile));
     // can't restore cache from file
-    bucketCache =
+    final BucketCache recoveredBucketCache =
       new BucketCache("file:" + testDir + "/bucket.cache", capacitySize, 
constructedBlockSize,
         constructedBlockSizes, writeThreads, writerQLen, testDir + 
"/bucket.persistence");
-    assertTrue(bucketCache.waitForCacheInitialization(10000));
-    assertEquals(0, bucketCache.getAllocator().getUsedSize());
-    assertEquals(0, bucketCache.backingMap.size());
+    assertTrue(recoveredBucketCache.waitForCacheInitialization(10000));
+    Waiter.waitFor(HBaseConfiguration.create(), 1000,
+      () -> recoveredBucketCache.getBackingMapValidated().get());
+    assertEquals(0, recoveredBucketCache.getAllocator().getUsedSize());
+    assertEquals(0, recoveredBucketCache.backingMap.size());
     // Add blocks
     for (CacheTestUtils.HFileBlockPair block : blocks) {
-      cacheAndWaitUntilFlushedToBucket(bucketCache, block.getBlockName(), 
block.getBlock());
+      cacheAndWaitUntilFlushedToBucket(recoveredBucketCache, 
block.getBlockName(),
+        block.getBlock());
     }
-    usedSize = bucketCache.getAllocator().getUsedSize();
+    usedSize = recoveredBucketCache.getAllocator().getUsedSize();
     assertNotEquals(0, usedSize);
     // persist cache to file
-    bucketCache.shutdown();
+    recoveredBucketCache.shutdown();
 
     // 3.delete backingMap persistence file
     final java.nio.file.Path mapFile =

Reply via email to