Fix bug with custom bootstrap (#2948)

Patroni was falsely applying `--command` argument.

Close https://github.com/zalando/patroni/issues/2947
This commit is contained in:
Alexander Kukushkin
2023-11-13 15:01:57 +01:00
committed by GitHub
parent 7370f70f13
commit 1870dcd8f9
2 changed files with 11 additions and 5 deletions
+8 -1
View File
@@ -179,10 +179,17 @@ class TestBootstrap(BaseTestPostgresql):
@patch.object(Postgresql, 'controldata', Mock(return_value={'Database cluster state': 'in production'}))
def test_custom_bootstrap(self, mock_cancellable_subprocess_call):
self.p.config._config.pop('pg_hba')
config = {'method': 'foo', 'foo': {'command': 'bar'}}
config = {'method': 'foo', 'foo': {'command': 'bar --arg1=val1'}}
mock_cancellable_subprocess_call.return_value = 1
self.assertFalse(self.b.bootstrap(config))
self.assertEqual(mock_cancellable_subprocess_call.call_args_list[0][0][0],
['bar', '--arg1=val1', '--scope=batman', '--datadir=' + os.path.join('data', 'test0')])
mock_cancellable_subprocess_call.reset_mock()
config['foo']['no_params'] = 1
self.assertFalse(self.b.bootstrap(config))
self.assertEqual(mock_cancellable_subprocess_call.call_args_list[0][0][0], ['bar', '--arg1=val1'])
mock_cancellable_subprocess_call.return_value = 0
with patch('multiprocessing.Process', Mock(side_effect=Exception("42"))), \