use of org.neo4j.test.DbRepresentation in project neo4j by neo4j.
the class BackupCoreIT method makeSureBackupCanBePerformedFromAnyInstance.
@Test
public void makeSureBackupCanBePerformedFromAnyInstance() throws Throwable {
for (CoreClusterMember db : cluster.coreMembers()) {
// Run backup
DbRepresentation beforeChange = DbRepresentation.of(createSomeData(cluster));
String[] args = backupArguments(backupAddress(db.database()), backupsDir, "" + db.serverId());
assertEquals(0, runBackupToolFromOtherJvmToGetExitCode(clusterRule.clusterDirectory(), args));
// Add some new data
DbRepresentation afterChange = DbRepresentation.of(createSomeData(cluster));
// Verify that old data is back
DbRepresentation backupRepresentation = DbRepresentation.of(new File(backupsDir, "" + db.serverId()), getConfig());
assertEquals(beforeChange, backupRepresentation);
assertNotEquals(backupRepresentation, afterChange);
}
}
use of org.neo4j.test.DbRepresentation in project neo4j by neo4j.
the class ClusterSeedingIT method shouldRestoreBySeedingSingleMember.
@Test
@Ignore("need to seed all members for now")
public void shouldRestoreBySeedingSingleMember() throws Throwable {
// given
File backupDir = createBackupUsingAnotherCluster();
DbRepresentation before = DbRepresentation.of(backupDir);
// when
fsa.copyRecursively(backupDir, cluster.getCoreMemberById(0).storeDir());
cluster.getCoreMemberById(0).start();
Thread.sleep(2_000);
cluster.getCoreMemberById(1).start();
cluster.getCoreMemberById(2).start();
// then
dataMatchesEventually(before, cluster.coreMembers());
}
use of org.neo4j.test.DbRepresentation in project neo4j by neo4j.
the class ClusterSeedingIT method shouldRestoreBySeedingAllMembers.
@Test
public void shouldRestoreBySeedingAllMembers() throws Throwable {
// given
File backupDir = createBackupUsingAnotherCluster();
DbRepresentation before = DbRepresentation.of(backupDir);
// when
fsa.copyRecursively(backupDir, cluster.getCoreMemberById(0).storeDir());
fsa.copyRecursively(backupDir, cluster.getCoreMemberById(1).storeDir());
fsa.copyRecursively(backupDir, cluster.getCoreMemberById(2).storeDir());
cluster.start();
// then
dataMatchesEventually(before, cluster.coreMembers());
}
use of org.neo4j.test.DbRepresentation in project graphdb by neo4j-attic.
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("localhost");
backup.full(backupPath);
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);
fail("Shouldn't work");
} catch (ComException e) {
// Good
}
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);
assertEquals(furtherRepresentation, DbRepresentation.of(backupPath));
shutdownServer(server);
}
use of org.neo4j.test.DbRepresentation in project graphdb by neo4j-attic.
the class TestBackup method createInitialDataSet.
private DbRepresentation createInitialDataSet(String path) {
GraphDatabaseService db = startGraphDatabase(path);
Transaction tx = db.beginTx();
Node node = db.createNode();
node.setProperty("myKey", "myValue");
db.getReferenceNode().createRelationshipTo(node, DynamicRelationshipType.withName("KNOWS"));
tx.success();
tx.finish();
DbRepresentation result = DbRepresentation.of(db);
db.shutdown();
return result;
}
Aggregations