use of org.neo4j.test.DbRepresentation in project neo4j by neo4j.
the class TestReadOnlyNeo4j method testSimple.
@Test
public void testSimple() {
DbRepresentation someData = createSomeData();
GraphDatabaseService readGraphDb = new TestGraphDatabaseFactory().setFileSystem(new UncloseableDelegatingFileSystemAbstraction(fs.get())).newImpermanentDatabaseBuilder(PATH).setConfig(GraphDatabaseSettings.read_only, Settings.TRUE).newGraphDatabase();
assertEquals(someData, DbRepresentation.of(readGraphDb));
try (Transaction tx = readGraphDb.beginTx()) {
readGraphDb.createNode();
tx.success();
} catch (WriteOperationsNotAllowedException e) {
// good
}
readGraphDb.shutdown();
}
use of org.neo4j.test.DbRepresentation in project graphdb by neo4j-attic.
the class TestBackupToolHa method makeSureBackupCanBePerformedFromCluster.
@Test
public void makeSureBackupCanBePerformedFromCluster() throws Exception {
if (osIsWindows())
return;
assertEquals(0, runBackupToolFromOtherJvmToGetExitCode("-full", "-from", "ha://localhost:2181", "-to", BACKUP_PATH));
assertEquals(representation, DbRepresentation.of(BACKUP_PATH));
DbRepresentation newRepresentation = createSomeData(instances.get(2));
assertEquals(0, runBackupToolFromOtherJvmToGetExitCode("-incremental", "-from", "ha://localhost:2182", "-to", BACKUP_PATH));
assertEquals(newRepresentation, DbRepresentation.of(BACKUP_PATH));
}
use of org.neo4j.test.DbRepresentation in project neo4j by neo4j.
the class TestBackup method fullThenIncremental.
@Test
public void fullThenIncremental() throws Exception {
DbRepresentation initialDataSetRepresentation = createInitialDataSet(serverPath);
ServerInterface server = startServer(serverPath);
OnlineBackup backup = OnlineBackup.from("127.0.0.1");
backup.full(backupPath.getPath());
assertTrue("Should be consistent", backup.isConsistent());
assertEquals(initialDataSetRepresentation, getDbRepresentation());
shutdownServer(server);
DbRepresentation furtherRepresentation = addMoreData(serverPath);
server = startServer(serverPath);
backup.incremental(backupPath.getPath());
assertTrue("Should be consistent", backup.isConsistent());
assertEquals(furtherRepresentation, getDbRepresentation());
shutdownServer(server);
}
use of org.neo4j.test.DbRepresentation in project neo4j by neo4j.
the class TestBackup method shouldIncrementallyBackupDenseNodes.
@Test
public void shouldIncrementallyBackupDenseNodes() throws Exception {
GraphDatabaseService db = startGraphDatabase(serverPath, true);
try {
createInitialDataset(db);
OnlineBackup backup = OnlineBackup.from("127.0.0.1");
backup.full(backupPath.getPath());
DbRepresentation representation = addLotsOfData(db);
backup.incremental(backupPath.getPath());
assertEquals(representation, getDbRepresentation());
} finally {
db.shutdown();
}
}
use of org.neo4j.test.DbRepresentation in project neo4j by neo4j.
the class TestBackup method makeSureStoreIdIsEnforced.
@Test
public void makeSureStoreIdIsEnforced() throws Exception {
// Create data set X on server A
DbRepresentation initialDataSetRepresentation = createInitialDataSet(serverPath);
ServerInterface server = startServer(serverPath);
// Grab initial backup from server A
OnlineBackup backup = OnlineBackup.from("127.0.0.1");
backup.full(backupPath.getPath());
assertTrue("Should be consistent", backup.isConsistent());
assertEquals(initialDataSetRepresentation, DbRepresentation.of(backupPath));
shutdownServer(server);
// Create data set X+Y on server B
createInitialDataSet(otherServerPath);
addMoreData(otherServerPath);
server = startServer(otherServerPath);
// Data should be OK, but store id check should prevent that.
try {
backup.incremental(backupPath.getPath());
fail("Shouldn't work");
} catch (RuntimeException e) {
assertThat(e.getCause(), instanceOf(MismatchingStoreIdException.class));
}
shutdownServer(server);
// Just make sure incremental backup can be received properly from
// server A, even after a failed attempt from server B
DbRepresentation furtherRepresentation = addMoreData(serverPath);
server = startServer(serverPath);
backup.incremental(backupPath.getPath());
assertTrue("Should be consistent", backup.isConsistent());
assertEquals(furtherRepresentation, DbRepresentation.of(backupPath));
shutdownServer(server);
}
Aggregations