Commit fe54f05
committed
test(validator): make the cancellation test reach the guard it documents
Third instance in this PR of the same shape, and the review caught it: a guard
added, a test added, and the test never entering the guard's branch.
The test canceled the context before calling waitForDeclaredTrainer.
getTrainerObject checks ctx.Err() at the top of its first read and returns a
'canceled before checking' Timeout, so the err path returned before the select
ever ran. The assertions held — Timeout, not NotFound — but via the probe's
pre-existing behavior. Confirmed by control: with the guard deleted, the old
test still passed.
The cancellation now lands after a probe completes. A reactor cancels and
returns NotFound on the first CRD read, and a missing CRD makes
isTrainerInstalled return immediately, so that probe is the only one and the
next stop is the select with a pending deadline and a canceled parent.
Adds the witness the rollout test had and this one lacked: assert the message is
the guard's 'canceled while waiting' and not getTrainerObject's 'canceled before
checking'. Without a witness that the branch was entered, a test cannot
distinguish exercising a guard from bypassing it. Control-verified both ways.
Two nits from the same review:
The nil-discovery-client comment claimed a fall-through would fail immediately.
installTrainer fetches the release archive from GitHub before it touches
discovery, so on a machine with egress it would download tens of megabytes
first. What actually catches the regression is the assertions — no error, no
claimed resources, probes >= 2 — and the comment now says so.
Raises the test rollout budget from 20ms to 200ms. It has to cover two full
probes of roughly six sequential fake Gets each, plus the sleep, under -race on
a shared runner. Both are instantaneous in practice; the larger one is not
flaky.
Refs #2297
Signed-off-by: Yuan Chen <yuanchen97@gmail.com>1 parent bf6eba4 commit fe54f05
1 file changed
Lines changed: 37 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
320 | 320 | | |
321 | 321 | | |
322 | 322 | | |
323 | | - | |
| 323 | + | |
324 | 324 | | |
325 | 325 | | |
326 | 326 | | |
| |||
333 | 333 | | |
334 | 334 | | |
335 | 335 | | |
336 | | - | |
337 | | - | |
338 | | - | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
339 | 347 | | |
340 | 348 | | |
341 | | - | |
342 | 349 | | |
| 350 | + | |
343 | 351 | | |
344 | | - | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
345 | 361 | | |
346 | 362 | | |
347 | 363 | | |
| |||
354 | 370 | | |
355 | 371 | | |
356 | 372 | | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
357 | 383 | | |
358 | 384 | | |
359 | 385 | | |
| |||
387 | 413 | | |
388 | 414 | | |
389 | 415 | | |
390 | | - | |
391 | | - | |
392 | | - | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
393 | 421 | | |
394 | 422 | | |
395 | 423 | | |
| |||
0 commit comments