mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 02:27:26 +01:00
test(storage): the concurrency tests join only workers not yet joined
A failing path that already took a worker's result no longer leaves the cleanup waiting on an empty channel; the evict-without-lock mutant now fails at once instead of timing out in cleanup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9ab1478c5c
commit
88bd3e9181
1 file changed
+26
-24
@@ -256,11 +256,13 @@ func TestRecordRuntimeEvictDuringAFlushLandsLast(t *testing.T) {
|
||||
}
|
||||
flushed, evicted := make(chan error, 1), make(chan error, 1)
|
||||
go func() { flushed <- r.Flush() }()
|
||||
evictStarted := false
|
||||
t.Cleanup(func() {
|
||||
evictStarted, flushJoined, evictJoined := false, false, false
|
||||
t.Cleanup(func() { // release and join every worker not yet joined
|
||||
release.Do(func() { close(resume) })
|
||||
waitFor(t, flushed, "the flush")
|
||||
if evictStarted {
|
||||
if !flushJoined {
|
||||
waitFor(t, flushed, "the flush")
|
||||
}
|
||||
if evictStarted && !evictJoined {
|
||||
waitFor(t, evicted, "the evict")
|
||||
}
|
||||
})
|
||||
@@ -272,19 +274,18 @@ func TestRecordRuntimeEvictDuringAFlushLandsLast(t *testing.T) {
|
||||
}()
|
||||
select {
|
||||
case err := <-evicted:
|
||||
evicted <- err
|
||||
evictJoined = true
|
||||
t.Fatalf("the evict wrote its page (%v) while the flush held an older snapshot", err)
|
||||
case <-time.After(200 * time.Millisecond):
|
||||
}
|
||||
release.Do(func() { close(resume) })
|
||||
if err := waitFor(t, flushed, "the flush"); err != nil {
|
||||
t.Fatal(err)
|
||||
errF := waitFor(t, flushed, "the flush")
|
||||
flushJoined = true
|
||||
errE := waitFor(t, evicted, "the evict")
|
||||
evictJoined = true
|
||||
if errF != nil || errE != nil {
|
||||
t.Fatal(errF, errE)
|
||||
}
|
||||
flushed <- nil
|
||||
if err := waitFor(t, evicted, "the evict"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
evicted <- nil
|
||||
b, err := os.ReadFile(filepath.Join(r.dir, chunkRecordPageName(0)))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -336,11 +337,13 @@ func TestRecordRuntimePageWritersPublishInOrder(t *testing.T) {
|
||||
}
|
||||
aDone, bDone := make(chan error, 1), make(chan error, 1)
|
||||
go func() { aDone <- r.WriteThrough(4) }()
|
||||
bStarted := false
|
||||
t.Cleanup(func() { // release and join on every path
|
||||
bStarted, aJoined, bJoined := false, false, false
|
||||
t.Cleanup(func() { // release and join every worker not yet joined
|
||||
release.Do(func() { close(resume) })
|
||||
waitFor(t, aDone, "the first writer")
|
||||
if bStarted {
|
||||
if !aJoined {
|
||||
waitFor(t, aDone, "the first writer")
|
||||
}
|
||||
if bStarted && !bJoined {
|
||||
waitFor(t, bDone, "the second writer")
|
||||
}
|
||||
})
|
||||
@@ -350,19 +353,18 @@ func TestRecordRuntimePageWritersPublishInOrder(t *testing.T) {
|
||||
go func() { bDone <- r.Flush() }()
|
||||
select {
|
||||
case err := <-bDone:
|
||||
bDone <- err
|
||||
bJoined = true
|
||||
t.Fatalf("the second writer published (%v) while the first held an older snapshot", err)
|
||||
case <-time.After(200 * time.Millisecond):
|
||||
}
|
||||
release.Do(func() { close(resume) })
|
||||
if err := waitFor(t, aDone, "the first writer"); err != nil {
|
||||
t.Fatal(err)
|
||||
errA := waitFor(t, aDone, "the first writer")
|
||||
aJoined = true
|
||||
errB := waitFor(t, bDone, "the second writer")
|
||||
bJoined = true
|
||||
if errA != nil || errB != nil {
|
||||
t.Fatal(errA, errB)
|
||||
}
|
||||
aDone <- nil
|
||||
if err := waitFor(t, bDone, "the second writer"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
bDone <- nil
|
||||
if err := r.Flush(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user