From 78e3fbaea6cb09a5caa88ec10e96975e25a8b2e2 Mon Sep 17 00:00:00 2001 From: Simon Pichugin Date: Mar 22 2017 09:17:03 +0000 Subject: Issue 7 - Add pause and resume methods to topology fixtures Description: For testing purposes, sometimes we need to pause the replication on a big amount of agreements (4 and more, for instance). Add the methods to the TopologyMain class of lib389/topologies.py module. https://pagure.io/lib389/issue/7 Reviewed by: wibrown (Thanks!) --- diff --git a/lib389/topologies.py b/lib389/topologies.py index 56a8169..9b2258a 100644 --- a/lib389/topologies.py +++ b/lib389/topologies.py @@ -27,6 +27,8 @@ log = logging.getLogger(__name__) class TopologyMain(object): def __init__(self, standalones=None, masters=None, consumers=None, hubs=None): + insts_with_agreements = {} + if standalones: if isinstance(standalones, dict): self.ins = standalones @@ -34,10 +36,29 @@ class TopologyMain(object): self.standalone = standalones if masters: self.ms = masters + insts_with_agreements.update(self.ms) if consumers: self.cs = consumers + insts_with_agreements.update(self.cs) if hubs: self.hs = hubs + insts_with_agreements.update(self.hs) + + self._insts = {name: inst for name, inst in insts_with_agreements.items() if not name.endswith('agmts')} + + def pause_all_replicas(self): + """Pause all agreements in the class instance""" + + for inst in self._insts.values(): + for agreement in inst.agreement.list(suffix=DEFAULT_SUFFIX): + inst.agreement.pause(agreement.dn) + + def resume_all_replicas(self): + """Resume all agreements in the class instance""" + + for inst in self._insts.values(): + for agreement in inst.agreement.list(suffix=DEFAULT_SUFFIX): + inst.agreement.resume(agreement.dn) @pytest.fixture(scope="module")