use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.
the class LoadCommandTest method shouldRespectTheDatabaseLock.
@Test
void shouldRespectTheDatabaseLock() throws IOException {
Path databaseDirectory = homeDir.resolve("data/databases/foo");
Files.createDirectories(databaseDirectory);
DatabaseLayout databaseLayout = DatabaseLayout.ofFlat(databaseDirectory);
try (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction();
Locker locker = new DatabaseLocker(fileSystem, databaseLayout)) {
locker.checkLock();
CommandFailedException commandFailed = assertThrows(CommandFailedException.class, () -> executeForce("foo"));
assertEquals("The database is in use. Stop database 'foo' and try again.", commandFailed.getMessage());
}
}
use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.
the class LoadCommandTest method shouldHandleSymlinkToDatabaseDir.
@Test
@DisabledOnOs(OS.WINDOWS)
void shouldHandleSymlinkToDatabaseDir() throws IOException, CommandFailedException, IncorrectFormat {
Path symDir = testDirectory.directory("path-to-links");
Path realDatabaseDir = symDir.resolve("foo");
Path dataDir = testDirectory.directory("some-other-path");
Path databaseDir = dataDir.resolve("databases/foo");
Path txLogsDir = dataDir.resolve(DEFAULT_TX_LOGS_ROOT_DIR_NAME);
Path databasesDir = dataDir.resolve("databases");
Files.createDirectories(realDatabaseDir);
Files.createDirectories(databasesDir);
Files.createSymbolicLink(databaseDir, realDatabaseDir);
Files.write(configDir.resolve(Config.DEFAULT_CONFIG_FILE_NAME), singletonList(formatProperty(data_directory, dataDir)));
execute("foo", archive);
DatabaseLayout databaseLayout = createDatabaseLayout(dataDir, databasesDir, "foo", txLogsDir);
verify(loader).load(any(), eq(databaseLayout));
}
use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.
the class ArchiveTest method dumpAndLoadTransactionLogsFromCustomLocations.
@ParameterizedTest
@EnumSource(CompressionFormat.class)
void dumpAndLoadTransactionLogsFromCustomLocations(CompressionFormat compressionFormat) throws IOException, IncorrectFormat {
Path txLogsRoot = testDirectory.directory("txLogsRoot");
DatabaseLayout testDatabaseLayout = layoutWithCustomTxRoot(txLogsRoot, "testDatabase");
Files.createDirectories(testDatabaseLayout.databaseDirectory());
Path txLogsDirectory = testDatabaseLayout.getTransactionLogsDirectory();
Files.createDirectories(txLogsDirectory);
Files.write(testDatabaseLayout.databaseDirectory().resolve("dbfile"), new byte[0]);
Files.write(txLogsDirectory.resolve(TransactionLogFilesHelper.DEFAULT_NAME + ".0"), new byte[0]);
Path archive = testDirectory.file("the-archive.dump");
new Dumper().dump(testDatabaseLayout.databaseDirectory(), txLogsDirectory, archive, compressionFormat, alwaysFalse());
Path newTxLogsRoot = testDirectory.directory("newTxLogsRoot");
DatabaseLayout newDatabaseLayout = layoutWithCustomTxRoot(newTxLogsRoot, "the-new-database");
new Loader().load(archive, newDatabaseLayout);
Path expectedOutput = testDirectory.directory("expected-output");
Files.write(expectedOutput.resolve("dbfile"), new byte[0]);
Path expectedTxLogs = testDirectory.directory("expectedTxLogs");
Files.write(expectedTxLogs.resolve(TransactionLogFilesHelper.DEFAULT_NAME + ".0"), new byte[0]);
assertEquals(describeRecursively(expectedOutput), describeRecursively(newDatabaseLayout.databaseDirectory()));
assertEquals(describeRecursively(expectedTxLogs), describeRecursively(newDatabaseLayout.getTransactionLogsDirectory()));
}
use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.
the class ArchiveTest method assertRoundTrips.
private void assertRoundTrips(Path oldDirectory, CompressionFormat compressionFormat) throws IOException, IncorrectFormat {
Path archive = testDirectory.file("the-archive.dump");
new Dumper().dump(oldDirectory, oldDirectory, archive, compressionFormat, alwaysFalse());
Path newDirectory = testDirectory.file("the-new-directory");
DatabaseLayout databaseLayout = DatabaseLayout.ofFlat(newDirectory);
new Loader().load(archive, databaseLayout);
assertEquals(describeRecursively(oldDirectory), describeRecursively(newDirectory));
}
use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.
the class ArchiveTest method shouldExcludeFilesMatchedByTheExclusionPredicate.
@ParameterizedTest
@EnumSource(CompressionFormat.class)
void shouldExcludeFilesMatchedByTheExclusionPredicate(CompressionFormat compressionFormat) throws IOException, IncorrectFormat {
Path directory = testDirectory.directory("a-directory");
Files.createDirectories(directory);
Files.write(directory.resolve("a-file"), new byte[0]);
Files.write(directory.resolve("another-file"), new byte[0]);
Path archive = testDirectory.file("the-archive.dump");
new Dumper().dump(directory, directory, archive, compressionFormat, path -> path.getFileName().toString().equals("another-file"));
Path txRootDirectory = testDirectory.directory("tx-root_directory");
DatabaseLayout databaseLayout = layoutWithCustomTxRoot(txRootDirectory, "the-new-directory");
new Loader().load(archive, databaseLayout);
Path expectedOutput = testDirectory.directory("expected-output");
Files.createDirectories(expectedOutput);
Files.write(expectedOutput.resolve("a-file"), new byte[0]);
assertEquals(describeRecursively(expectedOutput), describeRecursively(databaseLayout.databaseDirectory()));
}
Aggregations