mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 10:37:23 +01:00
test(storage): prevent retries from bypassing takeover cooling
This commit is contained in:
1 parent
40f1df163d
commit
dd38de086c
1 file changed
+19
@@ -147,3 +147,22 @@ func TestHeadBeltConfirmationUsesOnlyRoot(t *testing.T) {
|
||||
t.Fatal("confirmed wrong image")
|
||||
}
|
||||
}
|
||||
|
||||
func TestHeadBeltRetryOfUnconfirmedClaimStillCools(t *testing.T) {
|
||||
f := newFakeChunkRemote()
|
||||
f.head = chunkHead{Gen: 1, Epoch: 1, Holder: "old", Chunks: map[uint64]chunkRef{}}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
|
||||
defer cancel()
|
||||
if _, err := ClaimChunkHead(ctx, f, ChunkLayerConfig{Epoch: 2, Holder: "new"}); !errors.Is(err, context.DeadlineExceeded) || f.stats().cas != 1 {
|
||||
t.Fatalf("claim did not stop inside cooling after CAS: %v, calls=%d", err, f.stats().cas)
|
||||
}
|
||||
retryCtx, retryCancel := context.WithTimeout(context.Background(), 8*time.Second)
|
||||
defer retryCancel()
|
||||
start := time.Now()
|
||||
if _, err := ClaimChunkHead(retryCtx, f, ChunkLayerConfig{Epoch: 2, Holder: "new"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if time.Since(start) < 5*time.Second || f.stats().cas != 1 {
|
||||
t.Fatal("retry bypassed cooling or replayed a settled claim")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user