use of org.neo4j.consistency.CheckConsistencyCommand in project neo4j by neo4j.
the class AdminCommandsIT method shouldNotExpandCommands.
@Test
void shouldNotExpandCommands() {
assertExpansionError(new SetInitialPasswordCommand(context), "pass");
assertExpansionError(new SetDefaultAdminCommand(context), "user");
assertExpansionError(new StoreInfoCommand(context), "path");
assertExpansionError(new CheckConsistencyCommand(context), "--database", "neo4j");
assertExpansionError(new DiagnosticsReportCommand(context));
assertExpansionError(new LoadCommand(context, new Loader()), "--from", "test");
assertExpansionError(new MemoryRecommendationsCommand(context));
assertExpansionError(new ImportCommand(context), "--nodes=" + testDirectory.createFile("foo.csv").toAbsolutePath());
assertExpansionError(new DumpCommand(context, new Dumper(context.err())), "--to", "test");
}
use of org.neo4j.consistency.CheckConsistencyCommand in project neo4j by neo4j.
the class CheckConsistencyCommandIT method failsWhenInconsistenciesAreFound.
@Test
void failsWhenInconsistenciesAreFound() throws Exception {
ConsistencyCheckService consistencyCheckService = mock(ConsistencyCheckService.class);
CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(new ExecutionContext(homeDir, confPath), consistencyCheckService);
when(consistencyCheckService.runFullConsistencyCheck(any(DatabaseLayout.class), any(Config.class), any(ProgressMonitorFactory.class), any(LogProvider.class), any(FileSystemAbstraction.class), eq(true), any(), any(ConsistencyFlags.class))).thenReturn(ConsistencyCheckService.Result.failure(Path.of("/the/report/path"), new ConsistencySummaryStatistics()));
CommandFailedException commandFailed = assertThrows(CommandFailedException.class, () -> {
CommandLine.populateCommand(checkConsistencyCommand, "--database=mydb", "--verbose");
checkConsistencyCommand.execute();
});
assertThat(commandFailed.getMessage()).contains(Path.of("/the/report/path").toString());
}
use of org.neo4j.consistency.CheckConsistencyCommand in project neo4j by neo4j.
the class CheckConsistencyCommandIT method runsConsistencyChecker.
@Test
void runsConsistencyChecker() 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(false), any(), any(ConsistencyFlags.class))).thenReturn(ConsistencyCheckService.Result.success(null, null));
CommandLine.populateCommand(checkConsistencyCommand, "--database=mydb");
checkConsistencyCommand.execute();
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 consistencyCheckerRespectDatabaseLock.
@Test
void consistencyCheckerRespectDatabaseLock() throws CannotWriteException, IOException {
ConsistencyCheckService consistencyCheckService = mock(ConsistencyCheckService.class);
CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(new ExecutionContext(homeDir, confPath), consistencyCheckService);
DatabaseLayout databaseLayout = neo4jLayout.databaseLayout("mydb");
testDirectory.getFileSystem().mkdirs(databaseLayout.databaseDirectory());
try (Closeable ignored = LockChecker.checkDatabaseLock(databaseLayout)) {
CommandLine.populateCommand(checkConsistencyCommand, "--database=mydb", "--verbose");
CommandFailedException exception = assertThrows(CommandFailedException.class, checkConsistencyCommand::execute);
assertThat(exception.getCause()).isInstanceOf(FileLockException.class);
assertThat(exception.getMessage()).isEqualTo("The database is in use. Stop database 'mydb' and try again.");
}
}
use of org.neo4j.consistency.CheckConsistencyCommand in project neo4j by neo4j.
the class CheckConsistencyCommandIT method canRunOnBackup.
@Test
void canRunOnBackup() throws Exception {
ConsistencyCheckService consistencyCheckService = mock(ConsistencyCheckService.class);
DatabaseLayout backupLayout = Neo4jLayout.ofFlat(testDirectory.directory("backup")).databaseLayout(DEFAULT_DATABASE_NAME);
prepareBackupDatabase(backupLayout);
CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(new ExecutionContext(homeDir, confPath), consistencyCheckService);
when(consistencyCheckService.runFullConsistencyCheck(eq(backupLayout), 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, "--backup=" + backupLayout.databaseDirectory());
checkConsistencyCommand.execute();
verify(consistencyCheckService).runFullConsistencyCheck(eq(backupLayout), any(Config.class), any(ProgressMonitorFactory.class), any(LogProvider.class), any(FileSystemAbstraction.class), eq(false), any(), any(ConsistencyFlags.class));
}
Aggregations