mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 02:27:26 +01:00
test: require complete final image and bounded maintenance cleanup
This commit is contained in:
1 parent
8e5a2cce7d
commit
899ef867b0
2 files changed
+29
-2
No files matched your search
@@ -53,7 +53,24 @@ func TestMaintenanceSameHandleRearmsAfterJoinedStop(t *testing.T) {
|
||||
h := &volHandle{chunk: layer, chunkLineage: chunkLineage{"v1", "r1", 3, 1}}
|
||||
entered := make(chan struct{}, 2)
|
||||
p := &DurableProvider{volumes: map[string]*volHandle{"v1": h}, view: precopyQueueView{id}, cfg: ProviderConfig{ChunkMaintenanceInterval: time.Nanosecond, ChunkMaintenance: func(ctx context.Context, _ string) error { entered <- struct{}{}; <-ctx.Done(); return ctx.Err() }}}
|
||||
t.Cleanup(func() { p.stopChunkLoop(h) })
|
||||
var stopperDone chan struct{}
|
||||
t.Cleanup(func() {
|
||||
p.mu.Lock()
|
||||
stop, ownerDone := h.chunkStop, h.chunkDone
|
||||
p.mu.Unlock()
|
||||
if stop != nil {
|
||||
stop()
|
||||
}
|
||||
for _, done := range []<-chan struct{}{stopperDone, ownerDone} {
|
||||
if done != nil {
|
||||
select {
|
||||
case <-done:
|
||||
case <-time.After(time.Second):
|
||||
t.Error("cleanup did not join outstanding maintenance stopper/owner")
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
for i := 0; i < 2; i++ {
|
||||
p.mu.Lock()
|
||||
p.startChunkLoop("v1", h, layer)
|
||||
@@ -64,6 +81,7 @@ func TestMaintenanceSameHandleRearmsAfterJoinedStop(t *testing.T) {
|
||||
t.Fatal("same handle did not arm")
|
||||
}
|
||||
done := make(chan struct{})
|
||||
stopperDone = done
|
||||
go func() { p.stopChunkLoop(h); close(done) }()
|
||||
select {
|
||||
case <-done:
|
||||
|
||||
@@ -151,13 +151,16 @@ func (r *deadlineProgressRemote) Put(ctx context.Context, key string, b []byte)
|
||||
return err
|
||||
}
|
||||
func TestChunkStageV3_MultipleDeadlinesKeepProgress(t *testing.T) {
|
||||
_, f, l, w := precopyLayer(t, 1, 5)
|
||||
s, f, l, w := precopyLayer(t, 1, 5)
|
||||
l.cfg.COWSpillLimit = ctChunkBytes
|
||||
l.cfg.UploadConcurrency = 1
|
||||
r := &deadlineProgressRemote{fakeChunkRemote: f}
|
||||
l.remote = r
|
||||
base := f.stats().head.Gen
|
||||
previous := 0
|
||||
lastSubmitted := s.NextLSN() - 1
|
||||
expectedImage := w.imageAt(lastSubmitted)
|
||||
var finalHead chunkHead
|
||||
for pass := 0; pass < 3; pass++ {
|
||||
r.completed = 0
|
||||
r.calls = 0
|
||||
@@ -180,6 +183,8 @@ func TestChunkStageV3_MultipleDeadlinesKeepProgress(t *testing.T) {
|
||||
previous = cached
|
||||
} else if err != nil || result.Head.Gen != base+1 {
|
||||
t.Fatalf("third pass failed to publish: %+v %v", result, err)
|
||||
} else {
|
||||
finalHead = result.Head
|
||||
}
|
||||
}
|
||||
// Five changed chunks, five successful puts, no retransmission after expiry.
|
||||
@@ -194,6 +199,10 @@ func TestChunkStageV3_MultipleDeadlinesKeepProgress(t *testing.T) {
|
||||
t.Fatalf("uploaded bytes=%d want%d", totalBytes, 5*ctChunkBytes)
|
||||
}
|
||||
assertEveryHeadIsPrefixImage(t, f, w)
|
||||
if finalHead.RemoteLSN != lastSubmitted {
|
||||
t.Fatalf("final frontier=%d want last submitted=%d", finalHead.RemoteLSN, lastSubmitted)
|
||||
}
|
||||
assertImage(t, "final complete submitted image", f.imageOf(t, finalHead), expectedImage)
|
||||
if previous != 4 {
|
||||
t.Fatalf("reusable chunks=%d", previous)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user