Fix keepalive connection out of the range issue (#3089) (#3158)

This commit is contained in:
hadizamani021
2024-09-13 17:48:59 +02:00
committed by GitHub
parent 74a72e4f78
commit 94a592d275
2 changed files with 42 additions and 6 deletions
+8 -2
View File
@@ -1,10 +1,11 @@
import sys
import unittest
from unittest.mock import Mock, patch
from patroni.exceptions import PatroniException
from patroni.utils import enable_keepalive, get_major_version, get_postgres_version, \
polling_loop, Retry, RetryFailedError, unquote, validate_directory
from patroni.utils import apply_keepalive_limit, enable_keepalive, get_major_version, \
get_postgres_version, polling_loop, Retry, RetryFailedError, unquote, validate_directory
class TestUtils(unittest.TestCase):
@@ -43,6 +44,11 @@ class TestUtils(unittest.TestCase):
with patch('sys.platform', platform):
self.assertIsNone(enable_keepalive(Mock(), 10, 5))
def test_apply_keepalive_limit(self):
for platform in ('linux2', 'darwin'):
with patch('sys.platform', platform):
self.assertLess(apply_keepalive_limit('TCP_KEEPIDLE', sys.maxsize), sys.maxsize)
def test_unquote(self):
self.assertEqual(unquote('value'), 'value')
self.assertEqual(unquote('value with spaces'), "value with spaces")