Exemple #1
0
 def setUp(self):
     with patch.object(Client, 'machines') as mock_machines:
         mock_machines.__get__ = Mock(
             return_value=['http://remotehost:2379'])
         self.p = Postgresql({
             'name': 'postgresql0',
             'scope': 'dummy',
             'listen': '127.0.0.1:5432',
             'data_dir': 'data/postgresql0',
             'superuser': {},
             'admin': {},
             'replication': {
                 'username': '',
                 'password': '',
                 'network': ''
             }
         })
         self.p.set_state('running')
         self.p.set_role('replica')
         self.p.check_replication_lag = true
         self.p.can_create_replica_without_replication_connection = MagicMock(
             return_value=False)
         self.e = Etcd('foo', {
             'ttl': 30,
             'host': 'ok:2379',
             'scope': 'test'
         })
         self.ha = Ha(MockPatroni(self.p, self.e))
         self.ha._async_executor.run_async = run_async
         self.ha.old_cluster = self.e.get_cluster()
         self.ha.cluster = get_cluster_not_initialized_without_leader()
         self.ha.load_cluster_from_dcs = Mock()
 def get_dcs(name, config):
     if 'etcd' in config:
         return Etcd(name, config['etcd'])
     if 'zookeeper' in config:
         return ZooKeeper(name, config['zookeeper'])
     raise Exception(
         'Can not find suitable configuration of distributed configuration store'
     )
Exemple #3
0
 def setUp(self):
     self.runner = CliRunner()
     with patch.object(Client, 'machines') as mock_machines:
         mock_machines.__get__ = Mock(
             return_value=['http://remotehost:2379'])
         self.e = Etcd('foo', {
             'ttl': 30,
             'host': 'ok:2379',
             'scope': 'test'
         })
 def setUp(self, mock_machines):
     mock_machines.__get__ = Mock(return_value=['http://remotehost:2379'])
     self.p = MockPostgresql()
     self.e = Etcd('foo', {'ttl': 30, 'host': 'ok:2379', 'scope': 'test'})
     self.e.client.read = etcd_read
     self.e.client.write = etcd_write
     self.e.client.delete = Mock(side_effect=etcd.EtcdException())
     self.ha = Ha(MockPatroni(self.p, self.e))
     self.ha._async_executor.run_async = run_async
     self.ha.old_cluster = self.e.get_cluster()
     self.ha.cluster = get_cluster_not_initialized_without_leader()
     self.ha.load_cluster_from_dcs = Mock()
Exemple #5
0
 def setUp(self):
     with patch.object(Client, 'machines') as mock_machines:
         mock_machines.__get__ = Mock(return_value=[
             'http://localhost:2379', 'http://localhost:4001'
         ])
         self.etcd = Etcd(
             'foo', {
                 'namespace': '/patroni/',
                 'ttl': 30,
                 'host': 'localhost:2379',
                 'scope': 'test'
             })
Exemple #6
0
 def get_dcs(name, config):
     if 'etcd' in config:
         from patroni.etcd import Etcd
         return Etcd(name, config['etcd'])
     if 'zookeeper' in config:
         from patroni.zookeeper import ZooKeeper
         return ZooKeeper(name, config['zookeeper'])
     if 'consul' in config:
         from patroni.consul import Consul
         return Consul(name, config['consul'])
     raise PatroniException(
         'Can not find suitable configuration of distributed configuration store'
     )
 def setUp(self):
     with patch.object(Client, 'machines') as mock_machines:
         mock_machines.__get__ = Mock(return_value=[
             'http://localhost:2379', 'http://localhost:4001'
         ])
         self.etcd = Etcd(
             'foo', {
                 'namespace': '/patroni/',
                 'ttl': 30,
                 'host': 'localhost:2379',
                 'scope': 'test'
             })
         self.etcd.client.write = etcd_write
         self.etcd.client.read = etcd_read
         self.etcd.client.delete = Mock(side_effect=etcd.EtcdException())