mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
Workaround unittest bug and fix requirements (#1718)
* unittest bug: https://bugs.python.org/issue25532 * `urllib3[secure]` wrongly depends on `ipaddress` for python3, while in fact we don't need all dependencies of the `secure` extra, but only `ipaddress` for the `kubernetes` on python2.7 Close https://github.com/zalando/patroni/issues/1717 Close https://github.com/zalando/patroni/issues/1709
This commit is contained in:
+2
-1
@@ -1,4 +1,5 @@
|
||||
urllib3[secure]>=1.19.1,!=1.21
|
||||
urllib3>=1.19.1,!=1.21
|
||||
ipaddress; python_version=="2.7"
|
||||
boto
|
||||
PyYAML
|
||||
six >= 1.7
|
||||
|
||||
@@ -23,7 +23,7 @@ KEYWORDS = 'etcd governor patroni postgresql postgres ha haproxy confd' +\
|
||||
' zookeeper exhibitor consul streaming replication kubernetes k8s'
|
||||
|
||||
EXTRAS_REQUIRE = {'aws': ['boto'], 'etcd': ['python-etcd'], 'etcd3': ['python-etcd'], 'consul': ['python-consul'],
|
||||
'exhibitor': ['kazoo'], 'zookeeper': ['kazoo'], 'kubernetes': [], 'raft': ['pysyncobj']}
|
||||
'exhibitor': ['kazoo'], 'zookeeper': ['kazoo'], 'kubernetes': ['ipaddress'], 'raft': ['pysyncobj']}
|
||||
COVERAGE_XML = True
|
||||
COVERAGE_HTML = False
|
||||
|
||||
@@ -143,9 +143,13 @@ class PyTest(Command):
|
||||
|
||||
def run(self):
|
||||
from pkg_resources import evaluate_marker
|
||||
requirements = self.distribution.install_requires + ['mock>=2.0.0', 'pytest-cov', 'pytest'] +\
|
||||
[v for k, v in self.distribution.extras_require.items() if not k.startswith(':') or evaluate_marker(k[1:])]
|
||||
self.distribution.fetch_build_eggs(requirements)
|
||||
|
||||
requirements = set(self.distribution.install_requires + ['mock>=2.0.0', 'pytest-cov', 'pytest'])
|
||||
for k, v in self.distribution.extras_require.items():
|
||||
if not k.startswith(':') or evaluate_marker(k[1:]):
|
||||
requirements.update(v)
|
||||
|
||||
self.distribution.fetch_build_eggs(list(requirements))
|
||||
self.run_tests()
|
||||
|
||||
|
||||
@@ -167,7 +171,7 @@ def setup_package(version):
|
||||
extra = False
|
||||
for e, v in EXTRAS_REQUIRE.items():
|
||||
if v and r.startswith(v[0]):
|
||||
EXTRAS_REQUIRE[e] = [r]
|
||||
EXTRAS_REQUIRE[e] = [r] if e != 'kubernetes' or sys.version_info < (3, 0, 0) else []
|
||||
extra = True
|
||||
if not extra:
|
||||
install_requires.append(r)
|
||||
|
||||
+3
-4
@@ -3,7 +3,7 @@ import etcd
|
||||
import os
|
||||
import sys
|
||||
|
||||
from mock import call, Mock, MagicMock, PropertyMock, patch, mock_open
|
||||
from mock import Mock, MagicMock, PropertyMock, patch, mock_open
|
||||
from patroni.config import Config
|
||||
from patroni.dcs import Cluster, ClusterConfig, Failover, Leader, Member, get_dcs, SyncState, TimelineHistory
|
||||
from patroni.dcs.etcd import AbstractEtcdClientWithFailover
|
||||
@@ -902,9 +902,8 @@ class TestHa(PostgresInit):
|
||||
self.p.pick_synchronous_standby = Mock(return_value=(['other2', 'other3'], ['other2']))
|
||||
self.ha.dcs.write_sync_state = Mock(return_value=True)
|
||||
self.ha.run_cycle()
|
||||
# mock_set_sync.assert_called_once_with(['other2'])
|
||||
calls = [call(['other2']), call(['other2', 'other3'])]
|
||||
mock_set_sync.assert_has_calls(calls)
|
||||
self.assertEqual(mock_set_sync.call_args_list[0][0], (['other2'],))
|
||||
self.assertEqual(mock_set_sync.call_args_list[1][0], (['other2', 'other3'],))
|
||||
|
||||
mock_set_sync.reset_mock()
|
||||
# Test sync standby is not disabled when updating dcs fails
|
||||
|
||||
Reference in New Issue
Block a user