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();
}
}
}
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));
}
}
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))));
}
}
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();
}
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();
}
Aggregations