Esempio n. 1
0
def test_new_suffix(topo_m4, new_suffix):
    """Check that we can enable replication on a new suffix

    :id: d44a9ed4-26b0-4189-b0d0-b2b336ddccbd
    :setup: Four suppliers replication setup, a new suffix
    :steps:
        1. Enable replication on the new suffix
        2. Check if replication works
        3. Disable replication on the new suffix
    :expectedresults:
        1. Replication on the new suffix should be enabled
        2. Replication should work
        3. Replication on the new suffix should be disabled
    """
    m1 = topo_m4.ms["supplier1"]
    m2 = topo_m4.ms["supplier2"]

    repl = ReplicationManager(NEW_SUFFIX)

    repl.create_first_supplier(m1)

    repl.join_supplier(m1, m2)

    repl.test_replication(m1, m2)
    repl.test_replication(m2, m1)

    repl.remove_supplier(m1)
    repl.remove_supplier(m2)
Esempio n. 2
0
def restore_supplier4(topology_m4):
    """In our tests will always be removing supplier 4, so we need a common
    way to restore it for another test
    """

    # Restart the remaining suppliers to allow rid 4 to be reused.
    for inst in topology_m4.ms.values():
        inst.restart()

    repl = ReplicationManager(DEFAULT_SUFFIX)
    repl.join_supplier(topology_m4.ms["supplier1"],
                       topology_m4.ms["supplier4"])

    # Add the 2,3 -> 4 agmt.
    repl.ensure_agreement(topology_m4.ms["supplier2"],
                          topology_m4.ms["supplier4"])
    repl.ensure_agreement(topology_m4.ms["supplier3"],
                          topology_m4.ms["supplier4"])
    # And in reverse ...
    repl.ensure_agreement(topology_m4.ms["supplier4"],
                          topology_m4.ms["supplier2"])
    repl.ensure_agreement(topology_m4.ms["supplier4"],
                          topology_m4.ms["supplier3"])

    log.info('Supplier 4 has been successfully restored.')
Esempio n. 3
0
def restore_supplier4(topology_m4):
    """In our tests will always be removing supplier 4, so we need a common
    way to restore it for another test
    """

    log.info('Restoring supplier 4...')

    # Enable replication on supplier 4
    M4 = topology_m4.ms["supplier4"]
    M1 = topology_m4.ms["supplier1"]
    repl = ReplicationManager(SUFFIX)
    repl.join_supplier(M1, M4)
    repl.ensure_agreement(M4, M1)
    repl.ensure_agreement(M1, M4)

    # Test Replication is working
    for num in range(2, 5):
        if topology_m4.ms["supplier1"].testReplication(DEFAULT_SUFFIX, topology_m4.ms["supplier{}".format(num)]):
            log.info('Replication is working m1 -> m{}.'.format(num))
        else:
            log.fatal('restore_supplier4: Replication is not working from m1 -> m{}.'.format(num))
            assert False
        time.sleep(1)

    # Check replication is working from supplier 4 to supplier1...
    if topology_m4.ms["supplier4"].testReplication(DEFAULT_SUFFIX, topology_m4.ms["supplier1"]):
        log.info('Replication is working m4 -> m1.')
    else:
        log.fatal('restore_supplier4: Replication is not working from m4 -> 1.')
        assert False
    time.sleep(5)

    log.info('Supplier 4 has been successfully restored.')
Esempio n. 4
0
def replicate_backend(s1, s2, beSuffix):
    repl = ReplicationManager(beSuffix)
    repl.create_first_supplier(s1)
    repl.join_supplier(s1, s2)
    repl.ensure_agreement(s1, s2)
    repl.ensure_agreement(s2, s2)
Esempio n. 5
0
def create_topology(topo_dict, suffix=DEFAULT_SUFFIX):
    """Create a requested topology. Cascading replication scenario isn't supported

    :param topo_dict: a dictionary {ReplicaRole.STANDALONE: num, ReplicaRole.SUPPLIER: num,
                                   ReplicaRole.CONSUMER: num}
    :type topo_dict: dict
    :param suffix: a suffix for the replication
    :type suffix: str

    :return - TopologyMain object
    """

    if not topo_dict:
        ValueError("You need to specify the dict. For instance: {ReplicaRole.STANDALONE: 1}")

    if ReplicaRole.HUB in topo_dict.keys():
        NotImplementedError("Cascading replication scenario isn't supported."
                            "Please, use existing topology or create your own.")

    topo = _create_instances(topo_dict, suffix)

    # Start with a single supplier, and create it "first".
    first_supplier = None
    try:
        first_supplier = list(topo.ms.values())[0]
        log.info("Creating replication topology.")
        # Now get the first supplier ready.
        repl = ReplicationManager(DEFAULT_SUFFIX)
        repl.create_first_supplier(first_supplier)
    except IndexError:
        pass

    # Now init the other suppliers from this.
    # This will reinit m, and put a bi-directional agreement
    # in place.
    for m in topo.ms.values():
        # Skip firstsupplier.
        if m is first_supplier:
            continue
        log.info("Joining supplier %s to %s ..." % (m.serverid, first_supplier.serverid))
        repl.join_supplier(first_supplier, m)

    # Mesh the supplier agreements.
    for mo in topo.ms.values():
        for mi in topo.ms.values():
            if mo is mi:
                continue
            log.info("Ensuring supplier %s to %s ..." % (mo.serverid, mi.serverid))
            repl.ensure_agreement(mo, mi)

    # Add supplier -> consumer agreements.
    for c in topo.cs.values():
        log.info("Joining consumer %s from %s ..." % (c.serverid, first_supplier.serverid))
        repl.join_consumer(first_supplier, c)

    for m in topo.ms.values():
        for c in topo.cs.values():
            log.info("Ensuring consumer %s from %s ..." % (c.serverid, m.serverid))
            repl.ensure_agreement(m, c)

    # Clear out the tmp dir
    for instance in topo:
        instance.clearTmpDir(__file__)

    return topo