carlos / platform Public

code health: gate the digests walk test without a sleep

The slow store holds app listings until four are in flight instead of
sleeping, and apimode.go's record drops to the merged code's 4147.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 82266dfed440dc342cb7b956730b489f61be6e7c parent 6d6cd70
2 files changed, +13 −6
  • .amadan/code-health.tsv +1 −1
  • internal/console/apidigests_test.go +12 −5
diff --git a/.amadan/code-health.tsv b/.amadan/code-health.tsv
index a8edfef61..8986226e3 100644
--- a/.amadan/code-health.tsv
+++ b/.amadan/code-health.tsv
@@ -2218,7 +2218,7 @@ func-lines internal/registry (*Registry).haJournal - 402 # raised: ha-departure-
func-lines internal/release PassFilter - 399
func-lines internal/release adoptHost - 494
func-lines internal/team TestFixture - 421
-file-lines . apimode.go - 4150
+file-lines . apimode.go - 4147
file-lines . apimode_test.go - 3530 # raised: fdc912b (batch 2, #1123) landed before the ratchet; tests for the system update refusals
file-lines internal/activator activator.go - 3785 # raised: the Service.ConfigBeforeWake field and doWakeOnce's one call to it (the body lives in configbeforewake.go); before it, #1290 step 2c
file-lines internal/activator activator_test.go - 5471
diff --git a/internal/console/apidigests_test.go b/internal/console/apidigests_test.go
index fddc22f49..33554f971 100644
--- a/internal/console/apidigests_test.go
+++ b/internal/console/apidigests_test.go
@@ -555,15 +555,16 @@ func TestSystemDigestsDoorListsHeadsTheConsoleDoesNotKnow(t *testing.T) {
}
}
-// slowAppListStore answers every account's app listing ("apps/<acct>/") only
-// after a pause, counting how many are in flight at once, and fails the one
-// for failApps as an unreachable bucket would.
+// slowAppListStore holds every account's app listing ("apps/<acct>/") until
+// four are in flight at once, or a second has passed, counting the most in
+// flight, and fails the one for failApps as an unreachable bucket would.
type slowAppListStore struct {
release.Store
failApps string
mu sync.Mutex
inFlight int
most int
+ full chan struct{}
}
func (s *slowAppListStore) ListDirs(ctx context.Context, prefix string) ([]string, error) {
@@ -573,9 +574,15 @@ func (s *slowAppListStore) ListDirs(ctx context.Context, prefix string) ([]strin
s.mu.Lock()
s.inFlight++
s.most = max(s.most, s.inFlight)
+ if s.inFlight == 4 {
+ close(s.full)
+ }
s.mu.Unlock()
defer func() { s.mu.Lock(); s.inFlight--; s.mu.Unlock() }()
- time.Sleep(50 * time.Millisecond)
+ select {
+ case <-s.full:
+ case <-time.After(time.Second):
+ }
if prefix == "apps/"+s.failApps+"/" {
return nil, errors.New("bucket unreachable for this account")
}
@@ -599,7 +606,7 @@ func TestSystemDigestsDoorWalksAccountsInParallelInOrder(t *testing.T) {
t.Fatal(err)
}
}
- slow := &slowAppListStore{Store: fx.srv.cfg.Releases, failApps: "zqd"}
+ slow := &slowAppListStore{Store: fx.srv.cfg.Releases, failApps: "zqd", full: make(chan struct{})}
fx.srv.cfg.Releases = slow
st, out := getRaw(t, fx.ts.URL+"/api/cli/system/pointer-digests", fx.operator)
if st != http.StatusOK {