Search in sources :

Example 6 with CheckConsistencyCommand

use of org.neo4j.consistency.CheckConsistencyCommand in project neo4j by neo4j.

the class CheckConsistencyCommandIT method shouldCanonicalizeReportDirectory.

@Test
void shouldCanonicalizeReportDirectory() 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=" + Paths.get("..", "bar"));
    checkConsistencyCommand.execute();
    verify(consistencyCheckService).runFullConsistencyCheck(any(), any(), any(), any(), any(), anyBoolean(), eq(Path.of("../bar")), 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 7 with CheckConsistencyCommand

use of org.neo4j.consistency.CheckConsistencyCommand in project neo4j by neo4j.

the class CheckConsistencyCommandIT method enablesVerbosity.

@Test
void enablesVerbosity() throws Exception {
    ConsistencyCheckService consistencyCheckService = mock(ConsistencyCheckService.class);
    CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(new ExecutionContext(homeDir, confPath), consistencyCheckService);
    DatabaseLayout databaseLayout = neo4jLayout.databaseLayout("mydb");
    when(consistencyCheckService.runFullConsistencyCheck(eq(databaseLayout), any(Config.class), any(ProgressMonitorFactory.class), any(LogProvider.class), any(FileSystemAbstraction.class), eq(true), any(), any(ConsistencyFlags.class))).thenReturn(ConsistencyCheckService.Result.success(null, null));
    CommandLine.populateCommand(checkConsistencyCommand, "--database=mydb", "--verbose");
    checkConsistencyCommand.execute();
    verify(consistencyCheckService).runFullConsistencyCheck(eq(databaseLayout), any(Config.class), any(ProgressMonitorFactory.class), any(LogProvider.class), any(FileSystemAbstraction.class), eq(true), any(), any(ConsistencyFlags.class));
}
Also used : LogProvider(org.neo4j.logging.LogProvider) ExecutionContext(org.neo4j.cli.ExecutionContext) 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) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) ConsistencyCheckService(org.neo4j.consistency.ConsistencyCheckService) CheckConsistencyCommand(org.neo4j.consistency.CheckConsistencyCommand) Test(org.junit.jupiter.api.Test)

Example 8 with CheckConsistencyCommand

use of org.neo4j.consistency.CheckConsistencyCommand in project neo4j by neo4j.

the class CheckConsistencyCommandIT method databaseAndBackupAreMutuallyExclusive.

@Test
void databaseAndBackupAreMutuallyExclusive() throws Exception {
    ConsistencyCheckService consistencyCheckService = mock(ConsistencyCheckService.class);
    CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(new ExecutionContext(homeDir, confPath), consistencyCheckService);
    when(consistencyCheckService.runFullConsistencyCheck(any(), any(), any(), any(), any(), anyBoolean(), any(ConsistencyFlags.class))).thenReturn(ConsistencyCheckService.Result.success(null, null));
    MutuallyExclusiveArgsException incorrectUsage = assertThrows(MutuallyExclusiveArgsException.class, () -> {
        CommandLine.populateCommand(checkConsistencyCommand, "--database=foo", "--backup=bar");
        checkConsistencyCommand.execute();
    });
    assertThat(incorrectUsage.getMessage()).contains("--database=<database>, --backup=<path> are mutually exclusive (specify only one)");
}
Also used : MutuallyExclusiveArgsException(picocli.CommandLine.MutuallyExclusiveArgsException) 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 9 with CheckConsistencyCommand

use of org.neo4j.consistency.CheckConsistencyCommand in project neo4j by neo4j.

the class CheckConsistencyCommandIT method backupNeedsToBePath.

@Test
void backupNeedsToBePath() {
    ConsistencyCheckService consistencyCheckService = mock(ConsistencyCheckService.class);
    CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(new ExecutionContext(homeDir, confPath), consistencyCheckService);
    Path backupPath = homeDir.resolve("dir/does/not/exist");
    CommandFailedException commandFailed = assertThrows(CommandFailedException.class, () -> {
        CommandLine.populateCommand(checkConsistencyCommand, "--backup=" + backupPath);
        checkConsistencyCommand.execute();
    });
    assertThat(commandFailed.getMessage()).contains("Report directory path doesn't exist or not a directory");
}
Also used : Path(java.nio.file.Path) ExecutionContext(org.neo4j.cli.ExecutionContext) ConsistencyCheckService(org.neo4j.consistency.ConsistencyCheckService) CheckConsistencyCommand(org.neo4j.consistency.CheckConsistencyCommand) CommandFailedException(org.neo4j.cli.CommandFailedException) Test(org.junit.jupiter.api.Test)

Example 10 with CheckConsistencyCommand

use of org.neo4j.consistency.CheckConsistencyCommand in project neo4j by neo4j.

the class CheckConsistencyCommandIT method passesOnCheckParameters.

@Test
void passesOnCheckParameters() throws Exception {
    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", "--check-graph=false", "--check-indexes=false", "--check-index-structure=true");
    checkConsistencyCommand.execute();
    verify(consistencyCheckService).runFullConsistencyCheck(any(), any(), any(), any(), any(), anyBoolean(), any(), eq(new ConsistencyFlags(false, false, true)));
}
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