summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2020-01-09 02:03:45 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2020-01-09 02:03:45 +0100
commit6f177b3f6cf5cea4086be35c0d5ceeb73694b9c0 (patch)
tree5b6fec7891a5bc16a6d567b673d8879f88fdf330 /org.eclipse.jgit.test
parentfefddb28b23d9b49215cfc813acd8612a9cda8bb (diff)
parent4209a0f84b1917c0640d781ac54e8c5ffbadd574 (diff)
downloadjgit-6f177b3f6cf5cea4086be35c0d5ceeb73694b9c0.tar.gz
jgit-6f177b3f6cf5cea4086be35c0d5ceeb73694b9c0.zip
Merge branch 'stable-5.1' into stable-5.2
* stable-5.1: Fix unclosed resource warning in SmartOutputStream JschConfigSessionFactory: fix boxing warning SshSupport#runSshCommand: don't throw exception in finally block Don't override already managed maven-compiler-plugin version Remove unused import from CreateFileSnapshotBenchmark Remove duplicate ignore_optional_problems entry in .classpath Update maven-site-plugin used by benchmark module to 3.8.2 Add dependency to enable site generation for benchmark module Ignore warnings for generated source code in org.eclipse.jgit.benchmark Fix MBean registration Enhance WindowCache statistics Change-Id: Ic90aacf1ea40e13dc564d4d659e79535e86d0300 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/WindowCacheGetTest.java43
1 files changed, 37 insertions, 6 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/WindowCacheGetTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/WindowCacheGetTest.java
index 9063b65189..f1a18b096c 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/WindowCacheGetTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/WindowCacheGetTest.java
@@ -61,6 +61,7 @@ import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectLoader;
import org.eclipse.jgit.storage.file.WindowCacheConfig;
+import org.eclipse.jgit.storage.file.WindowCacheStats;
import org.eclipse.jgit.test.resources.SampleDataRepositoryTestCase;
import org.eclipse.jgit.util.MutableInteger;
import org.junit.Before;
@@ -102,8 +103,21 @@ public class WindowCacheGetTest extends SampleDataRepositoryTestCase {
checkLimits(cfg);
final WindowCache cache = WindowCache.getInstance();
- assertEquals(6, cache.getOpenFiles());
- assertEquals(17346, cache.getOpenBytes());
+ WindowCacheStats s = cache.getStats();
+ assertEquals(6, s.getOpenFileCount());
+ assertEquals(17346, s.getOpenByteCount());
+ assertEquals(0, s.getEvictionCount());
+ assertEquals(90, s.getHitCount());
+ assertTrue(s.getHitRatio() > 0.0 && s.getHitRatio() < 1.0);
+ assertEquals(6, s.getLoadCount());
+ assertEquals(0, s.getLoadFailureCount());
+ assertEquals(0, s.getLoadFailureRatio(), 0.001);
+ assertEquals(6, s.getLoadSuccessCount());
+ assertEquals(6, s.getMissCount());
+ assertTrue(s.getMissRatio() > 0.0 && s.getMissRatio() < 1.0);
+ assertEquals(96, s.getRequestCount());
+ assertTrue(s.getAverageLoadTime() > 0.0);
+ assertTrue(s.getTotalLoadTime() > 0.0);
}
@Test
@@ -127,10 +141,27 @@ public class WindowCacheGetTest extends SampleDataRepositoryTestCase {
private static void checkLimits(WindowCacheConfig cfg) {
final WindowCache cache = WindowCache.getInstance();
- assertTrue(cache.getOpenFiles() <= cfg.getPackedGitOpenFiles());
- assertTrue(cache.getOpenBytes() <= cfg.getPackedGitLimit());
- assertTrue(0 < cache.getOpenFiles());
- assertTrue(0 < cache.getOpenBytes());
+ WindowCacheStats s = cache.getStats();
+ assertTrue(0 < s.getAverageLoadTime());
+ assertTrue(0 < s.getOpenByteCount());
+ assertTrue(0 < s.getOpenByteCount());
+ assertTrue(0.0 < s.getAverageLoadTime());
+ assertTrue(0 <= s.getEvictionCount());
+ assertTrue(0 < s.getHitCount());
+ assertTrue(0 < s.getHitRatio());
+ assertTrue(1 > s.getHitRatio());
+ assertTrue(0 < s.getLoadCount());
+ assertTrue(0 <= s.getLoadFailureCount());
+ assertTrue(0.0 <= s.getLoadFailureRatio());
+ assertTrue(1 > s.getLoadFailureRatio());
+ assertTrue(0 < s.getLoadSuccessCount());
+ assertTrue(s.getOpenByteCount() <= cfg.getPackedGitLimit());
+ assertTrue(s.getOpenFileCount() <= cfg.getPackedGitOpenFiles());
+ assertTrue(0 <= s.getMissCount());
+ assertTrue(0 <= s.getMissRatio());
+ assertTrue(1 > s.getMissRatio());
+ assertTrue(0 < s.getRequestCount());
+ assertTrue(0 < s.getTotalLoadTime());
}
private void doCacheTests() throws IOException {