use of org.junit.jupiter.api.condition.DisabledOnOs in project neo4j by neo4j.
the class SingleFilePageSwapperTest method creatingSwapperForExternallyLockedFileMustThrow.
@Test
@DisabledOnOs(OS.WINDOWS)
void creatingSwapperForExternallyLockedFileMustThrow() throws Exception {
PageSwapperFactory factory = createSwapperFactory(fileSystem);
Path file = testDir.file("file");
((StoreChannel) fileSystem.write(file)).close();
var process = start(pb -> pb.directory(Path.of("target/test-classes").toAbsolutePath().toFile()), LockThisFileProgram.class.getCanonicalName(), file.toAbsolutePath().toString());
BufferedReader stdout = new BufferedReader(new InputStreamReader(process.getInputStream()));
InputStream stderr = process.getErrorStream();
try {
assumeTrue(LockThisFileProgram.LOCKED_OUTPUT.equals(stdout.readLine()));
} catch (Throwable e) {
int b = stderr.read();
while (b != -1) {
System.err.write(b);
b = stderr.read();
}
System.err.flush();
int exitCode = process.waitFor();
System.out.println("exitCode = " + exitCode);
throw e;
}
try {
assertThrows(FileLockException.class, () -> createSwapper(factory, file, 4, NO_CALLBACK, true));
} finally {
process.getOutputStream().write(0);
process.getOutputStream().flush();
process.waitFor();
}
}
use of org.junit.jupiter.api.condition.DisabledOnOs in project neo4j by neo4j.
the class SingleFilePageSwapperTest method creatingSwapperForInternallyLockedFileMustThrow.
@Test
@DisabledOnOs(OS.WINDOWS)
void creatingSwapperForInternallyLockedFileMustThrow() throws Exception {
PageSwapperFactory factory = createSwapperFactory(fileSystem);
Path file = testDir.file("file");
StoreFileChannel channel = fileSystem.write(file);
try (FileLock fileLock = channel.tryLock()) {
assertThat(fileLock).isNotNull();
assertThrows(FileLockException.class, () -> createSwapper(factory, file, 4, NO_CALLBACK, true));
}
}
use of org.junit.jupiter.api.condition.DisabledOnOs in project neo4j by neo4j.
the class SingleFilePageSwapperTest method creatingSwapperForFileMustTakeLockOnFile.
/**
* The OverlappingFileLockException is thrown when tryLock is called on the same file *in the same JVM*.
*/
@Test
@DisabledOnOs(OS.WINDOWS)
void creatingSwapperForFileMustTakeLockOnFile() throws Exception {
PageSwapperFactory factory = createSwapperFactory(fileSystem);
Path file = testDir.file("file");
((StoreChannel) fileSystem.write(file)).close();
PageSwapper pageSwapper = createSwapper(factory, file, 4, NO_CALLBACK, false);
try {
StoreChannel channel = fileSystem.write(file);
assertThrows(OverlappingFileLockException.class, channel::tryLock);
} finally {
pageSwapper.close();
}
}
use of org.junit.jupiter.api.condition.DisabledOnOs 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());
}
}
}
use of org.junit.jupiter.api.condition.DisabledOnOs in project neo4j by neo4j.
the class LoaderTest method shouldGiveAClearErrorMessageIfTheTxLogsParentDirectoryIsNotWritable.
@Test
@DisabledOnOs(OS.WINDOWS)
@DisabledForRoot
void shouldGiveAClearErrorMessageIfTheTxLogsParentDirectoryIsNotWritable() throws IOException {
Path archive = testDirectory.file("the-archive.dump");
Path txLogsDirectory = testDirectory.directory("subdir", "txLogs");
Config config = Config.newBuilder().set(neo4j_home, testDirectory.homePath()).set(transaction_logs_root_path, txLogsDirectory.toAbsolutePath()).set(default_database, "destination").build();
DatabaseLayout databaseLayout = DatabaseLayout.of(config);
Path txLogsRoot = databaseLayout.getTransactionLogsDirectory().getParent();
try (Closeable ignored = withPermissions(txLogsRoot, emptySet())) {
AccessDeniedException exception = assertThrows(AccessDeniedException.class, () -> new Loader().load(archive, databaseLayout));
assertEquals(txLogsRoot.toString(), exception.getMessage());
}
}
Aggregations