fix pep8 formatting and implement missing tests

This commit is contained in:
Alexander Kukushkin
2016-08-29 15:39:24 +02:00
parent 6dc1d9c88e
commit 366ed9cc52
4 changed files with 10 additions and 9 deletions
+2 -2
View File
@@ -66,7 +66,7 @@ Scenario: check the failover via the API
Given I run patronictl.py failover batman --master postgres0 --candidate postgres1 --force
Then I receive a response returncode 0
And postgres1 is a leader after 5 seconds
And postgres1 role is the primary after 5 seconds
And postgres1 role is the primary after 10 seconds
And postgres0 role is the secondary after 10 seconds
And replication works from postgres1 to postgres0 after 20 seconds
@@ -74,7 +74,7 @@ Scenario: check the scheduled failover
Given I issue a scheduled failover from postgres1 to postgres0 in 1 seconds
Then I receive a response returncode 0
And postgres0 is a leader after 20 seconds
And postgres0 role is the primary after 5 seconds
And postgres0 role is the primary after 10 seconds
And postgres1 role is the secondary after 10 seconds
And replication works from postgres0 to postgres1 after 25 seconds
+5 -5
View File
@@ -812,15 +812,15 @@ def flush(cluster_name, member_names, config_file, dcs, force, role, target):
def toggle_pause(config_file, cluster_name, dcs, paused):
config, dcs, cluster = ctl_load_config(cluster_name, config_file, dcs)
if cluster.is_paused() == paused:
raise PatroniCtlException("Cluster " + ("is already" if paused else "is not") + " paused")
raise PatroniCtlException('Cluster is {0} paused'.format(paused and 'already' or 'not'))
r = request_patroni(cluster.leader.member, 'patch', 'config', {'pause': paused}, auth_header(config))
r = request_patroni(cluster.leader.member, 'patch', 'config', {'pause': paused or None}, auth_header(config))
if r.status_code == 200:
click.echo("Success: cluster management is " + ("paused" if paused else "resumed"))
click.echo('Success: cluster management is {0}'.format(paused and 'paused' or 'resumed'))
else:
click.echo("Failed: " + ("pause" if paused else "resume")
+ " cluster management status code={0}, ({1})".format(r.status_code, r.text))
click.echo('Failed: {0} cluster management status code={1}, ({2})'.format(
paused and 'pause' or 'resume', r.status_code, r.text))
@ctl.command('pause', help='Disable auto failover')
+1 -1
View File
@@ -229,7 +229,7 @@ class Cluster(namedtuple('Cluster', 'initialize,config,leader,last_leader_operat
return candidates[randint(0, len(candidates) - 1)] if candidates else self.leader
def is_paused(self):
return self.config and self.config.data.get('pause', False)
return self.config and self.config.data.get('pause', False) or False
@six.add_metaclass(abc.ABCMeta)
+2 -1
View File
@@ -54,7 +54,8 @@ class TestPatroni(unittest.TestCase):
with patch.object(Patroni, 'run', Mock(side_effect=SleepException)):
self.assertRaises(SleepException, _main)
with patch.object(Patroni, 'run', Mock(side_effect=KeyboardInterrupt())):
_main()
with patch('patroni.ha.Ha.is_paused', Mock(return_value=True)):
_main()
@patch('patroni.config.Config.save_cache', Mock())
@patch('patroni.config.Config.reload_local_configuration', Mock(return_value=True))