use of org.neo4j.test.DbRepresentation in project neo4j by neo4j.
the class Cluster method dataOnMemberEventuallyLooksLike.
/**
* Waits for {@link #DEFAULT_TIMEOUT_MS} for the <code>memberThatChanges</code> to match the contents of
* <code>memberToLookLike</code>. After calling this method, changes both in <code>memberThatChanges</code> and
* <code>memberToLookLike</code> are picked up.
*/
public static void dataOnMemberEventuallyLooksLike(CoreClusterMember memberThatChanges, CoreClusterMember memberToLookLike) throws TimeoutException, InterruptedException {
await(() -> {
try {
// We recalculate the DbRepresentation of both source and target, so changes can be picked up
DbRepresentation representationToLookLike = DbRepresentation.of(memberToLookLike.database());
DbRepresentation representationThatChanges = DbRepresentation.of(memberThatChanges.database());
return representationToLookLike.equals(representationThatChanges);
} catch (DatabaseShutdownException e) {
/*
* This can happen if the database is still in the process of starting. Yes, the naming
* of the exception is unfortunate, since it is thrown when the database lifecycle is not
* in RUNNING state and therefore signals general unavailability (e.g still starting) and not
* necessarily a database that is shutting down.
*/
}
return false;
}, DEFAULT_TIMEOUT_MS, TimeUnit.MILLISECONDS);
}
use of org.neo4j.test.DbRepresentation in project neo4j by neo4j.
the class BackupHaIT method makeSureBackupCanBePerformed.
@Test
public void makeSureBackupCanBePerformed() throws Throwable {
// Run backup
ManagedCluster cluster = clusterRule.startCluster();
DbRepresentation beforeChange = DbRepresentation.of(cluster.getMaster());
assertEquals(0, runBackupToolFromOtherJvmToGetExitCode(backupPath, backupArguments("localhost:4445", backupPath, "basic")));
// Add some new data
DbRepresentation afterChange = createSomeData(cluster.getMaster());
cluster.sync();
// Verify that backed up database can be started and compare representation
DbRepresentation backupRepresentation = DbRepresentation.of(new File(backupPath, "basic"));
assertEquals(beforeChange, backupRepresentation);
assertNotEquals(backupRepresentation, afterChange);
}
use of org.neo4j.test.DbRepresentation in project neo4j by neo4j.
the class BackupHaIT method makeSureBackupCanBePerformedFromAnyInstance.
@Test
public void makeSureBackupCanBePerformedFromAnyInstance() throws Throwable {
ManagedCluster cluster = clusterRule.startCluster();
Integer[] backupPorts = { 4445, 4446, 4447 };
for (Integer port : backupPorts) {
// Run backup
DbRepresentation beforeChange = DbRepresentation.of(cluster.getMaster());
assertEquals(0, runBackupToolFromOtherJvmToGetExitCode(backupPath, backupArguments("localhost:" + port, backupPath, "anyinstance")));
// Add some new data
DbRepresentation afterChange = createSomeData(cluster.getMaster());
cluster.sync();
// Verify that old data is back
DbRepresentation backupRepresentation = DbRepresentation.of(new File(backupPath, "anyinstance"));
assertEquals(beforeChange, backupRepresentation);
assertNotEquals(backupRepresentation, afterChange);
}
}
use of org.neo4j.test.DbRepresentation in project neo4j by neo4j.
the class IncrementalBackupTests method addMoreData2.
private DbRepresentation addMoreData2(File path) {
db = startGraphDatabase(path);
try (Transaction tx = db.beginTx()) {
Node donald = db.getNodeById(2);
Node gladstone = db.createNode();
gladstone.setProperty("name", "Gladstone");
Relationship hates = donald.createRelationshipTo(gladstone, RelationshipType.withName("HATES"));
hates.setProperty("since", 1948);
tx.success();
}
DbRepresentation result = DbRepresentation.of(db);
db.shutdown();
return result;
}
use of org.neo4j.test.DbRepresentation in project neo4j by neo4j.
the class IncrementalBackupTests method shouldNotServeTransactionsWithInvalidHighIds.
@Test
public void shouldNotServeTransactionsWithInvalidHighIds() throws Exception {
/*
* This is in effect a high level test for an edge case that happens when a relationship group is
* created and deleted in the same tx. This can end up causing an IllegalArgumentException because
* the HighIdApplier used when applying incremental updates (batch transactions in general) will postpone
* processing of added/altered record ids but deleted ids will be processed on application. This can result
* in a deleted record causing an IllegalArgumentException even though it is not the highest id in the tx.
*
* The way we try to trigger this is:
* 0. In one tx, create a node with 49 relationships, belonging to two types.
* 1. In another tx, create another relationship on that node (making it dense) and then delete all
* relationships of one type. This results in the tx state having a relationship group record that was
* created in this tx and also set to not in use.
* 2. Receipt of this tx will have the offending rel group command apply its id before the groups that are
* altered. This will try to update the high id with a value larger than what has been seen previously and
* fail the update.
* The situation is resolved by a check added in TransactionRecordState which skips the creation of such
* commands.
* Note that this problem can also happen in HA slaves.
*/
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 = createTransactiongWithWeirdRelationshipGroupRecord(serverPath);
server = startServer(serverPath, null);
backup.incremental(backupPath.getPath());
assertEquals(furtherRepresentation, getBackupDbRepresentation());
shutdownServer(server);
}
Aggregations