From 15ae6f80c7792e2ea4a16df2937c40f9457c1b85 Mon Sep 17 00:00:00 2001 From: Jeffrey Sica Date: Mon, 5 Oct 2026 06:24:39 -0500 Subject: [PATCH] test(join): wait for the source slot between rate-limit attempts TestRateLimitPerSource joined three times in a row from one source. The server frees the source's slot after the client already has its answer, so the next attempt could be refused as busy ("attempt 1: control plane refused: busy"). It failed main's push builds 37264198746 and 37282526257 and both full builds of #404, inside homelab/bluefin-cluster.bst's go test. Wait for the slot like the replay tests do (#391). Assisted-by: Claude Opus 5.5 via GitHub Copilot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- files/homelab/cluster/internal/join/join_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/files/homelab/cluster/internal/join/join_test.go b/files/homelab/cluster/internal/join/join_test.go index 3de8b7e3..e8560ebd 100644 --- a/files/homelab/cluster/internal/join/join_test.go +++ b/files/homelab/cluster/internal/join/join_test.go @@ -394,10 +394,14 @@ func TestReplayFromSameSourceUnderHeldSlot(t *testing.T) { func TestRateLimitPerSource(t *testing.T) { ts := startServer(t, goodPass, Limits{PerSource: 3, PerSourceWindow: time.Hour, Global: 100, GlobalWindow: time.Hour}) for i := 0; i < 3; i++ { + // The server frees the source's slot after the client has its answer; + // without the wait the next attempt can be refused as busy. + waitSlotFree(ts.limiter, "127.0.0.1") if _, err := client(badPass).Join(context.Background(), ts.addr); !errors.Is(err, ErrNotProven) { t.Fatalf("attempt %d: %v", i, err) } } + waitSlotFree(ts.limiter, "127.0.0.1") _, err := client(goodPass).Join(context.Background(), ts.addr) var se *ServerError if !errors.As(err, &se) || se.Code != ErrCodeRateLimited || se.RetryAfter <= 0 {