Search in sources :

Example 1 with CheckConsistencyCommand

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");
}
Also used : DumpCommand(org.neo4j.commandline.dbms.DumpCommand) DiagnosticsReportCommand(org.neo4j.commandline.dbms.DiagnosticsReportCommand) SetDefaultAdminCommand(org.neo4j.commandline.admin.security.SetDefaultAdminCommand) StoreInfoCommand(org.neo4j.commandline.dbms.StoreInfoCommand) Loader(org.neo4j.dbms.archive.Loader) MemoryRecommendationsCommand(org.neo4j.commandline.dbms.MemoryRecommendationsCommand) LoadCommand(org.neo4j.commandline.dbms.LoadCommand) SetInitialPasswordCommand(org.neo4j.commandline.admin.security.SetInitialPasswordCommand) CheckConsistencyCommand(org.neo4j.consistency.CheckConsistencyCommand) Dumper(org.neo4j.dbms.archive.Dumper) Test(org.junit.jupiter.api.Test)

Example 2 with CheckConsistencyCommand

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."));
}
Also used : PrintStream(java.io.PrintStream) ExecutionContext(org.neo4j.cli.ExecutionContext) ByteArrayOutputStream(java.io.ByteArrayOutputStream) CheckConsistencyCommand(org.neo4j.consistency.CheckConsistencyCommand) Test(org.junit.jupiter.api.Test)

Example 3 with CheckConsistencyCommand

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));
}
Also used : ExecutionContext(org.neo4j.cli.ExecutionContext) ConsistencyFlags(org.neo4j.consistency.checking.full.ConsistencyFlags) ConsistencyCheckService(org.neo4j.consistency.ConsistencyCheckService) CheckConsistencyCommand(org.neo4j.consistency.CheckConsistencyCommand) Test(org.junit.jupiter.api.Test)

Example 4 with CheckConsistencyCommand

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));
}
Also used : PrintStream(java.io.PrintStream) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) ProgressMonitorFactory(org.neo4j.internal.helpers.progress.ProgressMonitorFactory) ConsistencyFlags(org.neo4j.consistency.checking.full.ConsistencyFlags) Config(org.neo4j.configuration.Config) ByteArrayOutputStream(java.io.ByteArrayOutputStream) LogProvider(org.neo4j.logging.LogProvider) ExecutionContext(org.neo4j.cli.ExecutionContext) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) ConsistencyCheckService(org.neo4j.consistency.ConsistencyCheckService) CheckConsistencyCommand(org.neo4j.consistency.CheckConsistencyCommand) Test(org.junit.jupiter.api.Test)

Example 5 with CheckConsistencyCommand

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));
}
Also used : ExecutionContext(org.neo4j.cli.ExecutionContext) ConsistencyFlags(org.neo4j.consistency.checking.full.ConsistencyFlags) ConsistencyCheckService(org.neo4j.consistency.ConsistencyCheckService) CheckConsistencyCommand(org.neo4j.consistency.CheckConsistencyCommand) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)15 CheckConsistencyCommand (org.neo4j.consistency.CheckConsistencyCommand)15 ExecutionContext (org.neo4j.cli.ExecutionContext)13 ConsistencyCheckService (org.neo4j.consistency.ConsistencyCheckService)12 ConsistencyFlags (org.neo4j.consistency.checking.full.ConsistencyFlags)10 DatabaseLayout (org.neo4j.io.layout.DatabaseLayout)6 Config (org.neo4j.configuration.Config)5 ProgressMonitorFactory (org.neo4j.internal.helpers.progress.ProgressMonitorFactory)5 DefaultFileSystemAbstraction (org.neo4j.io.fs.DefaultFileSystemAbstraction)5 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)5 LogProvider (org.neo4j.logging.LogProvider)5 CommandFailedException (org.neo4j.cli.CommandFailedException)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 PrintStream (java.io.PrintStream)2 SetDefaultAdminCommand (org.neo4j.commandline.admin.security.SetDefaultAdminCommand)2 SetInitialPasswordCommand (org.neo4j.commandline.admin.security.SetInitialPasswordCommand)2 DiagnosticsReportCommand (org.neo4j.commandline.dbms.DiagnosticsReportCommand)2 DumpCommand (org.neo4j.commandline.dbms.DumpCommand)2 LoadCommand (org.neo4j.commandline.dbms.LoadCommand)2 MemoryRecommendationsCommand (org.neo4j.commandline.dbms.MemoryRecommendationsCommand)2