diff options
author | Ivan Frade <ifrade@google.com> | 2024-10-15 23:41:06 +0000 |
---|---|---|
committer | Gerrit Code Review <support@gerrithub.io> | 2024-10-15 23:41:06 +0000 |
commit | 7fed42f860d2af49365283e6fba9a3a2dba9ea53 (patch) | |
tree | daa11727071b3abb948ed24b35c53e8fd632ef1f /org.eclipse.jgit.test/tst | |
parent | 5583f6a10eafc8c2627e0fb4833cb8ffe422f69a (diff) | |
parent | 6a169f10835c780e65b4e920dce3bed5006dc68d (diff) | |
download | jgit-7fed42f860d2af49365283e6fba9a3a2dba9ea53.tar.gz jgit-7fed42f860d2af49365283e6fba9a3a2dba9ea53.zip |
Merge "DfsBlockCacheConfigs: add debug configuration print"
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsBlockCacheConfigTest.java | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsBlockCacheConfigTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsBlockCacheConfigTest.java index 4b7aae05f0..65774e6d6c 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsBlockCacheConfigTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsBlockCacheConfigTest.java @@ -54,7 +54,12 @@ import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThrows; +import java.io.ByteArrayOutputStream; +import java.io.PrintWriter; +import java.nio.charset.StandardCharsets; +import java.util.Arrays; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; import org.eclipse.jgit.internal.JGitText; @@ -250,6 +255,45 @@ public class DfsBlockCacheConfigTest { () -> new DfsBlockCacheConfig().fromConfig(config)); } + @Test + public void writeConfigurationDebug_writesConfigsToWriter() + throws Exception { + Config config = new Config(); + config.setLong(CONFIG_CORE_SECTION, CONFIG_DFS_SECTION, + CONFIG_KEY_BLOCK_LIMIT, 50 * 1024); + config.setInt(CONFIG_CORE_SECTION, CONFIG_DFS_SECTION, + CONFIG_KEY_BLOCK_SIZE, 1024); + config.setInt(CONFIG_CORE_SECTION, CONFIG_DFS_SECTION, + CONFIG_KEY_CONCURRENCY_LEVEL, 3); + config.setString(CONFIG_CORE_SECTION, CONFIG_DFS_SECTION, + CONFIG_KEY_STREAM_RATIO, "0.5"); + addPackExtConfigEntry(config, "pack", List.of(PackExt.PACK), + /* blockLimit= */ 20 * 512, /* blockSize= */ 512); + + DfsBlockCacheConfig cacheConfig = new DfsBlockCacheConfig() + .fromConfig(config); + Map<PackExt, Integer> hotmap = Map.of(PackExt.PACK, 10); + cacheConfig.setCacheHotMap(hotmap); + + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + cacheConfig.print(new PrintWriter(byteArrayOutputStream, true, + StandardCharsets.UTF_8)); + + String writenConfig = byteArrayOutputStream + .toString(StandardCharsets.UTF_8); + + List<String> writenLines = Arrays.asList(writenConfig.split("\n")); + assertThat(writenLines, + equalTo(List.of("Name: dfs", " BlockLimit: " + (50 * 1024), + " BlockSize: 1024", " StreamRatio: 0.5", + " ConcurrencyLevel: 3", + " CacheHotMapEntry: " + PackExt.PACK + " : " + 10, + " Name: dfs.pack", " BlockLimit: " + 20 * 512, + " BlockSize: 512", " StreamRatio: 0.3", + " ConcurrencyLevel: 32", + " PackExts: " + List.of(PackExt.PACK)))); + } + private static void addPackExtConfigEntry(Config config, String configName, List<PackExt> packExts, long blockLimit, int blockSize) { String packExtConfigName = CONFIG_DFS_CACHE_PREFIX + configName; |