Commit dbe4725
authored
test(grpc): absorb leader churn in consistency loops without weakening the check (#632)
## Summary
`Test_consistency_satisfy_write_after_read_sequence` and
`Test_grpc_transaction` both run a 9999-iteration Put/Get loop against a
3-node Raft cluster. On a busy CI runner Raft re-election can fire
mid-loop and the in-flight RPC surfaces as `rpc error: code = Unknown
desc = leader not found` (also `etcd raft engine is not leader`). Today
both tests abort on the first such error even though it is purely an
availability hiccup — nothing committed, so consistency cannot be
violated.
Wrap every RPC in the existing `retryNotLeader` helper so transient
leader churn is absorbed within `leaderChurnRetryTimeout`. The
consistency assertions (`assert.Equal` for value reads, `assert.Nil` for
post-delete reads) are unchanged: once the Put / Delete eventually
commits, the subsequent Get must agree, and a stale read still fails the
test loudly. **This is the explicit constraint — 一貫性確認そのものは損なわず — and it
holds because `retryNotLeader` only inspects RPC error codes, never the
response payload.**
The fix is symmetric with how `rpushEventually` / `lpushEventually`
already wrap Lua list tests for the same class of CI flake.
## Test plan
- [x] Build / vet / `golangci-lint` clean.
- [x] Locally: `go test ./adapter/ -run
'Test_grpc_transaction|Test_consistency_satisfy_write_after_read_sequence'
-count=1 -timeout 600s` passes (this is the same race-mode shape that
was failing on
https://github.com/bootjp/elastickv/actions/runs/24930560663/job/73007486310).
- [x] No change to the consistency invariants — only the RPC failure
path is retried.
/gemini review
@codex review
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Tests**
* Enhanced robustness of gRPC transaction tests by implementing retry
logic for transient failures during leader elections, reducing flaky
test failures and improving overall test reliability in distributed
cluster scenarios.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->1 file changed
Lines changed: 60 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
191 | 196 | | |
192 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
193 | 205 | | |
194 | 206 | | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
203 | 215 | | |
204 | 216 | | |
205 | 217 | | |
206 | 218 | | |
207 | | - | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
208 | 223 | | |
209 | 224 | | |
210 | 225 | | |
211 | 226 | | |
212 | | - | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
213 | 233 | | |
214 | 234 | | |
215 | 235 | | |
216 | 236 | | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
217 | 241 | | |
218 | 242 | | |
219 | 243 | | |
| |||
224 | 248 | | |
225 | 249 | | |
226 | 250 | | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
227 | 254 | | |
228 | 255 | | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
229 | 260 | | |
230 | 261 | | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
235 | 266 | | |
236 | 267 | | |
237 | 268 | | |
238 | 269 | | |
239 | 270 | | |
240 | 271 | | |
241 | | - | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
242 | 278 | | |
243 | 279 | | |
244 | 280 | | |
245 | 281 | | |
246 | 282 | | |
247 | | - | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
248 | 287 | | |
249 | 288 | | |
250 | 289 | | |
251 | 290 | | |
252 | | - | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
253 | 296 | | |
254 | 297 | | |
255 | 298 | | |
| |||
0 commit comments