Search in sources :

Example 11 with EphemeralFileSystemAbstraction

use of org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction in project neo4j by neo4j.

the class TestGraphProperties method twoUncleanInARow.

@Test
public void twoUncleanInARow() throws Exception {
    File storeDir = new File("dir");
    try (EphemeralFileSystemAbstraction snapshot = produceUncleanStore(fs.get(), storeDir)) {
        try (EphemeralFileSystemAbstraction snapshot2 = produceUncleanStore(snapshot, storeDir)) {
            GraphDatabaseAPI db = (GraphDatabaseAPI) new TestGraphDatabaseFactory().setFileSystem(produceUncleanStore(snapshot2, storeDir)).newImpermanentDatabase(storeDir);
            assertThat(properties(db), inTx(db, hasProperty("prop").withValue("Some value")));
            db.shutdown();
        }
    }
}
Also used : GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) EphemeralFileSystemAbstraction(org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) File(java.io.File) Test(org.junit.Test)

Example 12 with EphemeralFileSystemAbstraction

use of org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction in project neo4j by neo4j.

the class TestStoreAccess method openingThroughStoreAccessShouldNotTriggerRecovery.

@Test
public void openingThroughStoreAccessShouldNotTriggerRecovery() throws Exception {
    try (EphemeralFileSystemAbstraction snapshot = produceUncleanStore()) {
        assertTrue("Store should be unclean", isUnclean(snapshot));
        File messages = new File(storeDir, "debug.log");
        snapshot.deleteFile(messages);
        PageCache pageCache = pageCacheRule.getPageCache(snapshot);
        new StoreAccess(snapshot, pageCache, storeDir).initialize().close();
        assertTrue("Store should be unclean", isUnclean(snapshot));
    }
}
Also used : EphemeralFileSystemAbstraction(org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction) File(java.io.File) PageCache(org.neo4j.io.pagecache.PageCache) Test(org.junit.Test)

Example 13 with EphemeralFileSystemAbstraction

use of org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction in project neo4j by neo4j.

the class LegacyLogsTest method shouldRenameFiles.

@Test
public void shouldRenameFiles() throws Exception {
    // given
    try (EphemeralFileSystemAbstraction fs = new EphemeralFileSystemAbstraction()) {
        fs.mkdirs(storeDir);
        final File unrelated = new File(storeDir, "unrelated");
        final List<File> files = Arrays.asList(new File(storeDir, "active_tx_log"), new File(storeDir, "tm_tx_log.v0"), new File(storeDir, "tm_tx_log.v1"), new File(storeDir, "nioneo_logical.log.1"), new File(storeDir, "nioneo_logical.log.2"), new File(storeDir, getLegacyLogFilename(1)), new File(storeDir, getLegacyLogFilename(2)), unrelated);
        for (File file : files) {
            fs.create(file).close();
        }
        // when
        new LegacyLogs(fs, reader, writer).renameLogFiles(storeDir);
        // then
        final Set<File> expected = new HashSet<>(Arrays.asList(unrelated, new File(storeDir, getLogFilenameForVersion(1)), new File(storeDir, getLogFilenameForVersion(2))));
        assertEquals(expected, new HashSet<>(Arrays.asList(fs.listFiles(storeDir))));
    }
}
Also used : EphemeralFileSystemAbstraction(org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction) File(java.io.File) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 14 with EphemeralFileSystemAbstraction

use of org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction in project neo4j by neo4j.

the class PageCacheTest method mustCloseFileChannelWhenTheLastHandleIsUnmapped.

@Test(timeout = SHORT_TIMEOUT_MILLIS)
public void mustCloseFileChannelWhenTheLastHandleIsUnmapped() throws Exception {
    assumeTrue("This depends on EphemeralFSA specific features", fs.getClass() == EphemeralFileSystemAbstraction.class);
    PageCache cache = createStandardPageCache();
    PagedFile a = cache.map(file("a"), filePageSize);
    PagedFile b = cache.map(file("a"), filePageSize);
    a.close();
    b.close();
    ((EphemeralFileSystemAbstraction) fs).assertNoOpenFiles();
}
Also used : AdversarialPagedFile(org.neo4j.adversaries.pagecache.AdversarialPagedFile) EphemeralFileSystemAbstraction(org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction) Test(org.junit.Test)

Example 15 with EphemeralFileSystemAbstraction

use of org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction in project neo4j by neo4j.

the class RecordStoreConsistentReadTest method setUp.

@Before
public void setUp() {
    fs = new EphemeralFileSystemAbstraction();
    nextReadIsInconsistent = new AtomicBoolean();
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) EphemeralFileSystemAbstraction(org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction) Before(org.junit.Before)

Aggregations

EphemeralFileSystemAbstraction (org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction)54 Test (org.junit.Test)37 File (java.io.File)27 TestGraphDatabaseFactory (org.neo4j.test.TestGraphDatabaseFactory)10 StoreChannel (org.neo4j.io.fs.StoreChannel)8 IOException (java.io.IOException)7 AdversarialFileSystemAbstraction (org.neo4j.adversaries.fs.AdversarialFileSystemAbstraction)7 Before (org.junit.Before)6 CountingAdversary (org.neo4j.adversaries.CountingAdversary)6 Transaction (org.neo4j.graphdb.Transaction)6 ByteBuffer (java.nio.ByteBuffer)5 MethodGuardedAdversary (org.neo4j.adversaries.MethodGuardedAdversary)5 StateRecoveryManager (org.neo4j.causalclustering.core.state.StateRecoveryManager)5 EndOfStreamException (org.neo4j.causalclustering.messaging.EndOfStreamException)5 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 Node (org.neo4j.graphdb.Node)4 SelectiveFileSystemAbstraction (org.neo4j.graphdb.mockfs.SelectiveFileSystemAbstraction)4 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)4 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)4