mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-26 07:30:14 +00:00
* bugfix: pass an arguments to a callback
This commit is contained in:
committed by
GitHub
parent
8c0712047e
commit
a5e79bce9d
@@ -610,7 +610,12 @@ class Postgresql(object):
|
||||
self.__cb_called = True
|
||||
|
||||
if self.callback and cb_name in self.callback:
|
||||
self._callback_executor.call(self.callback[cb_name])
|
||||
cmd = self.callback[cb_name]
|
||||
try:
|
||||
cmd = shlex.split(self.callback[cb_name]) + [cb_name, self.role, self.scope]
|
||||
self._callback_executor.call(cmd)
|
||||
except Exception:
|
||||
logger.exception('callback %s %s %s %s failed', cmd, cb_name, self.role, self.scope)
|
||||
|
||||
@property
|
||||
def role(self):
|
||||
|
||||
@@ -279,6 +279,7 @@ class TestPostgresql(unittest.TestCase):
|
||||
|
||||
@patch.object(builtins, 'open', MagicMock())
|
||||
def test_write_pgpass(self):
|
||||
self.p.write_pgpass({'host': 'localhost', 'port': '5432', 'user': 'foo'})
|
||||
self.p.write_pgpass({'host': 'localhost', 'port': '5432', 'user': 'foo', 'password': 'bar'})
|
||||
|
||||
def test_checkpoint(self):
|
||||
@@ -423,9 +424,9 @@ class TestPostgresql(unittest.TestCase):
|
||||
def test_is_running(self):
|
||||
self.assertFalse(self.p.is_running())
|
||||
|
||||
@patch('subprocess.Popen', Mock(side_effect=OSError))
|
||||
@patch('shlex.split', Mock(side_effect=OSError))
|
||||
def test_call_nowait(self):
|
||||
self.assertFalse(self.p.call_nowait('on_start'))
|
||||
self.assertIsNone(self.p.call_nowait('on_start'))
|
||||
|
||||
def test_non_existing_callback(self):
|
||||
self.assertFalse(self.p.call_nowait('foobar'))
|
||||
|
||||
Reference in New Issue
Block a user