mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
test: retain bounded failed startup in default mode
This commit is contained in:
1 parent
7c15b1b998
commit
dc5e9a1f3b
1 file changed
+36
@@ -131,3 +131,39 @@ func TestDefaultAttachAt262144EntriesOutlivesAssignmentWait(t *testing.T) {
|
||||
}
|
||||
t.Logf("default attach served after %s, allowance=%s segments=%d entries=%d progress=%d", time.Since(start), allowance, f.fetched.Load(), entries, completed.Load())
|
||||
}
|
||||
|
||||
// Removing the whole-attempt timer must not turn a broken store into an
|
||||
// endless startup retry, nor let the assignment wait serve without a grant.
|
||||
func TestDefaultGrantedAttachFailureEndsAtAssignmentAllowance(t *testing.T) {
|
||||
v := &arrivingAssignment{seen: make(chan struct{}), assigned: make(chan struct{})}
|
||||
cfg := durable.ProviderConfig{Impl: durable.ImplWALStoreChunk, StorageRoot: t.TempDir(), NumBlocks: 64, BlockSize: 4096, ChunkBlocks: 4, ChunkAssignmentTimeout: time.Millisecond}
|
||||
testutil.NewLayoutFixture(t, "v1", 64, 4).Configure(&cfg)
|
||||
cfg.ChunkLayoutHeadFor = func(string) (layout.StartStore, error) { return nil, errHeadRead }
|
||||
p, err := durable.NewDurableProvider(cfg, v)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer p.Close()
|
||||
if _, err := p.EnsureStorage("v1"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
v.active.Store(true)
|
||||
if _, err := p.RecoverVolume(context.Background(), "v1"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
close(v.assigned)
|
||||
deadline := time.Now().Add(2 * time.Second)
|
||||
for {
|
||||
if _, failed := p.ChunkStartupOutcome("v1"); failed {
|
||||
break
|
||||
}
|
||||
if time.Now().After(deadline) {
|
||||
t.Fatal("failed default attach retried past its assignment allowance")
|
||||
}
|
||||
time.Sleep(time.Millisecond)
|
||||
}
|
||||
statuses := p.DurableStatuses()
|
||||
if len(statuses) != 1 || statuses[0].Operational || !strings.Contains(statuses[0].Evidence, "deadline exceeded") {
|
||||
t.Fatal("expired attach did not stay non-serving with the deadline outcome")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user