mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-11-17 09:17:39 +01:00
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:
1 parent
ddfb219ec3
commit
8cf42a5abb
1 file changed
+10
-2
@@ -193,17 +193,25 @@ func TestFake_NilRequestUsesDefault(t *testing.T) {
|
|||||||
|
|
||||||
func TestFake_ConcurrentCallsSerializeWithoutDeadlock(t *testing.T) {
|
func TestFake_ConcurrentCallsSerializeWithoutDeadlock(t *testing.T) {
|
||||||
// The dispatcher fans dispatch across many goroutines; the fake
|
// 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()
|
f := NewFakeLifecycleServer()
|
||||||
const N = 64
|
const N = 64
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
|
errCh := make(chan error, N)
|
||||||
wg.Add(N)
|
wg.Add(N)
|
||||||
for i := 0; i < N; i++ {
|
for i := 0; i < N; i++ {
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
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()
|
wg.Wait()
|
||||||
|
close(errCh)
|
||||||
|
for err := range errCh {
|
||||||
|
require.NoError(t, err)
|
||||||
|
}
|
||||||
assert.Len(t, f.Recorded(), N)
|
assert.Len(t, f.Recorded(), N)
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user