MCPcopy
hub / github.com/redis/redis-py / test_discover_slaves

Function test_discover_slaves

tests/test_sentinel.py:188–215  ·  view source on GitHub ↗
(cluster, sentinel)

Source from the content-addressed store, hash-verified

186
187@pytest.mark.onlynoncluster
188def test_discover_slaves(cluster, sentinel):
189 assert sentinel.discover_slaves("mymaster") == []
190
191 cluster.slaves = [
192 {"ip": "slave0", "port": 1234, "is_odown": False, "is_sdown": False},
193 {"ip": "slave1", "port": 1234, "is_odown": False, "is_sdown": False},
194 ]
195 assert sentinel.discover_slaves("mymaster") == [("slave0", 1234), ("slave1", 1234)]
196
197 # slave0 -> ODOWN
198 cluster.slaves[0]["is_odown"] = True
199 assert sentinel.discover_slaves("mymaster") == [("slave1", 1234)]
200
201 # slave1 -> SDOWN
202 cluster.slaves[1]["is_sdown"] = True
203 assert sentinel.discover_slaves("mymaster") == []
204
205 cluster.slaves[0]["is_odown"] = False
206 cluster.slaves[1]["is_sdown"] = False
207
208 # node0 -> DOWN
209 cluster.nodes_down.add(("foo", 26379))
210 assert sentinel.discover_slaves("mymaster") == [("slave0", 1234), ("slave1", 1234)]
211 cluster.nodes_down.clear()
212
213 # node0 -> TIMEOUT
214 cluster.nodes_timeout.add(("foo", 26379))
215 assert sentinel.discover_slaves("mymaster") == [("slave0", 1234), ("slave1", 1234)]
216
217
218@pytest.mark.onlynoncluster

Callers

nothing calls this directly

Calls 3

discover_slavesMethod · 0.45
addMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected