use of org.neo4j.test.LimitedFileSystemGraphDatabase in project neo4j by neo4j.
the class RunOutOfDiskSpaceIT method shouldPropagateIOExceptions.
@Test
public void shouldPropagateIOExceptions() throws Exception {
// Given
TransactionFailureException exceptionThrown = null;
File storeDir = testDirectory.absolutePath();
LimitedFileSystemGraphDatabase db = new LimitedFileSystemGraphDatabase(storeDir);
try (Transaction tx = db.beginTx()) {
db.createNode();
tx.success();
}
long logVersion = db.getDependencyResolver().resolveDependency(LogVersionRepository.class).getCurrentLogVersion();
db.runOutOfDiskSpaceNao();
// When
try (Transaction tx = db.beginTx()) {
db.createNode();
tx.success();
} catch (TransactionFailureException e) {
exceptionThrown = e;
} finally {
Assert.assertNotNull("Expected tx finish to throw TransactionFailureException when filesystem is full.", exceptionThrown);
assertTrue(Exceptions.contains(exceptionThrown, IOException.class));
}
// to help shutting down the db
db.somehowGainMoreDiskSpace();
db.shutdown();
PageCache pageCache = pageCacheRule.getPageCache(db.getFileSystem());
File neoStore = new File(storeDir, MetaDataStore.DEFAULT_NAME);
assertEquals(logVersion, MetaDataStore.getRecord(pageCache, neoStore, MetaDataStore.Position.LOG_VERSION));
}
use of org.neo4j.test.LimitedFileSystemGraphDatabase in project neo4j by neo4j.
the class RunOutOfDiskSpaceIT method shouldStopDatabaseWhenOutOfDiskSpace.
@Test
public void shouldStopDatabaseWhenOutOfDiskSpace() throws Exception {
// Given
TransactionFailureException expectedCommitException = null;
TransactionFailureException expectedStartException = null;
File storeDir = testDirectory.absolutePath();
LimitedFileSystemGraphDatabase db = cleanup.add(new LimitedFileSystemGraphDatabase(storeDir));
try (Transaction tx = db.beginTx()) {
db.createNode();
tx.success();
}
long logVersion = db.getDependencyResolver().resolveDependency(LogVersionRepository.class).getCurrentLogVersion();
db.runOutOfDiskSpaceNao();
try (Transaction tx = db.beginTx()) {
db.createNode();
tx.success();
} catch (TransactionFailureException e) {
expectedCommitException = e;
} finally {
Assert.assertNotNull("Expected tx finish to throw TransactionFailureException when filesystem is full.", expectedCommitException);
}
// When
try (Transaction transaction = db.beginTx()) {
fail("Expected tx begin to throw TransactionFailureException when tx manager breaks.");
} catch (TransactionFailureException e) {
expectedStartException = e;
} finally {
Assert.assertNotNull("Expected tx begin to throw TransactionFailureException when tx manager breaks.", expectedStartException);
}
// Then
// to help shutting down the db
db.somehowGainMoreDiskSpace();
db.shutdown();
PageCache pageCache = pageCacheRule.getPageCache(db.getFileSystem());
File neoStore = new File(storeDir, MetaDataStore.DEFAULT_NAME);
assertEquals(logVersion, MetaDataStore.getRecord(pageCache, neoStore, MetaDataStore.Position.LOG_VERSION));
}
Aggregations