use of org.neo4j.test.DbRepresentation in project neo4j by neo4j.
the class TestBackup method addMoreData.
private DbRepresentation addMoreData(File path) {
GraphDatabaseService db = startGraphDatabase(path, false);
DbRepresentation representation;
try (Transaction tx = db.beginTx()) {
Node node = db.createNode();
node.setProperty("backup", "Is great");
db.createNode().createRelationshipTo(node, RelationshipType.withName("LOVES"));
tx.success();
} finally {
representation = DbRepresentation.of(db);
db.shutdown();
}
return representation;
}
use of org.neo4j.test.DbRepresentation in project neo4j by neo4j.
the class IncrementalBackupTests method shouldDoIncrementalBackup.
@Test
public void shouldDoIncrementalBackup() throws Exception {
DbRepresentation initialDataSetRepresentation = createInitialDataSet(serverPath);
server = startServer(serverPath, "127.0.0.1:6362");
OnlineBackup backup = OnlineBackup.from("127.0.0.1");
backup.full(backupPath.getPath());
assertEquals(initialDataSetRepresentation, getBackupDbRepresentation());
shutdownServer(server);
DbRepresentation furtherRepresentation = addMoreData2(serverPath);
server = startServer(serverPath, null);
backup.incremental(backupPath.getPath());
assertEquals(furtherRepresentation, getBackupDbRepresentation());
shutdownServer(server);
}
use of org.neo4j.test.DbRepresentation in project neo4j by neo4j.
the class IncrementalBackupTests method createInitialDataSet.
private DbRepresentation createInitialDataSet(File path) {
db = startGraphDatabase(path);
try (Transaction tx = db.beginTx()) {
db.createNode().setProperty("name", "Goofy");
Node donald = db.createNode();
donald.setProperty("name", "Donald");
Node daisy = db.createNode();
daisy.setProperty("name", "Daisy");
Relationship knows = donald.createRelationshipTo(daisy, RelationshipType.withName("LOVES"));
knows.setProperty("since", 1940);
tx.success();
}
DbRepresentation result = DbRepresentation.of(db);
db.shutdown();
return result;
}
use of org.neo4j.test.DbRepresentation in project neo4j by neo4j.
the class ReadReplicaReplicationIT method aReadReplicShouldBeAbleToRejoinTheCluster.
@Test
public void aReadReplicShouldBeAbleToRejoinTheCluster() throws Exception {
int readReplicaId = 4;
Cluster cluster = clusterRule.withNumberOfReadReplicas(0).startCluster();
cluster.coreTx(createSomeData);
cluster.addReadReplicaWithId(readReplicaId).start();
// let's spend some time by adding more data
cluster.coreTx(createSomeData);
awaitEx(() -> readReplicasUpToDateAsTheLeader(cluster.awaitLeader(), cluster.readReplicas()), 1, TimeUnit.MINUTES);
cluster.removeReadReplicaWithMemberId(readReplicaId);
// let's spend some time by adding more data
cluster.coreTx(createSomeData);
cluster.addReadReplicaWithId(readReplicaId).start();
awaitEx(() -> readReplicasUpToDateAsTheLeader(cluster.awaitLeader(), cluster.readReplicas()), 1, TimeUnit.MINUTES);
Function<ClusterMember, DbRepresentation> toRep = db -> DbRepresentation.of(db.database());
Set<DbRepresentation> dbs = cluster.coreMembers().stream().map(toRep).collect(toSet());
dbs.addAll(cluster.readReplicas().stream().map(toRep).collect(toSet()));
cluster.shutdown();
assertEquals(1, dbs.size());
}
use of org.neo4j.test.DbRepresentation in project neo4j by neo4j.
the class BackupReadReplicaIT method makeSureBackupCanBePerformed.
@Test
public void makeSureBackupCanBePerformed() throws Throwable {
// Run backup
CoreGraphDatabase leader = createSomeData(cluster);
ReadReplicaGraphDatabase readReplica = cluster.findAnyReadReplica().database();
awaitEx(() -> readReplicasUpToDateAsTheLeader(leader, readReplica), 1, TimeUnit.MINUTES);
DbRepresentation beforeChange = DbRepresentation.of(readReplica);
String backupAddress = this.backupAddress(readReplica);
String[] args = backupArguments(backupAddress, backupPath, "readreplica");
assertEquals(0, runBackupToolFromOtherJvmToGetExitCode(clusterRule.clusterDirectory(), args));
// Add some new data
DbRepresentation afterChange = DbRepresentation.of(createSomeData(cluster));
// Verify that backed up database can be started and compare representation
DbRepresentation backupRepresentation = DbRepresentation.of(new File(backupPath, "readreplica"), getConfig());
assertEquals(beforeChange, backupRepresentation);
assertNotEquals(backupRepresentation, afterChange);
}
Aggregations