use of org.neo4j.consistency.CheckConsistencyCommand in project neo4j by neo4j.
the class AdminCommandsIT method shouldExpandCommands.
@Test
void shouldExpandCommands() throws Exception {
assertSuccess(new SetInitialPasswordCommand(context), "--expand-commands", "pass");
assertSuccess(new SetDefaultAdminCommand(context), "--expand-commands", "admin");
assertSuccess(new StoreInfoCommand(context), "--expand-commands", "path");
assertSuccess(new CheckConsistencyCommand(context), "--expand-commands", "--database", "neo4j");
assertSuccess(new DiagnosticsReportCommand(context), "--expand-commands");
assertSuccess(new LoadCommand(context, new Loader()), "--expand-commands", "--from", "test");
assertSuccess(new MemoryRecommendationsCommand(context), "--expand-commands");
assertSuccess(new DumpCommand(context, new Dumper(context.err())), "--expand-commands", "--to", "test");
}
use of org.neo4j.consistency.CheckConsistencyCommand in project neo4j by neo4j.
the class CheckConsistencyCommandIT method printUsageHelp.
@Test
void printUsageHelp() {
final var baos = new ByteArrayOutputStream();
final var command = new CheckConsistencyCommand(new ExecutionContext(Path.of("."), Path.of(".")));
try (var out = new PrintStream(baos)) {
CommandLine.usage(command, new PrintStream(out), CommandLine.Help.Ansi.OFF);
}
assertThat(baos.toString().trim()).isEqualTo(String.format("Check the consistency of a database.%n" + "%n" + "USAGE%n" + "%n" + "check-consistency [--expand-commands] [--verbose] [--additional-config=<path>]%n" + " [--check-graph=<true/false>]%n" + " [--check-index-structure=<true/false>]%n" + " [--check-indexes=<true/false>]%n" + " [--check-label-scan-store=<true/false>]%n" + " [--check-property-owners=<true/false>]%n" + " [--check-relationship-type-scan-store=<true/false>]%n" + " [--report-dir=<path>] (--database=<database> |%n" + " --backup=<path>)%n" + "%n" + "DESCRIPTION%n" + "%n" + "This command allows for checking the consistency of a database or a backup%n" + "thereof. It cannot be used with a database which is currently in use.%n" + "%n" + "All checks except 'check-graph' can be quite expensive so it may be useful to%n" + "turn them off for very large databases. Increasing the heap size can also be a%n" + "good idea. See 'neo4j-admin help' for details.%n" + "%n" + "OPTIONS%n" + "%n" + " --verbose Enable verbose output.%n" + " --expand-commands Allow command expansion in config value evaluation.%n" + " --database=<database> Name of the database to check.%n" + " --backup=<path> Path to backup to check consistency of. Cannot be%n" + " used together with --database.%n" + " --additional-config=<path>%n" + " Configuration file to supply additional%n" + " configuration in.%n" + " --report-dir=<path> Directory where consistency report will be written.%n" + " Default: .%n" + " --check-graph=<true/false>%n" + " Perform consistency checks between nodes,%n" + " relationships, properties, types and tokens.%n" + " Default: true%n" + " --check-indexes=<true/false>%n" + " Perform consistency checks on indexes.%n" + " Default: true%n" + " --check-index-structure=<true/false>%n" + " Perform structure checks on indexes.%n" + " Default: true%n" + " --check-label-scan-store=<true/false>%n" + " Perform consistency checks on the label scan store.%n" + " This option is deprecated and its value will be%n" + " ignored. Checking of label scan store/lookup%n" + " index on labels is controlled by --check-graph.%n" + " --check-relationship-type-scan-store=<true/false>%n" + " Perform consistency checks on the relationship type%n" + " scan store. This option is deprecated and its%n" + " value will be ignored. Checking of relationship%n" + " type scan store/lookup index on relationship%n" + " types is controlled by --check-graph.%n" + " --check-property-owners=<true/false>%n" + " Perform additional consistency checks on property%n" + " ownership. This check is very expensive in time%n" + " and memory. This option is deprecated and its%n" + " value will be ignored."));
}
use of org.neo4j.consistency.CheckConsistencyCommand in project neo4j by neo4j.
the class CheckConsistencyCommandIT method shouldWriteReportFileToSpecifiedDirectory.
@Test
void shouldWriteReportFileToSpecifiedDirectory() throws IOException, ConsistencyCheckIncompleteException, CommandFailedException {
ConsistencyCheckService consistencyCheckService = mock(ConsistencyCheckService.class);
CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(new ExecutionContext(homeDir, confPath), consistencyCheckService);
when(consistencyCheckService.runFullConsistencyCheck(any(), any(), any(), any(), any(), anyBoolean(), any(), any(ConsistencyFlags.class))).thenReturn(ConsistencyCheckService.Result.success(null, null));
CommandLine.populateCommand(checkConsistencyCommand, "--database=mydb", "--report-dir=some-dir-or-other");
checkConsistencyCommand.execute();
verify(consistencyCheckService).runFullConsistencyCheck(any(), any(), any(), any(), any(), anyBoolean(), eq(Path.of("some-dir-or-other")), any(ConsistencyFlags.class));
}
use of org.neo4j.consistency.CheckConsistencyCommand in project neo4j by neo4j.
the class CheckConsistencyCommandIT method warnsOnUseOfDeprecatedOptions.
@Test
void warnsOnUseOfDeprecatedOptions() throws Exception {
ConsistencyCheckService consistencyCheckService = mock(ConsistencyCheckService.class);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream out = new PrintStream(baos);
CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(new ExecutionContext(homeDir, confPath, out, System.err, new DefaultFileSystemAbstraction()), consistencyCheckService);
DatabaseLayout databaseLayout = neo4jLayout.databaseLayout("mydb");
when(consistencyCheckService.runFullConsistencyCheck(eq(databaseLayout), any(Config.class), any(ProgressMonitorFactory.class), any(LogProvider.class), any(FileSystemAbstraction.class), eq(false), any(), any(ConsistencyFlags.class))).thenReturn(ConsistencyCheckService.Result.success(null, null));
CommandLine.populateCommand(checkConsistencyCommand, "--database=mydb", "--check-label-scan-store=true", "--check-relationship-type-scan-store=true", "--check-property-owners=true");
checkConsistencyCommand.execute();
// See that warnings were printed and that command was still run.
String log = baos.toString();
assertThat(log).contains("Option '--check-label-scan-store' has been deprecated and its value will be ignored");
assertThat(log).contains("Option '--check-relationship-type-scan-store' has been deprecated and its value will be ignored");
assertThat(log).contains("Option '--check-property-owners' has been deprecated and its value will be ignored");
verify(consistencyCheckService).runFullConsistencyCheck(eq(databaseLayout), any(Config.class), any(ProgressMonitorFactory.class), any(LogProvider.class), any(FileSystemAbstraction.class), eq(false), any(), any(ConsistencyFlags.class));
}
use of org.neo4j.consistency.CheckConsistencyCommand in project neo4j by neo4j.
the class CheckConsistencyCommandIT method shouldWriteReportFileToCurrentDirectoryByDefault.
@Test
void shouldWriteReportFileToCurrentDirectoryByDefault() throws IOException, ConsistencyCheckIncompleteException, CommandFailedException {
ConsistencyCheckService consistencyCheckService = mock(ConsistencyCheckService.class);
CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(new ExecutionContext(homeDir, confPath), consistencyCheckService);
when(consistencyCheckService.runFullConsistencyCheck(any(), any(), any(), any(), any(), anyBoolean(), any(), any(ConsistencyFlags.class))).thenReturn(ConsistencyCheckService.Result.success(null, null));
CommandLine.populateCommand(checkConsistencyCommand, "--database=mydb");
checkConsistencyCommand.execute();
verify(consistencyCheckService).runFullConsistencyCheck(any(), any(), any(), any(), any(), anyBoolean(), eq(Path.of("")), any(ConsistencyFlags.class));
}
Aggregations