Fix bug with unix socket connections (#1933)

When the unix_socket_directories is not known Patroni was immediately going back to tcp connection via the localhost.

The bug was introduced in https://github.com/zalando/patroni/pull/1865
This commit is contained in:
Alexander Kukushkin
2021-05-10 09:53:25 +02:00
committed by GitHub
parent 99626a07f2
commit eaa98e71e3
2 changed files with 12 additions and 4 deletions
+8
View File
@@ -492,6 +492,14 @@ class TestPostgresql(BaseTestPostgresql):
self.p.reload_config(config)
self.p.config.resolve_connection_addresses()
def test_resolve_connection_addresses(self):
self.p.config._config['use_unix_socket'] = self.p.config._config['use_unix_socket_repl'] = True
self.p.config.resolve_connection_addresses()
self.assertEqual(self.p.config.local_replication_address, {'host': '/tmp', 'port': '5432'})
self.p.config._server_parameters.pop('unix_socket_directories')
self.p.config.resolve_connection_addresses()
self.assertEqual(self.p.config._local_address, {'port': '5432'})
@patch.object(Postgresql, '_version_file_exists', Mock(return_value=True))
def test_get_major_version(self):
with patch.object(builtins, 'open', mock_open(read_data='9.4')):