carlos / platform Public

edge tests: Astra round 1 P2s on the lbhealth witnesses

P2-1: TestHomeMapFeedsTheHealthState advances the clock a minute before
the failed refresh, so at before+RefreshWindow the good refresh's stamp
has aged out and only the failed attempt's own stamp keeps the refresh
condition fresh. A home map that stamps only successful refreshes now
fails the test (mutation run); before this it passed.

P2-2: wedgedProbe's free-path case keeps ticking the watch, two ticks at
a time, until a fresh beat shows, within 5 s: a probe that loses to the
100 ms servingProbeTimeout on a loaded box records no beat for that
poll. The wedged case still takes exactly two ticks and no retries, so a
retry cannot hide a beat it should never emit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 3dead10cf27409f068a0dc1051616444bf597e1f parent 5dc4ad0
1 file changed, +18 −2
  • internal/edge/lbhealth_test.go +18 −2

CI cancelled — superseded by a newer push — run details

diff --git a/internal/edge/lbhealth_test.go b/internal/edge/lbhealth_test.go
index d85fad0fa..c61eb8c75 100644
--- a/internal/edge/lbhealth_test.go
+++ b/internal/edge/lbhealth_test.go
@@ -7,6 +7,7 @@ import (
"net/http/httptest"
"os"
"path/filepath"
+ "slices"
"strings"
"testing"
"time"
@@ -165,7 +166,10 @@ func TestHomeMapFeedsTheHealthState(t *testing.T) {
t.Fatalf("after a good refresh: %s", failing)
}
- // A bucket outage: the attempt fails but finishes, and the latches hold.
+ // A bucket outage a minute later: the attempt fails but finishes, and
+ // the latches hold. A window after it, the good refresh's stamp has
+ // aged out, so only the failed attempt's own stamp keeps it fresh.
+ clk.advance(time.Minute)
s.down = true
before := clk.now()
if err := m.Refresh(context.Background()); err == nil {
@@ -360,7 +364,19 @@ func wedgedProbe(t *testing.T, wedge bool) (failing string) {
sendTick(t, tick)
// Set the clock 57s ahead: a beat from the ticks is still inside the 60s
// window, one from before the wedge (setup, 5s back) is not.
- now := time.Now().Add(lbhealth.HeartbeatWindow - 3*time.Second)
+ ahead := func() time.Time { return time.Now().Add(lbhealth.HeartbeatWindow - 3*time.Second) }
+ if !wedge {
+ // A free path's probe can still lose to servingProbeTimeout on a
+ // loaded box, and that poll records no beat: keep polling until one
+ // beats, within a bound. The wedged case takes no retries, so a
+ // retry cannot hide a beat it should never emit.
+ deadline := time.Now().Add(5 * time.Second)
+ for slices.Contains(h.Failing(ahead()), lbhealth.CondEdge) && time.Now().Before(deadline) {
+ sendTick(t, tick)
+ sendTick(t, tick)
+ }
+ }
+ now := ahead()
got := h.Failing(now)
w := httptest.NewRecorder()
lbhealth.Serve(w, httptest.NewRequest(http.MethodGet, lbhealth.Path, nil), h, now)