Search in sources :

Example 11 with DisabledOnOs

use of org.junit.jupiter.api.condition.DisabledOnOs in project neo4j by neo4j.

the class ConfigTest method shouldNotEvaluateK8sConfDirWithIncorrectFilePermission.

@Test
@DisabledOnOs({ OS.WINDOWS })
void shouldNotEvaluateK8sConfDirWithIncorrectFilePermission() throws IOException {
    // Given
    Path confDir = createK8sStyleConfigDir(PosixFilePermissions.fromString("rw-----w-"));
    Config.Builder builder = Config.newBuilder().allowCommandExpansion().addSettingsClass(TestSettings.class).fromFile(confDir);
    // Then
    String msg = assertThrows(IllegalArgumentException.class, builder::build).getMessage();
    String expectedErrorMessage = "does not have the correct file permissions";
    assertThat(msg).contains(expectedErrorMessage);
}
Also used : Path(java.nio.file.Path) DisabledOnOs(org.junit.jupiter.api.condition.DisabledOnOs) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 12 with DisabledOnOs

use of org.junit.jupiter.api.condition.DisabledOnOs in project neo4j by neo4j.

the class TestGrowingFileMemoryMapping method shouldGrowAFileWhileContinuingToMemoryMapNewRegions.

@Test
@DisabledOnOs(OS.WINDOWS)
void shouldGrowAFileWhileContinuingToMemoryMapNewRegions() {
    // given
    final int NUMBER_OF_RECORDS = 1000000;
    Config config = Config.defaults();
    DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(testDirectory.getFileSystem(), immediate(), databaseLayout.getDatabaseName());
    StoreFactory storeFactory = new StoreFactory(databaseLayout, config, idGeneratorFactory, pageCache, testDirectory.getFileSystem(), NullLogProvider.getInstance(), NULL, writable());
    NeoStores neoStores = storeFactory.openAllNeoStores(true);
    NodeStore nodeStore = neoStores.getNodeStore();
    // when
    int iterations = 2 * NUMBER_OF_RECORDS;
    long startingId = nodeStore.nextId(CursorContext.NULL);
    long nodeId = startingId;
    for (int i = 0; i < iterations; i++) {
        NodeRecord record = new NodeRecord(nodeId).initialize(false, 0, false, i, 0);
        record.setInUse(true);
        nodeStore.updateRecord(record, CursorContext.NULL);
        nodeId = nodeStore.nextId(CursorContext.NULL);
    }
    // then
    NodeRecord record = new NodeRecord(0).initialize(false, 0, false, 0, 0);
    for (int i = 0; i < iterations; i++) {
        record.setId(startingId + i);
        nodeStore.getRecord(i, record, NORMAL, CursorContext.NULL);
        assertTrue(record.inUse(), "record[" + i + "] should be in use");
        assertThat(record.getNextRel()).as("record[" + i + "] should have nextRelId of " + i).isEqualTo(i);
    }
    neoStores.close();
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) Config(org.neo4j.configuration.Config) DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory) DisabledOnOs(org.junit.jupiter.api.condition.DisabledOnOs) Test(org.junit.jupiter.api.Test)

Example 13 with DisabledOnOs

use of org.junit.jupiter.api.condition.DisabledOnOs 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));
}
Also used : Path(java.nio.file.Path) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) DisabledOnOs(org.junit.jupiter.api.condition.DisabledOnOs) Test(org.junit.jupiter.api.Test)

Example 14 with DisabledOnOs

use of org.junit.jupiter.api.condition.DisabledOnOs in project neo4j by neo4j.

the class DumperTest method shouldGiveAClearErrorMessageIfTheArchivesParentDirectoryIsNotWritable.

@Test
@DisabledOnOs(OS.WINDOWS)
@DisabledForRoot
void shouldGiveAClearErrorMessageIfTheArchivesParentDirectoryIsNotWritable() throws IOException {
    Path directory = testDirectory.directory("a-directory");
    Path archive = testDirectory.file("subdir").resolve("the-archive.dump");
    Files.createDirectories(archive.getParent());
    try (Closeable ignored = TestUtils.withPermissions(archive.getParent(), emptySet())) {
        AccessDeniedException exception = assertThrows(AccessDeniedException.class, () -> new Dumper().dump(directory, directory, archive, GZIP, Predicates.alwaysFalse()));
        assertEquals(archive.getParent().toString(), exception.getMessage());
    }
}
Also used : Path(java.nio.file.Path) AccessDeniedException(java.nio.file.AccessDeniedException) Closeable(java.io.Closeable) DisabledOnOs(org.junit.jupiter.api.condition.DisabledOnOs) Test(org.junit.jupiter.api.Test) DisabledForRoot(org.neo4j.test.extension.DisabledForRoot)

Example 15 with DisabledOnOs

use of org.junit.jupiter.api.condition.DisabledOnOs in project neo4j by neo4j.

the class SingleFilePageSwapperTest method fileMustRemainLockedEvenIfChannelIsClosedByStrayInterrupt.

@Test
@DisabledOnOs(OS.WINDOWS)
void fileMustRemainLockedEvenIfChannelIsClosedByStrayInterrupt() 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);
        Thread.currentThread().interrupt();
        pageSwapper.force();
        assertThrows(OverlappingFileLockException.class, channel::tryLock);
    } finally {
        pageSwapper.close();
    }
}
Also used : Path(java.nio.file.Path) PageSwapperFactory(org.neo4j.io.pagecache.PageSwapperFactory) StoreChannel(org.neo4j.io.fs.StoreChannel) DelegatingStoreChannel(org.neo4j.io.fs.DelegatingStoreChannel) PageSwapper(org.neo4j.io.pagecache.PageSwapper) DisabledOnOs(org.junit.jupiter.api.condition.DisabledOnOs) PageSwapperTest(org.neo4j.io.pagecache.PageSwapperTest) Test(org.junit.jupiter.api.Test)

Aggregations

DisabledOnOs (org.junit.jupiter.api.condition.DisabledOnOs)85 Test (org.junit.jupiter.api.Test)78 Path (java.nio.file.Path)38 File (java.io.File)24 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)15 PathsBaseTest (org.assertj.core.internal.PathsBaseTest)12 AssertionsUtil.expectAssertionError (org.assertj.core.util.AssertionsUtil.expectAssertionError)11 PosixFilePermission (java.nio.file.attribute.PosixFilePermission)6 PageSwapperFactory (org.neo4j.io.pagecache.PageSwapperFactory)6 PageSwapperTest (org.neo4j.io.pagecache.PageSwapperTest)6 CommandBuilder (com.thoughtworks.go.domain.builder.CommandBuilder)5 DelegatingStoreChannel (org.neo4j.io.fs.DelegatingStoreChannel)5 StoreChannel (org.neo4j.io.fs.StoreChannel)5 DisabledForRoot (org.neo4j.test.extension.DisabledForRoot)5 Closeable (java.io.Closeable)4 URI (java.net.URI)4 FileUtils.writeByteArrayToFile (org.apache.commons.io.FileUtils.writeByteArrayToFile)4 ShouldBeFile.shouldBeFile (org.assertj.core.error.ShouldBeFile.shouldBeFile)4 FilesBaseTest (org.assertj.core.internal.FilesBaseTest)4 Files.newFile (org.assertj.core.util.Files.newFile)4