mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 10:07:28 +01:00
test: reproduce transient volume delete failures and stalled progress
This commit is contained in:
1 parent
12ba154d55
commit
ca41cfd2a1
1 file changed
+59
@@ -0,0 +1,59 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/seaweedfs/seaweed-block/core/frontend/chunkstore"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
type transientDeleteFiler struct {
|
||||
*memChunkStore
|
||||
seen map[string]bool
|
||||
stuck bool
|
||||
calls int
|
||||
}
|
||||
|
||||
func (f *transientDeleteFiler) DeleteEntry(ctx context.Context, dir, name string, expected map[string][]byte) error {
|
||||
f.calls++
|
||||
key := dir + "/" + name
|
||||
if f.stuck || !f.seen[key] {
|
||||
f.seen[key] = true
|
||||
return status.Error(codes.DeadlineExceeded, "object deadline")
|
||||
}
|
||||
return f.memChunkStore.DeleteEntry(ctx, dir, name, expected)
|
||||
}
|
||||
|
||||
func TestVolumeDeleteContinuesAcrossTransientObjectFailures(t *testing.T) {
|
||||
for _, stuck := range []bool{false, true} {
|
||||
name := "progress"
|
||||
if stuck {
|
||||
name = "no-progress"
|
||||
}
|
||||
t.Run(name, func(t *testing.T) {
|
||||
store := newMemChunkStore()
|
||||
useMemChunkStore(t, store)
|
||||
v := cliVolume(t, store, name, "daily")
|
||||
f := &transientDeleteFiler{memChunkStore: store, seen: map[string]bool{}, stuck: stuck}
|
||||
dialChunkFiler = func(string) (chunkstore.Filer, func() error, error) { return f, func() error { return nil }, nil }
|
||||
addr := startFakeLifecycle(t, &fakeLifecycle{})
|
||||
started := time.Now()
|
||||
code, out, logs := runChunk(cliArgs("volume-delete", volArgs("volume", v), []string{"--master", addr, "--request-id", "delete-progress", "--timeout", "150ms"})...)
|
||||
if stuck {
|
||||
e := chunkErrorOut(t, out)
|
||||
if code != 1 || e.Code != "unavailable" || !e.Retryable || !strings.Contains(e.Message, "deleted 0 of") || !strings.Contains(e.Message, "/") || !strings.Contains(e.Message, "object deadline") {
|
||||
t.Fatalf("stalled delete: code=%d out=%s logs=%s", code, out, logs)
|
||||
}
|
||||
if time.Since(started) > 3*time.Second {
|
||||
t.Fatal("no-progress window was not bounded")
|
||||
}
|
||||
} else if code != 0 || !strings.Contains(out, `"state":"deleted"`) || !strings.Contains(logs, "deleted 2 of 2") || f.calls < 4 {
|
||||
t.Fatalf("progressing delete: code=%d calls=%d out=%s logs=%s", code, f.calls, out, logs)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user