use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.
the class FullCheckFulltextIndexEmptyDocs method shouldNotReportEmptyDocsInFulltextIndexAsInconsistencies.
/**
* Fulltext index created before 4.3.0-drop02 can contain empty documents added when there were nodes matching the
* schema but having non-text values. This zip contains a couple of fulltext indexes with some empty documents.
* Consistency checker should ignore such documents since we don't want to force rebuild of all fulltext indexes
* when they actually are usable.
*/
@Test
void shouldNotReportEmptyDocsInFulltextIndexAsInconsistencies() throws Throwable {
Config config = Config.newBuilder().set(allow_upgrade, true).set(neo4j_home, testDirectory.homePath()).build();
DatabaseManagementService managementService = startUp42Db(config);
GraphDatabaseAPI db = (GraphDatabaseAPI) managementService.database(GraphDatabaseSettings.DEFAULT_DATABASE_NAME);
DatabaseLayout layout = db.databaseLayout();
managementService.shutdown();
ConsistencyCheckService.Result result = check(config, layout);
assertTrue(result.isSuccessful());
}
use of org.neo4j.io.layout.DatabaseLayout 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.io.layout.DatabaseLayout 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.io.layout.DatabaseLayout 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));
}
use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.
the class IndexRecoveryIT method restoreSnapshot.
private void restoreSnapshot(Path snapshotDir) {
try {
DatabaseLayout layout = databaseLayout;
FileUtils.deleteDirectory(layout.databaseDirectory());
FileUtils.deleteDirectory(layout.getTransactionLogsDirectory());
FileUtils.copyDirectory(snapshotDir.resolve("data"), layout.databaseDirectory());
FileUtils.copyDirectory(snapshotDir.resolve("transactions"), layout.getTransactionLogsDirectory());
FileUtils.deleteDirectory(snapshotDir);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
Aggregations