Exemple #1
0
def simple_replica(topo, new_suffixes, request):
    """Enable simple multi-supplier replication"""

    supplier1 = topo.ins["standalone1"]
    supplier2 = topo.ins["standalone2"]

    log.info("Enable two supplier replicas")
    replicas_m1 = Replicas(supplier1)
    replica_m1 = replicas_m1.enable(suffix=NEW_SUFFIX,
                                    role=ReplicaRole.SUPPLIER,
                                    replicaID=REPLICA_SUPPLIER_ID)
    replicas_m2 = Replicas(supplier2)
    replica_m2 = replicas_m2.enable(suffix=NEW_SUFFIX,
                                    role=ReplicaRole.SUPPLIER,
                                    replicaID=REPLICA_SUPPLIER_ID + 1)

    log.info("Create agreements between the instances")
    supplier1.agreement.create(suffix=NEW_SUFFIX,
                               host=supplier2.host,
                               port=supplier2.port)
    supplier2.agreement.create(suffix=NEW_SUFFIX,
                               host=supplier1.host,
                               port=supplier1.port)

    log.info("Test replication")
    replicas_m1.test(NEW_SUFFIX, supplier2)

    def fin():
        replicas_m1.disable(NEW_SUFFIX)
        replicas_m2.disable(NEW_SUFFIX)

    request.addfinalizer(fin)

    return [replica_m1, replica_m2]
Exemple #2
0
def test_basic(topo, new_suffixes, clean_up):
    """Check basic replica functionality

    :feature: Replication
    :steps: 1. Enable replication on supplier. hub and consumer
            2. Create agreements: supplier-hub, hub-consumer
            3. Test supplier-consumer replication
            4. Disable replication
            5. Check that replica, agreements and changelog were deleted
    :expectedresults: No errors happen, replication is successfully enabled and disabled
    """

    supplier = topo.ins["standalone1"]
    hub = topo.ins["standalone2"]
    consumer = topo.ins["standalone3"]

    log.info("Enable replicas (create replica and changelog entries)")
    supplier_replicas = Replicas(supplier)
    supplier_replicas.enable(suffix=NEW_SUFFIX,
                             role=ReplicaRole.SUPPLIER,
                             replicaID=REPLICA_SUPPLIER_ID)
    ents = supplier_replicas.list()
    assert len(ents) == 1
    ents = supplier.changelog.list()
    assert len(ents) == 1

    hub_replicas = Replicas(hub)
    hub_replicas.enable(suffix=NEW_SUFFIX,
                        role=ReplicaRole.HUB,
                        replicaID=CONSUMER_REPLICAID)
    ents = hub_replicas.list()
    assert len(ents) == 1
    ents = hub.changelog.list()
    assert len(ents) == 1

    consumer_replicas = Replicas(consumer)
    consumer_replicas.enable(suffix=NEW_SUFFIX, role=ReplicaRole.CONSUMER)
    ents = consumer_replicas.list()
    assert len(ents) == 1

    log.info("Create agreements between the instances")
    supplier.agreement.create(suffix=NEW_SUFFIX, host=hub.host, port=hub.port)
    ents = supplier.agreement.list(suffix=NEW_SUFFIX)
    assert len(ents) == 1
    hub.agreement.create(suffix=NEW_SUFFIX,
                         host=consumer.host,
                         port=consumer.port)
    ents = hub.agreement.list(suffix=NEW_SUFFIX)
    assert len(ents) == 1

    log.info("Test replication")
    supplier_replicas.test(NEW_SUFFIX, consumer)

    log.info("Disable replication")
    supplier_replicas.disable(suffix=NEW_SUFFIX)
    hub_replicas.disable(suffix=NEW_SUFFIX)
    consumer_replicas.disable(suffix=NEW_SUFFIX)

    log.info("Check that replica, agreements and changelog were deleted")
    for num in range(1, 4):
        log.info("Checking standalone{} instance".format(num))
        inst = topo.ins["standalone{}".format(num)]

        log.info("Checking that replica entries don't exist")
        replicas = Replicas(inst)
        ents = replicas.list()
        assert len(ents) == 0

        log.info("Checking that changelog doesn't exist")
        ents = inst.changelog.list()
        assert len(ents) == 0

        log.info(
            "Checking that agreements can't be acquired because the replica entry doesn't exist"
        )
        with pytest.raises(NoSuchEntryError) as e:
            inst.agreement.list(suffix=NEW_SUFFIX)
            assert "no replica set up" in e.msg
Exemple #3
0
def test_memberof_with_changelog_reset(topo_m2):
    """Test that replication does not break, after DS stop-start, due to changelog reset

    :id: 60c11636-55a1-4704-9e09-2c6bcc828de4
    :setup: 2 Masters
    :steps:
        1. On M1 and M2, Enable memberof
        2. On M1, add 999 entries allowing memberof
        3. On M1, add a group with these 999 entries as members
        4. Stop M1 in between,
           when add the group memerof is called and before it is finished the
           add, so step 4 should be executed after memberof has started and
           before the add has finished
        5. Check that replication is working fine
    :expectedresults:
        1. memberof should be enabled
        2. Entries should be added
        3. Add operation should start
        4. M1 should be stopped
        5. Replication should be working fine
    """
    m1 = topo_m2.ms["master1"]
    m2 = topo_m2.ms["master2"]

    log.info("Configure memberof on M1 and M2")
    memberof = MemberOfPlugin(m1)
    memberof.enable()
    memberof.set_autoaddoc('nsMemberOf')
    m1.restart()

    memberof = MemberOfPlugin(m2)
    memberof.enable()
    memberof.set_autoaddoc('nsMemberOf')
    m2.restart()

    log.info("On M1, add 999 test entries allowing memberof")
    users_list = add_users(topo_m2, 999, DEFAULT_SUFFIX)

    log.info("On M1, add a group with these 999 entries as members")
    dic_of_attributes = {
        'cn': ensure_bytes('testgroup'),
        'objectclass': ensure_list_bytes(['top', 'groupOfNames'])
    }

    for user in users_list:
        dic_of_attributes.setdefault('member', [])
        dic_of_attributes['member'].append(user.dn)

    log.info('Adding the test group using async function')
    groupdn = 'cn=testgroup,%s' % DEFAULT_SUFFIX
    m1.add(Entry((groupdn, dic_of_attributes)))

    #shutdown the server in-between adding the group
    m1.stop()

    #start the server
    m1.start()

    log.info("Check the log messages for error")
    error_msg = "ERR - NSMMReplicationPlugin - ruv_compare_ruv"
    assert not m1.ds_error_log.match(error_msg)

    log.info("Check that the replication is working fine both ways, M1 <-> M2")
    replicas_m1 = Replicas(m1)
    replicas_m2 = Replicas(m2)
    replicas_m1.test(DEFAULT_SUFFIX, m2)
    replicas_m2.test(DEFAULT_SUFFIX, m1)