summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2020-01-09 02:19:03 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2020-01-09 02:19:03 +0100
commitc5c1bbbe49313ee1e6ada9c0b7bfc02d27bcf5cd (patch)
tree2c8ad1dded18393bfe6e0d7f18637f08f1211761 /org.eclipse.jgit.test
parent839359425d619db31584955f4e0fb0d19ed4cfb8 (diff)
parent6f177b3f6cf5cea4086be35c0d5ceeb73694b9c0 (diff)
downloadjgit-c5c1bbbe49313ee1e6ada9c0b7bfc02d27bcf5cd.tar.gz
jgit-c5c1bbbe49313ee1e6ada9c0b7bfc02d27bcf5cd.zip
Merge branch 'stable-5.2' into stable-5.3
* stable-5.2: Fix API problem filters 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: I67a07d92718188bdf7f8a13b83e9f538ecf4b22f 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 {