@@ -140,10 +140,10 @@ public void testRetrieveFromFile() throws Exception {
140140 FileSystems .getDefault ().getPath (testDir .toString (), "bucket.cache" );
141141 assertTrue (Files .deleteIfExists (cacheFile ));
142142 // can't restore cache from file
143- recoveredBucketCache = new BucketCache ( "file:" + testDir + "/bucket.cache" , capacitySize ,
144- constructedBlockSize , constructedBlockSizes , writeThreads , writerQLen ,
145- testDir + "/bucket.persistence" + name . getMethodName () );
146- assertTrue ( recoveredBucketCache . waitForCacheInitialization ( 10000 ) );
143+ recoveredBucketCache =
144+ new BucketCache ( "file:" + testDir + "/bucket.cache" , capacitySize , constructedBlockSize ,
145+ constructedBlockSizes , writeThreads , writerQLen , testDir + "/bucket.persistence" );
146+ waitPersistentCacheValidation ( conf , bucketCache );
147147 assertEquals (0 , recoveredBucketCache .getAllocator ().getUsedSize ());
148148 assertEquals (0 , recoveredBucketCache .backingMap .size ());
149149 BlockCacheKey [] newKeys = CacheTestUtils .regenerateKeys (blocks , names );
@@ -512,6 +512,7 @@ private void cacheAndWaitUntilFlushedToBucket(BucketCache cache, BlockCacheKey c
512512 }
513513
514514 private void waitPersistentCacheValidation (Configuration config , final BucketCache bucketCache ) {
515- Waiter .waitFor (config , 5000 , () -> bucketCache .getBackingMapValidated ().get ());
515+ Waiter .waitFor (config , 5000 ,
516+ () -> bucketCache .getBackingMapValidated ().get () && bucketCache .isCacheEnabled ());
516517 }
517518}
0 commit comments