Search in sources :

Example 41 with DatabaseLayout

use of org.neo4j.io.layout.DatabaseLayout 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 42 with DatabaseLayout

use of org.neo4j.io.layout.DatabaseLayout 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 43 with DatabaseLayout

use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.

the class DumpCommandIT method shouldRespectTheDatabaseLock.

@Test
void shouldRespectTheDatabaseLock() throws Exception {
    Path databaseDirectory = homeDir.resolve("data/databases/foo");
    DatabaseLayout databaseLayout = DatabaseLayout.ofFlat(databaseDirectory);
    try (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction();
        Locker locker = new DatabaseLocker(fileSystem, databaseLayout)) {
        locker.checkLock();
        CommandFailedException commandFailed = assertThrows(CommandFailedException.class, () -> execute("foo"));
        assertEquals("The database is in use. Stop database 'foo' and try again.", commandFailed.getMessage());
    }
}
Also used : Path(java.nio.file.Path) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) DatabaseLocker(org.neo4j.kernel.internal.locker.DatabaseLocker) Locker(org.neo4j.kernel.internal.locker.Locker) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) DatabaseLocker(org.neo4j.kernel.internal.locker.DatabaseLocker) CommandFailedException(org.neo4j.cli.CommandFailedException) Test(org.junit.jupiter.api.Test)

Example 44 with DatabaseLayout

use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.

the class DumpCommandIT method shouldReportAHelpfulErrorIfWeDontHaveWritePermissionsForLock.

@Test
@DisabledOnOs(OS.WINDOWS)
@DisabledForRoot
void shouldReportAHelpfulErrorIfWeDontHaveWritePermissionsForLock() throws Exception {
    DatabaseLayout databaseLayout = DatabaseLayout.ofFlat(databaseDirectory);
    try (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction()) {
        Path file = databaseLayout.databaseLockFile();
        try (Closeable ignored = withPermissions(file, emptySet())) {
            CommandFailedException commandFailed = assertThrows(CommandFailedException.class, () -> execute("foo"));
            assertEquals("You do not have permission to dump the database.", commandFailed.getMessage());
        }
    }
}
Also used : Path(java.nio.file.Path) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) Closeable(java.io.Closeable) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) CommandFailedException(org.neo4j.cli.CommandFailedException) DisabledOnOs(org.junit.jupiter.api.condition.DisabledOnOs) Test(org.junit.jupiter.api.Test) DisabledForRoot(org.neo4j.test.extension.DisabledForRoot)

Example 45 with DatabaseLayout

use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.

the class AllNodesInStoreExistInLabelIndexTest method copyLabelIndexFile.

private Path copyLabelIndexFile() throws IOException {
    DatabaseLayout databaseLayout = db.databaseLayout();
    Path labelIndexFileCopy = databaseLayout.file("label_index_copy");
    database.stop();
    fs.copyFile(databaseLayout.labelScanStore(), labelIndexFileCopy);
    database.start();
    return labelIndexFileCopy;
}
Also used : Path(java.nio.file.Path) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout)

Aggregations

DatabaseLayout (org.neo4j.io.layout.DatabaseLayout)108 Test (org.junit.jupiter.api.Test)66 Path (java.nio.file.Path)51 Config (org.neo4j.configuration.Config)35 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)24 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)19 DefaultFileSystemAbstraction (org.neo4j.io.fs.DefaultFileSystemAbstraction)17 PageCache (org.neo4j.io.pagecache.PageCache)17 IOException (java.io.IOException)16 ConsistencyCheckService (org.neo4j.consistency.ConsistencyCheckService)16 Transaction (org.neo4j.graphdb.Transaction)13 DefaultIdGeneratorFactory (org.neo4j.internal.id.DefaultIdGeneratorFactory)10 DatabaseManagementService (org.neo4j.dbms.api.DatabaseManagementService)9 TestDatabaseManagementServiceBuilder (org.neo4j.test.TestDatabaseManagementServiceBuilder)9 CommandFailedException (org.neo4j.cli.CommandFailedException)8 ExecutionContext (org.neo4j.cli.ExecutionContext)8 PageCacheTracer (org.neo4j.io.pagecache.tracing.PageCacheTracer)8 StorageEngineFactory (org.neo4j.storageengine.api.StorageEngineFactory)8 Closeable (java.io.Closeable)7 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)7