test(s3/lifecycle): assert per-goroutine errors in fake-server concurrent test (#9393)

test(s3/lifecycle): assert per-goroutine errors in concurrent fake test

The previous TestFake_ConcurrentCallsSerializeWithoutDeadlock dropped
the err return from each LifecycleDelete call, so a regression in the
concurrent path could pass the length-only assertion. Capture each
err on a buffered channel and require.NoError after wg.Wait().
This commit is contained in:
Chris Lu
2026-05-09 18:54:15 -07:00
committed by GitHub
parent ddfb219ec3
commit 8cf42a5abb

View File

@@ -193,17 +193,25 @@ func TestFake_NilRequestUsesDefault(t *testing.T) {
func TestFake_ConcurrentCallsSerializeWithoutDeadlock(t *testing.T) {
// The dispatcher fans dispatch across many goroutines; the fake
// must not livelock or drop records under concurrent load.
// must not livelock or drop records under concurrent load. Capture
// each goroutine's err so a regression in concurrent paths surfaces
// instead of being masked by length-only assertions.
f := NewFakeLifecycleServer()
const N = 64
var wg sync.WaitGroup
errCh := make(chan error, N)
wg.Add(N)
for i := 0; i < N; i++ {
go func() {
defer wg.Done()
_, _ = f.LifecycleDelete(context.Background(), &s3_lifecycle_pb.LifecycleDeleteRequest{Bucket: "b", ObjectPath: "k"})
_, err := f.LifecycleDelete(context.Background(), &s3_lifecycle_pb.LifecycleDeleteRequest{Bucket: "b", ObjectPath: "k"})
errCh <- err
}()
}
wg.Wait()
close(errCh)
for err := range errCh {
require.NoError(t, err)
}
assert.Len(t, f.Recorded(), N)
}