use of org.neo4j.causalclustering.core.CoreGraphDatabase in project neo4j by neo4j.
the class CoreReplicationIT method shouldNotAllowWritesFromAFollower.
@Test
public void shouldNotAllowWritesFromAFollower() throws Exception {
// given
cluster.awaitLeader();
CoreGraphDatabase follower = cluster.getDbWithRole(Role.FOLLOWER).database();
// when
try (Transaction tx = follower.beginTx()) {
follower.createNode();
tx.success();
fail("Should have thrown exception");
} catch (WriteOperationsNotAllowedException ignored) {
// expected
assertThat(ignored.getMessage(), containsString("No write operations are allowed"));
}
}
use of org.neo4j.causalclustering.core.CoreGraphDatabase in project neo4j by neo4j.
the class CoreReplicationIT method shouldNotAllowSchemaChangesFromAFollower.
@Test
public void shouldNotAllowSchemaChangesFromAFollower() throws Exception {
// given
cluster.awaitLeader();
CoreGraphDatabase follower = cluster.getDbWithRole(Role.FOLLOWER).database();
// when
try (Transaction tx = follower.beginTx()) {
follower.schema().constraintFor(Label.label("Foo")).assertPropertyIsUnique("name").create();
tx.success();
fail("Should have thrown exception");
} catch (WriteOperationsNotAllowedException ignored) {
// expected
assertThat(ignored.getMessage(), containsString("No write operations are allowed"));
}
}
use of org.neo4j.causalclustering.core.CoreGraphDatabase 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);
}
use of org.neo4j.causalclustering.core.CoreGraphDatabase in project neo4j by neo4j.
the class ClusterSeedingIT method createBackupUsingAnotherCluster.
private File createBackupUsingAnotherCluster() throws Exception {
backupCluster.start();
CoreGraphDatabase db = BackupCoreIT.createSomeData(backupCluster);
File backup = createBackup(db, "some-backup");
backupCluster.shutdown();
return backup;
}
use of org.neo4j.causalclustering.core.CoreGraphDatabase in project neo4j by neo4j.
the class CoreReplicationIT method countNodes.
private long countNodes(CoreClusterMember member) {
CoreGraphDatabase db = member.database();
long count;
try (Transaction tx = db.beginTx()) {
count = count(db.getAllNodes());
tx.success();
}
return count;
}
Aggregations