Refactor is_failover_possible() (#2804)

* Refactor is_failover_possible()

Move all the members filtering inside the function.

* Remove check_synchronous parameter
* Add sync_mode_is_active() method and user it everywhere where it is appropriate
* Reduce nesting

---------

Co-authored-by: Alexander Kukushkin <[email protected]>
This commit is contained in:
Polina Bungina
2023-08-08 11:50:02 +02:00
committed by GitHub
co-authored by Alexander Kukushkin
parent 9dd177e5c9
commit f24db395c6
2 changed files with 81 additions and 79 deletions
-1
View File
@@ -748,7 +748,6 @@ class TestHa(PostgresInit):
self.p.is_leader = true
self.ha.has_lock = true
self.ha.is_synchronous_mode = true
self.ha.is_failover_possible = false
self.ha.process_sync_replication = Mock()
self.ha.cluster = get_cluster_initialized_with_leader(Failover(0, self.p.name, 'a', None), (self.p.name, None))
self.assertEqual('no action. I am (postgresql0), the leader with the lock', self.ha.run_cycle())