| 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 { |