Convert states to enums (#3293)

- Postgresql._state
- pg_isready state
This commit is contained in:
Polina Bungina
2025-03-14 09:53:56 +01:00
committed by GitHub
parent 5ed4d33f7d
commit 7543e64000
23 changed files with 202 additions and 151 deletions
+3 -2
View File
@@ -18,6 +18,7 @@ from patroni.postgresql.bootstrap import Bootstrap
from patroni.postgresql.callback_executor import CallbackAction
from patroni.postgresql.cancellable import CancellableSubprocess
from patroni.postgresql.config import ConfigHandler
from patroni.postgresql.misc import PostgresqlState
from patroni.postgresql.postmaster import PostmasterProcess
from patroni.postgresql.rewind import Rewind
from patroni.postgresql.slots import SlotsHandler
@@ -211,7 +212,7 @@ class TestHa(PostgresInit):
@patch.object(Config, '_load_cache', Mock())
def setUp(self):
super(TestHa, self).setUp()
self.p.set_state('running')
self.p.set_state(PostgresqlState.RUNNING)
self.p.set_role('replica')
self.p.postmaster_start_time = MagicMock(return_value=str(postmaster_start_time))
self.p.can_create_replica_without_replication_connection = MagicMock(return_value=False)
@@ -678,7 +679,7 @@ class TestHa(PostgresInit):
self.p.restart = Mock(return_value=None)
self.assertEqual(self.ha.restart({}), (False, 'postgres is still starting'))
self.p.restart = false
self.assertEqual(self.ha.restart({}), (False, 'restart failed'))
self.assertEqual(self.ha.restart({}), (False, PostgresqlState.RESTART_FAILED))
self.ha.cluster = get_cluster_initialized_with_leader()
self.ha._async_executor.schedule('reinitialize')
self.assertEqual(self.ha.restart({}), (False, 'reinitialize already in progress'))