Bug#1109865: marked as done (unblock: patroni/4.0.6-1) (4/4)
From
Debian Bug Tracking System@21:1/5 to
All on Sat Jul 26 15:20:01 2025
[continued from previous message]
with patch.object(Postgresql, "_cluster_info_state_get", side_effect=['a b', 'remote_apply', None]):
self.p._major_version = 90400
- self.assertEqual(self.s.current_state(self.cluster), ('off', 0, 0, CaseInsensitiveSet(),
+ self.assertEqual(self.s.current_state(self.cluster), ('off', 0, CaseInsensitiveSet(), CaseInsensitiveSet(),
CaseInsensitiveSet()))
@patch.object(Postgresql, 'last_operation', Mock(return_value=1))
@@ -80,16 +81,34 @@
pg_stat_replication = [
{'pid': 100, 'application_name': self.leadermem.name, 'sync_state': 'quorum', 'flush_lsn': 1},
- {'pid': 101, 'application_name': self.other.name, 'sync_state': 'quorum', 'flush_lsn': 2}]
+ {'pid': 101, 'application_name': self.me.name, 'sync_state': 'quorum', 'flush_lsn': 2}]
# sync node is a bit behind of async, but we prefer it anyway
with patch.object(Postgresql, "_cluster_info_state_get",
- side_effect=['ANY 1 ({0},"{1}")'.format(self.leadermem.name, self.other.name),
+ side_effect=['ANY 1 ({0},"{1}")'.format(self.leadermem.name, self.me.name),
+ 'on', pg_stat_replication]):
+ self.assertEqual(self.s.current_state(self.cluster),
+ ('quorum', 1, CaseInsensitiveSet([self.me.name, self.leadermem.name]),
+ CaseInsensitiveSet([self.me.name, self.leadermem.name]),
+ CaseInsensitiveSet([self.leadermem.name, self.me.name])))
+
+ @patch.object(Postgresql, 'last_operation', Mock(return_value=1))
+ def test_current_state_cascading(self):
+ pg_stat_replication = [
+ {'pid': 100, 'application_name': self.me.name, 'sync_state': 'async', 'flush_lsn': 1},
+ {'pid': 101, 'application_name': self.other.name, 'sync_state': 'sync', 'flush_lsn': 2}]
+
+ # nodes that are supposed to replicate from other standby nodes are not
+ # returned if at least one standby in a chain is streaming from primary
+ self.leadermem.data['tags'] = {'replicatefrom': self.me.name}
+ with patch.object(Postgresql, "_cluster_info_state_get",
+ side_effect=['2 ({0},"{1}")'.format(self.leadermem.name, self.other.name),
'on', pg_stat_replication]):
self.assertEqual(self.s.current_state(self.cluster),
- ('quorum', 1, 2, CaseInsensitiveSet([self.other.name, self.leadermem.name]),
- CaseInsensitiveSet([self.leadermem.name, self.other.name])))
+ ('priority', 2, CaseInsensitiveSet([self.other.name, self.leadermem.name]),
+ CaseInsensitiveSet(), CaseInsensitiveSet([self.me.name])))
+ @patch('time.sleep', Mock())
def test_set_sync_standby(self):
def value_in_conf():
with open(os.path.join(self.p.data_dir, 'postgresql.conf')) as f: @@ -181,5 +200,5 @@
# the pg_stat_replication. We need to check that primary is not selected as the synchronous node.
with patch.object(Postgresql, "_cluster_info_state_get", side_effect=[self.leadermem.name,
'on', pg_stat_replication]):
- self.assertEqual(self.s.current_state(cluster), ('priority', 1, 0, CaseInsensitiveSet(),
- CaseInsensitiveSet([self.me.name])))
+ self.assertEqual(self.s.current_state(cluster), ('priority', 1, CaseInsensitiveSet([self.leadermem.name]),
+ CaseInsensitiveSet(), CaseInsensitiveSet([self.me.name])))
diff -Nru patroni-4.0.5/tests/test_validator.py patroni-4.0.6/tests/test_validator.py
--- patroni-4.0.5/tests/test_validator.py 2025-02-20 16:40:20.000000000 +0100
+++ patroni-4.0.6/tests/test_validator.py 2025-06-06 19:27:48.000000000 +0200
@@ -228,11 +228,10 @@
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):
--===============1515611924359252298==--
Received: (at 1109865-done) by bu