You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by am...@apache.org on 2016/12/14 04:10:47 UTC

svn commit: r1774122 - in /jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/blob: AbstractDataStoreCacheTest.java CompositeDataStoreCacheTest.java FileCacheTest.java

Author: amitj
Date: Wed Dec 14 04:10:47 2016
New Revision: 1774122

URL: http://svn.apache.org/viewvc?rev=1774122&view=rev
Log:
OAK-5285: Test failures in org.apache.jackrabbit.oak.plugins.blob

Better diagnostics & some fixes

Modified:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/blob/AbstractDataStoreCacheTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/blob/CompositeDataStoreCacheTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/blob/FileCacheTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/blob/AbstractDataStoreCacheTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/blob/AbstractDataStoreCacheTest.java?rev=1774122&r1=1774121&r2=1774122&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/blob/AbstractDataStoreCacheTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/blob/AbstractDataStoreCacheTest.java Wed Dec 14 04:10:47 2016
@@ -144,7 +144,7 @@ public class AbstractDataStoreCacheTest
             try {
                 LOG.trace("After execution....counting down latch");
                 afterLatch.countDown();
-                LOG.trace("After execution....after counting down latch");
+                LOG.info("After execution....after counting down latch");
                 super.afterExecute(r, t);
                 LOG.trace("Completed afterExecute");
             } catch (Exception e) {

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/blob/CompositeDataStoreCacheTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/blob/CompositeDataStoreCacheTest.java?rev=1774122&r1=1774121&r2=1774122&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/blob/CompositeDataStoreCacheTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/blob/CompositeDataStoreCacheTest.java Wed Dec 14 04:10:47 2016
@@ -29,6 +29,8 @@ import java.util.concurrent.TimeUnit;
 
 import com.google.common.io.Closer;
 import com.google.common.io.Files;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.ListeningExecutorService;
 import com.google.common.util.concurrent.MoreExecutors;
 import com.google.common.util.concurrent.SettableFuture;
@@ -78,7 +80,9 @@ public class CompositeDataStoreCacheTest
     private ScheduledExecutorService scheduledExecutor;
 
     @Before
-    public void setup() throws IOException {
+    public void setup() throws Exception {
+        LOG.info("Starting setup");
+
         root = folder.newFolder();
         loader = new TestCacheLoader<String, InputStream>(folder.newFolder());
         uploader = new TestStagingUploader(folder.newFolder());
@@ -102,7 +106,11 @@ public class CompositeDataStoreCacheTest
             new CompositeDataStoreCache(root.getAbsolutePath(), null, 80 * 1024 /* bytes */, 10,
                 1/*threads*/,
                 loader, uploader, statsProvider, executor, scheduledExecutor, 3000, 6000);
+        Futures.successfulAsList((Iterable<? extends ListenableFuture<?>>) executor.futures).get();
+
         closer.register(cache);
+
+        LOG.info("Finished setup");
     }
 
     @After
@@ -112,6 +120,8 @@ public class CompositeDataStoreCacheTest
 
     @Test
     public void zeroCache() throws IOException {
+        LOG.info("Starting zeroCache");
+
         cache = new CompositeDataStoreCache(root.getAbsolutePath(), null, 0 /* bytes
         */, 10, 1/*threads*/, loader,
             uploader, statsProvider, executor, scheduledExecutor, 3000, 6000);
@@ -129,6 +139,8 @@ public class CompositeDataStoreCacheTest
         assertEquals(0,cache.getCacheStats().getMaxTotalWeight());
         cache.invalidate(ID_PREFIX + 0);
         cache.close();
+
+        LOG.info("Finished zeroCache");
     }
 
     /**
@@ -136,9 +148,13 @@ public class CompositeDataStoreCacheTest
      */
     @Test
     public void getIfPresentNoCache() {
+        LOG.info("Starting getIfPresentNoCache");
+
         File file = cache.getIfPresent(ID_PREFIX + 0);
         assertNull(file);
         assertCacheStats(cache.getStagingCacheStats(), 0, 0, 0, 0);
+
+        LOG.info("Finished getIfPresentNoCache");
     }
 
     /**
@@ -147,8 +163,12 @@ public class CompositeDataStoreCacheTest
      */
     @Test
     public void getNoCache() throws IOException {
+        LOG.info("Starting getNoCache");
+
         expectedEx.expect(IOException.class);
         cache.get(ID_PREFIX + 0);
+
+        LOG.info("Finished getNoCache");
     }
 
     /**
@@ -156,10 +176,14 @@ public class CompositeDataStoreCacheTest
      */
     @Test
     public void getIfPresentObjectNoCache() {
+        LOG.info("Starting getIfPresentObjectNoCache");
+
         File file = cache.getIfPresent((Object) (ID_PREFIX + 0));
         assertNull(file);
         assertCacheStats(cache.getStagingCacheStats(), 0, 0, 0, 0);
         assertCacheStats(cache.getDownloadCache().getStats(), 0, 0, 0, 0);
+
+        LOG.info("Finished getIfPresentObjectNoCache");
     }
 
     /**
@@ -167,6 +191,8 @@ public class CompositeDataStoreCacheTest
      */
     @Test
     public void add() throws Exception {
+        LOG.info("Starting add");
+
         File f = copyToFile(randomStream(0, 4 * 1024), folder.newFile());
         boolean accepted = cache.stage(ID_PREFIX + 0, f);
         assertTrue(accepted);
@@ -181,6 +207,8 @@ public class CompositeDataStoreCacheTest
         assertNotNull(f);
         assertFile(file, 0, folder);
         assertCacheStats(cache.getStagingCacheStats(), 0, 0, 1, 1);
+
+        LOG.info("Finished add");
     }
 
     /**
@@ -188,6 +216,8 @@ public class CompositeDataStoreCacheTest
      */
     @Test
     public void addCacheFull() throws IOException {
+        LOG.info("Starting addCacheFull");
+
         cache = new CompositeDataStoreCache(root.getAbsolutePath(), null, 40 * 1024 /*
         bytes */, 10 /* staging % */,
             1/*threads*/, loader, uploader, statsProvider, executor, scheduledExecutor, 3000,
@@ -212,6 +242,8 @@ public class CompositeDataStoreCacheTest
         assertNotNull(f);
         assertFile(file, 0, folder);
         assertCacheStats(cache.getStagingCacheStats(), 0, 0, 1, 2);
+
+        LOG.info("Finished addCacheFull");
     }
 
     /**
@@ -219,6 +251,8 @@ public class CompositeDataStoreCacheTest
      */
     @Test
     public void invalidateStaging() throws IOException {
+        LOG.info("Starting invalidateStaging");
+
         // create executor
         taskLatch = new CountDownLatch(2);
         callbackLatch = new CountDownLatch(2);
@@ -254,26 +288,36 @@ public class CompositeDataStoreCacheTest
         file = cache.getIfPresent(ID_PREFIX + 1);
         assertFile(file, 1, folder);
         assertCacheStats(cache.getStagingCacheStats(), 0, 0, 2, 2);
+
+        LOG.info("Finished invalidateStaging");
     }
 
     /**
      * Test {@link CompositeDataStoreCache#getIfPresent(String)} when file staged
-     * and then download cache when uploaded.
+     * and then put in download cache when uploaded.
      * @throws IOException
      */
     @Test
     public void getIfPresentStaged() throws IOException {
+        LOG.info("Starting getIfPresentStaged");
+
         get(false);
+
+        LOG.info("Finished getIfPresentStaged");
     }
 
     /**
-     * Test {@link CompositeDataStoreCache#get(String)} when file staged and then
+     * Test {@link CompositeDataStoreCache#get(String)} when file staged and then put in
      * download cache when uploaded.
      * @throws IOException
      */
     @Test
     public void getStaged() throws IOException {
+        LOG.info("Starting getStaged");
+
         get(true);
+
+        LOG.info("Finished getStaged");
     }
 
     private void get(boolean get) throws IOException {
@@ -298,13 +342,15 @@ public class CompositeDataStoreCacheTest
 
         waitFinish();
 
-        // Not should hit the download cache
+        // Now should hit the download cache
         if (get) {
             file = cache.get(ID_PREFIX + 0);
         } else {
             file = cache.getIfPresent(ID_PREFIX + 0);
         }
-        assertNotNull(f);
+        LOG.info("File loaded from cache [{}]", file);
+
+        assertNotNull(file);
         assertFile(file, 0, folder);
         assertCacheStats(cache.getStagingCacheStats(), 0, 0, 1, 1);
         assertCacheStats(cache.getCacheStats(), 1, 4 * 1024, 1, 1);
@@ -316,6 +362,8 @@ public class CompositeDataStoreCacheTest
      */
     @Test
     public void getLoad() throws Exception {
+        LOG.info("Starting getLoad");
+
         File f = copyToFile(randomStream(0, 4 * 1024), folder.newFile());
         loader.write(ID_PREFIX + 0, f);
 
@@ -335,6 +383,8 @@ public class CompositeDataStoreCacheTest
         assertCacheStats(cache.getCacheStats(), 1, 4 * 1024, 0, 2);
         assertEquals(1, cache.getCacheStats().getLoadCount());
         assertEquals(1, cache.getCacheStats().getLoadSuccessCount());
+
+        LOG.info("Finished getLoad");
     }
 
     /**
@@ -343,6 +393,8 @@ public class CompositeDataStoreCacheTest
      */
     @Test
     public void invalidate() throws Exception {
+        LOG.info("Starting invalidate");
+
         File f = copyToFile(randomStream(0, 4 * 1024), folder.newFile());
         loader.write(ID_PREFIX + 0, f);
 
@@ -367,6 +419,8 @@ public class CompositeDataStoreCacheTest
 
         /** Check eviction count */
         assertEquals(0, cache.getCacheStats().getEvictionCount());
+
+        LOG.info("Finished invalidate");
     }
 
     /**
@@ -375,6 +429,8 @@ public class CompositeDataStoreCacheTest
      */
     @Test
     public void concurrentGetCached() throws Exception {
+        LOG.info("Starting concurrentGetCached");
+
         // Add 2 files to backend
         // Concurrently get both
         ListeningExecutorService executorService =
@@ -414,6 +470,8 @@ public class CompositeDataStoreCacheTest
         assertCacheStats(cache.getCacheStats(), 2, 8 * 1024, 0, 4);
         assertEquals(2, cache.getCacheStats().getLoadCount());
         assertEquals(2, cache.getCacheStats().getLoadSuccessCount());
+
+        LOG.info("Finished concurrentGetCached");
     }
 
     /**
@@ -423,6 +481,8 @@ public class CompositeDataStoreCacheTest
      */
     @Test
     public void concurrentGetFromStagedAndCached() throws Exception {
+        LOG.info("Starting concurrentGetFromStagedAndCached");
+
         // Add 1 to backend
         // Add 2 to upload area
         // Stop upload execution
@@ -475,6 +535,8 @@ public class CompositeDataStoreCacheTest
         assertCacheStats(cache.getCacheStats(), 2, 8 * 1024, 0, 2);
         assertEquals(1, cache.getCacheStats().getLoadCount());
         assertEquals(1, cache.getCacheStats().getLoadSuccessCount());
+
+        LOG.info("Finished concurrentGetFromStagedAndCached");
     }
 
     /**
@@ -484,6 +546,8 @@ public class CompositeDataStoreCacheTest
      */
     @Test
     public void concurrentAddGet() throws Exception {
+        LOG.info("Starting concurrentAddGet");
+
         // Add to the upload area
         // stop upload execution
         // Same as above but concurrently
@@ -524,6 +588,8 @@ public class CompositeDataStoreCacheTest
         assertEquals(2, cache.getStagingCacheStats().getLoadCount());
         assertEquals(0, cache.getCacheStats().getLoadCount());
         assertEquals(0, cache.getCacheStats().getLoadSuccessCount());
+
+        LOG.info("Finished concurrentAddGet");
     }
 
     /**--------------------------- Helper Methods -----------------------------------------------**/

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/blob/FileCacheTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/blob/FileCacheTest.java?rev=1774122&r1=1774121&r2=1774122&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/blob/FileCacheTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/blob/FileCacheTest.java Wed Dec 14 04:10:47 2016
@@ -67,6 +67,8 @@ public class FileCacheTest extends Abstr
     CountDownLatch afterExecuteLatch;
     @Before
     public void setup() throws Exception {
+        LOG.info("Started setup");
+
         root = folder.newFolder();
         closer = Closer.create();
         loader = new TestCacheLoader<String, InputStream>(folder.newFolder());
@@ -82,6 +84,8 @@ public class FileCacheTest extends Abstr
         Futures.successfulAsList((Iterable<? extends ListenableFuture<?>>) executor.futures).get();
 
         closer.register(cache);
+
+        LOG.info("Finished setup");
     }
 
     @After
@@ -91,6 +95,8 @@ public class FileCacheTest extends Abstr
 
     @Test
     public void zeroCache() throws Exception {
+        LOG.info("Started zeroCache");
+
         cache = FileCache.build(0/* KB */, root, loader, null);
         closer.register(cache);
         File f = createFile(0, loader, cache, folder);
@@ -101,6 +107,8 @@ public class FileCacheTest extends Abstr
         cache.invalidate(ID_PREFIX + 0);
         assertFalse(cache.containsKey(ID_PREFIX + 0));
         cache.close();
+
+        LOG.info("Finished zeroCache");
     }
 
     /**
@@ -329,18 +337,17 @@ public class FileCacheTest extends Abstr
         CountDownLatch thread2Start = new CountDownLatch(1);
         SettableFuture<File> future2 =
             retrieveThread(executorService, ID_PREFIX + 4, cache, thread2Start);
-
         thread2Start.countDown();
 
         File f10 = future1.get();
-        future2.get();
+        File f4 = future2.get();
         LOG.info("Async tasks finished");
 
         if (f10.exists()) {
             assertCacheIfPresent(10, cache, f10);
         }
-        if (f.exists()) {
-            assertCacheIfPresent(4, cache, f);
+        if (f4.exists()) {
+            assertCacheIfPresent(4, cache, f4);
         }
         LOG.info("Finished getInvalidateConcurrent");
     }