Search in sources :

Example 1 with ClusterRule

use of org.neo4j.test.causalclustering.ClusterRule in project neo4j by neo4j.

the class ReadReplicaHierarchicalCatchupIT method shouldCatchupThroughHierarchy.

@Test
public void shouldCatchupThroughHierarchy() throws Throwable {
    clusterRule = clusterRule.withInstanceReadReplicaParam(CausalClusteringSettings.server_groups, id -> serverGroups.get(id)).withInstanceCoreParam(CausalClusteringSettings.server_groups, id -> serverGroups.get(id));
    // given
    Cluster cluster = clusterRule.startCluster();
    int numberOfNodesToCreate = 100;
    cluster.coreTx((db, tx) -> {
        db.schema().constraintFor(label("Foo")).assertPropertyIsUnique("foobar").create();
        tx.success();
    });
    // 0, 1, 2 are core instances
    createLabelledNodesWithProperty(cluster, numberOfNodesToCreate, label("Foo"), () -> Pair.of("foobar", String.format("baz_bat%s", UUID.randomUUID())));
    // 3, 4 are other DCs
    ReadReplica east3 = cluster.addReadReplicaWithId(3);
    east3.start();
    ReadReplica west4 = cluster.addReadReplicaWithId(4);
    west4.start();
    checkDataHasReplicatedToReadReplicas(cluster, numberOfNodesToCreate);
    for (CoreClusterMember coreClusterMember : cluster.coreMembers()) {
        coreClusterMember.stopCatchupServer();
    }
    // 5, 6 are other DCs
    ReadReplica east5 = cluster.addReadReplicaWithId(5);
    east5.setUpstreamDatabaseSelectionStrategy("connect-within-data-center");
    east5.start();
    ReadReplica west6 = cluster.addReadReplicaWithId(6);
    west6.setUpstreamDatabaseSelectionStrategy("connect-within-data-center");
    west6.start();
    checkDataHasReplicatedToReadReplicas(cluster, numberOfNodesToCreate);
}
Also used : Iterables.count(org.neo4j.helpers.collection.Iterables.count) CausalClusteringSettings(org.neo4j.causalclustering.core.CausalClusteringSettings) Test(org.junit.Test) HashMap(java.util.HashMap) UUID(java.util.UUID) ClusterRule(org.neo4j.test.causalclustering.ClusterRule) Label.label(org.neo4j.graphdb.Label.label) Pair(org.neo4j.helpers.collection.Pair) DataCreator.createLabelledNodesWithProperty(org.neo4j.causalclustering.helpers.DataCreator.createLabelledNodesWithProperty) Cluster(org.neo4j.causalclustering.discovery.Cluster) Rule(org.junit.Rule) HazelcastDiscoveryServiceFactory(org.neo4j.causalclustering.discovery.HazelcastDiscoveryServiceFactory) Map(java.util.Map) Is.is(org.hamcrest.core.Is.is) CoreClusterMember(org.neo4j.causalclustering.discovery.CoreClusterMember) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) ReadReplica(org.neo4j.causalclustering.discovery.ReadReplica) Before(org.junit.Before) ReadReplicaToReadReplicaCatchupIT.checkDataHasReplicatedToReadReplicas(org.neo4j.causalclustering.scenarios.ReadReplicaToReadReplicaCatchupIT.checkDataHasReplicatedToReadReplicas) ReadReplica(org.neo4j.causalclustering.discovery.ReadReplica) CoreClusterMember(org.neo4j.causalclustering.discovery.CoreClusterMember) Cluster(org.neo4j.causalclustering.discovery.Cluster) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 UUID (java.util.UUID)1 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)1 Is.is (org.hamcrest.core.Is.is)1 Before (org.junit.Before)1 Rule (org.junit.Rule)1 Test (org.junit.Test)1 CausalClusteringSettings (org.neo4j.causalclustering.core.CausalClusteringSettings)1 Cluster (org.neo4j.causalclustering.discovery.Cluster)1 CoreClusterMember (org.neo4j.causalclustering.discovery.CoreClusterMember)1 HazelcastDiscoveryServiceFactory (org.neo4j.causalclustering.discovery.HazelcastDiscoveryServiceFactory)1 ReadReplica (org.neo4j.causalclustering.discovery.ReadReplica)1 DataCreator.createLabelledNodesWithProperty (org.neo4j.causalclustering.helpers.DataCreator.createLabelledNodesWithProperty)1 ReadReplicaToReadReplicaCatchupIT.checkDataHasReplicatedToReadReplicas (org.neo4j.causalclustering.scenarios.ReadReplicaToReadReplicaCatchupIT.checkDataHasReplicatedToReadReplicas)1 Label.label (org.neo4j.graphdb.Label.label)1 Iterables.count (org.neo4j.helpers.collection.Iterables.count)1 Pair (org.neo4j.helpers.collection.Pair)1 ClusterRule (org.neo4j.test.causalclustering.ClusterRule)1