use of org.neo4j.kernel.ha.HighlyAvailableGraphDatabase in project neo4j by neo4j.
the class TransactionConstraintsIT method startTxAsSlaveAndFinishItAfterHavingSwitchedToMasterShouldNotSucceed.
@Test
public void startTxAsSlaveAndFinishItAfterHavingSwitchedToMasterShouldNotSucceed() throws Exception {
// GIVEN
GraphDatabaseService db = cluster.getAnySlave(getSlaveOnlySlave());
// WHEN
Transaction tx = db.beginTx();
try {
db.createNode().setProperty("name", "slave");
tx.success();
} finally {
HighlyAvailableGraphDatabase oldMaster = cluster.getMaster();
cluster.shutdown(oldMaster);
// Wait for new master
cluster.await(masterAvailable(oldMaster));
assertFinishGetsTransactionFailure(tx);
}
// THEN
assertEquals(db, cluster.getMaster());
// to prevent a deadlock scenario which occurs if this test exists (and @After starts)
// before the db has recovered from its KERNEL_PANIC
awaitFullyOperational(db);
}
use of org.neo4j.kernel.ha.HighlyAvailableGraphDatabase in project neo4j by neo4j.
the class TransactionConstraintsIT method slaveShouldNotBeAbleToProduceAnInvalidTransaction.
@Test
public void slaveShouldNotBeAbleToProduceAnInvalidTransaction() throws Exception {
// GIVEN
HighlyAvailableGraphDatabase aSlave = cluster.getAnySlave();
Node node = createMiniTree(aSlave);
Transaction tx = aSlave.beginTx();
// Deleting this node isn't allowed since it still has relationships
node.delete();
tx.success();
// EXPECT
exception.expect(ConstraintViolationException.class);
// WHEN
tx.close();
}
use of org.neo4j.kernel.ha.HighlyAvailableGraphDatabase in project neo4j by neo4j.
the class TestClusterClientPadding method additionalClusterClientCanHelpBreakTiesWhenMasterFails.
@Test
public void additionalClusterClientCanHelpBreakTiesWhenMasterFails() throws Throwable {
HighlyAvailableGraphDatabase sittingMaster = cluster.getMaster();
cluster.fail(sittingMaster);
cluster.await(masterAvailable(sittingMaster));
}
use of org.neo4j.kernel.ha.HighlyAvailableGraphDatabase in project neo4j by neo4j.
the class HACountsPropagationTest method shouldPropagateRelationshipCountsInHA.
@Test
public void shouldPropagateRelationshipCountsInHA() throws Throwable {
ManagedCluster cluster = clusterRule.startCluster();
HighlyAvailableGraphDatabase master = cluster.getMaster();
try (Transaction tx = master.beginTx()) {
Node left = master.createNode();
Node right = master.createNode(Label.label("A"));
left.createRelationshipTo(right, RelationshipType.withName("Type"));
tx.success();
}
cluster.sync();
for (HighlyAvailableGraphDatabase db : cluster.getAllMembers()) {
CountsTracker counts = counts(db);
assertEquals(1, counts.relationshipCount(-1, -1, -1, newDoubleLongRegister()).readSecond());
assertEquals(1, counts.relationshipCount(-1, -1, 0, newDoubleLongRegister()).readSecond());
assertEquals(1, counts.relationshipCount(-1, 0, -1, newDoubleLongRegister()).readSecond());
assertEquals(1, counts.relationshipCount(-1, 0, 0, newDoubleLongRegister()).readSecond());
}
}
use of org.neo4j.kernel.ha.HighlyAvailableGraphDatabase in project neo4j by neo4j.
the class HACountsPropagationTest method shouldPropagateNodeCountsInHA.
@Test
public void shouldPropagateNodeCountsInHA() throws Throwable {
ManagedCluster cluster = clusterRule.startCluster();
HighlyAvailableGraphDatabase master = cluster.getMaster();
try (Transaction tx = master.beginTx()) {
master.createNode();
master.createNode(Label.label("A"));
tx.success();
}
cluster.sync();
for (HighlyAvailableGraphDatabase db : cluster.getAllMembers()) {
CountsTracker counts = counts(db);
assertEquals(2, counts.nodeCount(-1, newDoubleLongRegister()).readSecond());
assertEquals(1, counts.nodeCount(0, /* A */
newDoubleLongRegister()).readSecond());
}
}
Aggregations