def fin(): for num in range(1, 4): try: replicas = Replicas(topo.ins["standalone{}".format(num)]) replicas.disable(NEW_SUFFIX) log.info("standalone{} is disabled now".format(num)) except: pass
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