Commit 7d7ce38
Pin the find_leader skip-and-continue path under a bad handshake
The find_leader loop at cluster.py:109-132 iterates candidate nodes
and catches transport/protocol errors per node so that one bad peer
does not wedge discovery. The wrapping chain that makes this work —
wire DecodeError/ProtocolError from a malformed handshake response
gets re-raised as client ProtocolError by _read_response and lands
in the except tuple — was only covered transitively through the
single-node `test_query_leader_closes_writer_on_handshake_error`.
Add a two-node test that replies to the first node with 64 bytes of
zeros (decodes as a FAILURE-typed frame whose body is too short for
the uint64 code, raising wire DecodeError) and to the second with a
valid Welcome + Leader pair, and assert that find_leader skips the
bad node and returns a valid leader address.
The test is deterministic under the cluster's intentional node
shuffle because the mock_reader's side_effect sequence is consumed
in call order — whichever node dials first consumes the bad
handshake bytes, the other consumes the valid welcome.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 877c0a8 commit 7d7ce38
1 file changed
+42
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
190 | 232 | | |
191 | 233 | | |
192 | 234 | | |
| |||
0 commit comments