use of org.neo4j.cli.ExecutionContext in project neo4j by neo4j.
the class MemoryRecommendationsCommandTest method doNotPrintRecommendationsForOffHeapWhenOnHeapIsConfigured.
@Test
void doNotPrintRecommendationsForOffHeapWhenOnHeapIsConfigured() throws Exception {
PrintStream output = mock(PrintStream.class);
Path homeDir = testDirectory.homePath();
Path configDir = homeDir.resolve("conf");
Path configFile = configDir.resolve(DEFAULT_CONFIG_FILE_NAME);
Files.createDirectories(configDir);
store(stringMap(data_directory.name(), homeDir.toString(), tx_state_memory_allocation.name(), TransactionStateMemoryAllocation.ON_HEAP.name()), configFile);
MemoryRecommendationsCommand command = new MemoryRecommendationsCommand(new ExecutionContext(homeDir, configDir, output, mock(PrintStream.class), testDirectory.getFileSystem()));
CommandLine.populateCommand(command, "--memory=8g");
String heap = bytesToString(recommendHeapMemory(gibiBytes(8)));
String pagecache = bytesToString(recommendPageCacheMemory(gibiBytes(8), 0));
String offHeap = bytesToString(gibiBytes(2));
command.execute();
verify(output).println(initial_heap_size.name() + "=" + heap);
verify(output).println(max_heap_size.name() + "=" + heap);
verify(output).println(pagecache_memory.name() + "=" + pagecache);
verify(output, never()).println(tx_state_max_off_heap_memory.name() + "=" + offHeap);
}
use of org.neo4j.cli.ExecutionContext in project neo4j by neo4j.
the class MemoryRecommendationsCommandTest method mustPrintMinimalPageCacheMemorySettingForConfiguredDb.
@Test
void mustPrintMinimalPageCacheMemorySettingForConfiguredDb() throws Exception {
// given
Path homeDir = neo4jLayout.homeDirectory();
Path configDir = homeDir.resolve("conf");
Files.createDirectories(configDir);
Path configFile = configDir.resolve(DEFAULT_CONFIG_FILE_NAME);
Files.createFile(configFile);
createDatabaseWithNativeIndexes(homeDir, DEFAULT_DATABASE_NAME);
PrintStream output = mock(PrintStream.class);
MemoryRecommendationsCommand command = new MemoryRecommendationsCommand(new ExecutionContext(homeDir, configDir, output, mock(PrintStream.class), testDirectory.getFileSystem()));
String heap = bytesToString(recommendHeapMemory(gibiBytes(8)));
String pagecache = bytesToString(recommendPageCacheMemory(gibiBytes(8), gibiBytes(2)));
// when
CommandLine.populateCommand(command, "--memory=8g");
command.execute();
// then
verify(output).println(contains(initial_heap_size.name() + "=" + heap));
verify(output).println(contains(max_heap_size.name() + "=" + heap));
verify(output).println(contains(pagecache_memory.name() + "=" + pagecache));
DatabaseLayout databaseLayout = neo4jLayout.databaseLayout(DEFAULT_DATABASE_NAME);
DatabaseLayout systemLayout = neo4jLayout.databaseLayout(SYSTEM_DATABASE_NAME);
long[] expectedSizes = calculatePageCacheFileSize(databaseLayout);
long[] systemSizes = calculatePageCacheFileSize(systemLayout);
long expectedPageCacheSize = expectedSizes[0] + systemSizes[0];
long expectedLuceneSize = expectedSizes[1] + systemSizes[1];
verify(output).println(contains("Total size of lucene indexes in all databases: " + bytesToString(expectedLuceneSize)));
verify(output).println(contains("Total size of data and native indexes in all databases: " + bytesToString(expectedPageCacheSize)));
}
use of org.neo4j.cli.ExecutionContext in project neo4j by neo4j.
the class MemoryRecommendationsCommandTest method mustPrintRecommendationsAsConfigReadableOutput.
@Test
void mustPrintRecommendationsAsConfigReadableOutput() throws Exception {
PrintStream output = mock(PrintStream.class);
Path homeDir = testDirectory.homePath();
Path configDir = homeDir.resolve("conf");
Path configFile = configDir.resolve(DEFAULT_CONFIG_FILE_NAME);
Files.createDirectories(configDir);
store(stringMap(data_directory.name(), homeDir.toString()), configFile);
MemoryRecommendationsCommand command = new MemoryRecommendationsCommand(new ExecutionContext(homeDir, configDir, output, mock(PrintStream.class), testDirectory.getFileSystem()));
CommandLine.populateCommand(command, "--memory=8g");
String heap = bytesToString(recommendHeapMemory(gibiBytes(8)));
String pagecache = bytesToString(recommendPageCacheMemory(gibiBytes(8), gibiBytes(2)));
String offHeap = bytesToString(gibiBytes(2));
command.execute();
verify(output).println(initial_heap_size.name() + "=" + heap);
verify(output).println(max_heap_size.name() + "=" + heap);
verify(output).println(pagecache_memory.name() + "=" + pagecache);
verify(output).println(tx_state_max_off_heap_memory.name() + "=" + offHeap);
verify(output).println(additional_jvm.name() + "=" + "-XX:+ExitOnOutOfMemoryError");
}
use of org.neo4j.cli.ExecutionContext in project neo4j by neo4j.
the class DumpCommandIT method execute.
private void execute(String database, Path to) {
final ExecutionContext ctx = new ExecutionContext(homeDir, configDir, mock(PrintStream.class), mock(PrintStream.class), testDirectory.getFileSystem());
final var command = new DumpCommand(ctx, dumper);
CommandLine.populateCommand(command, "--database=" + database, "--to=" + to.toAbsolutePath());
command.execute();
}
use of org.neo4j.cli.ExecutionContext in project neo4j by neo4j.
the class SetDefaultAdminCommandTest method setup.
@BeforeEach
void setup() throws IOException, InvalidArgumentsException {
command = new SetDefaultAdminCommand(new ExecutionContext(testDir.directory("home"), testDir.directory("conf"), mock(PrintStream.class), mock(PrintStream.class), fileSystem));
final Config config = command.loadNeo4jConfig();
UserRepository users = CommunitySecurityModule.getUserRepository(config, NullLogProvider.getInstance(), fileSystem);
users.create(new User.Builder("jake", LegacyCredential.forPassword("123")).withRequiredPasswordChange(false).build());
adminIniFile = CommunitySecurityModule.getUserRepositoryFile(config).resolveSibling("admin.ini");
}
Aggregations