The test was red on main two ways, each from a timing assumption:
- "the renewal never started" (line 54, 60s): the load call that starts
the renewal had a fixed 300ms context. When the call is not written to
the host within those 300ms (a slow get, a busy writer), it is given up
on before it is sent, the plugin never reaches auth.refresh, and no
wait helps. Now the call's context is cancelled only once the
renewal's log shows it started.
- "kept ... not the renewed token" (line 61, CI at 84ad780b6): a
given-up call keeps its slot until its abort is written to the host
(callAborting). If Restart runs before that write, the host is busy,
retire stops it in the background, and Restart returns at once; the
test then read plugin-auth.json while the renewal was still running.
The product is right: the background stop still lets the renewal end
and saves the token. The test now waits on the stopped host's dead
channel. It also waits until magpie has heard the host's "renewing"
event, so a host output read late can't count as no renewal.
No product code changes.
Run on mote at base origin/main d2c29abe7 (no internal/plugin change since; rebased onto 640825b09 and the three stop tests rerun there, -race -count=3: ok):
- injected (not committed) a 500ms sleep in callWithTimeout before a
"load" call is sent, and a 1.5s sleep in pumpCtrl before an abort is
written. Old test, go test -race -failfast -count=20: red with each, the
abort delay at line 61 ("after stopping 0s in, kept ... access:old"),
the send delay at line 54 ("the renewal never started", 60.03s).
New test, -race -count=20: ok with no injection (83.3s), with the
abort delay (83.5s) and with the send delay (93.8s).
- broke by hand: stop no longer waiting for a renewal (the
h.renewing loop off): the new test is red, "after stopping 2.004s in,
kept ... not the renewed token".
- gofmt -l internal/plugin: nothing; go vet ./internal/plugin, with
GOOS=linux and GOOS=windows too: ok; go test -tags nogui -race
-count=1 ./internal/plugin: ok (165.2s).
- the full suite runs after the push, through the suite lock; its reds
are filed as issues.
Not tried: Windows and Linux runs of this test; the change is in the
test only.