def test_on_ready_override(self): self.assertTrue(self.so.set('foo', 'bar')) self.so.destroy() self.so = None so = KVStoreTTL(Mock(), None, None, self_addr='127.0.0.1:1234', partner_addrs=['127.0.0.1:1235'], patronictl=True) so.doTick(0) so.destroy()
def test_on_ready_override(self): self.assertTrue(self.so.set('foo', 'bar')) self.destroy(self.so) self.so = None self.conf.onReady = Mock() self.conf.autoTick = False so = KVStoreTTL('127.0.0.1:1234', ['127.0.0.1:1235'], self.conf) so.doTick(0) so.destroy()
class RaftController(AbstractPatroniDaemon): def __init__(self, config): super(RaftController, self).__init__(config) raft_config = self.config.get('raft') self_addr = raft_config['self_addr'] template = os.path.join(raft_config.get('data_dir', ''), self_addr) self._syncobj_config = SyncObjConf(autoTick=False, appendEntriesUseBatch=False, dynamicMembershipChange=True, journalFile=template + '.journal', fullDumpFile=template + '.dump') self._raft = KVStoreTTL(self_addr, raft_config.get('partner_addrs', []), self._syncobj_config) def _run_cycle(self): try: self._raft.doTick(self._syncobj_config.autoTickPeriod) except Exception: logger.exception('doTick') def _shutdown(self): self._raft.destroy()