mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-01-27 10:20:10 +00:00
Solve a couple of Flaky unit tests (#3294)
This commit is contained in:
@@ -329,10 +329,14 @@ class TestRestApiHandler(unittest.TestCase):
|
||||
'tag_key1=true&tag_key2=false&'
|
||||
'tag_key3=1&tag_key4=1.4&tag_key5=RandomTag&tag_key6=RandomTag2')
|
||||
|
||||
def test_do_OPTIONS(self):
|
||||
@patch.object(MockPatroni, 'dcs')
|
||||
def test_do_OPTIONS(self, mock_dcs):
|
||||
mock_dcs.cluster.status.last_lsn = 20
|
||||
self.assertIsNotNone(MockRestApiServer(RestApiHandler, 'OPTIONS / HTTP/1.0'))
|
||||
|
||||
def test_do_HEAD(self):
|
||||
@patch.object(MockPatroni, 'dcs')
|
||||
def test_do_HEAD(self, mock_dcs):
|
||||
mock_dcs.cluster.status.last_lsn = 20
|
||||
self.assertIsNotNone(MockRestApiServer(RestApiHandler, 'HEAD / HTTP/1.0'))
|
||||
|
||||
@patch.object(MockPatroni, 'dcs')
|
||||
|
||||
@@ -161,6 +161,7 @@ class TestK8sConfig(unittest.TestCase):
|
||||
|
||||
|
||||
@patch('urllib3.PoolManager.request')
|
||||
@patch.object(K8sConfig, '_server', '', create=True)
|
||||
class TestApiClient(unittest.TestCase):
|
||||
|
||||
@patch.object(K8sConfig, '_server', '', create=True)
|
||||
|
||||
@@ -83,6 +83,8 @@ class TestPatroniLogger(unittest.TestCase):
|
||||
self.assertRaises(Exception, logger.shutdown)
|
||||
self.assertLessEqual(logger.queue_size, 2) # "Failed to close the old log handler" could be still in the queue
|
||||
self.assertEqual(logger.records_lost, 0)
|
||||
del config['log']['traceback_level']
|
||||
logger.reload_config(config)
|
||||
|
||||
def test_interceptor(self):
|
||||
logger = PatroniLogger()
|
||||
|
||||
@@ -229,11 +229,10 @@ class TestValidator(unittest.TestCase):
|
||||
c["kubernetes"]["pod_ip"] = "::1"
|
||||
c["consul"]["host"] = "127.0.0.1:50000"
|
||||
c["etcd"]["host"] = "127.0.0.1:237"
|
||||
c["postgresql"]["listen"] = "127.0.0.1:5432"
|
||||
with patch('patroni.validator.open', mock_open(read_data='9')):
|
||||
errors = schema(c)
|
||||
output = "\n".join(errors)
|
||||
self.assertEqual(['consul.host', 'etcd.host', 'postgresql.bin_dir', 'postgresql.data_dir', 'postgresql.listen',
|
||||
self.assertEqual(['consul.host', 'etcd.host', 'postgresql.bin_dir', 'postgresql.data_dir',
|
||||
'raft.bind_addr', 'raft.self_addr', 'restapi.connect_address'], parse_output(output))
|
||||
|
||||
def test_bin_dir_is_empty_string_executables_in_path(self, mock_out, mock_err):
|
||||
|
||||
Reference in New Issue
Block a user