package main import ( "errors" "strings" "testing" "github.com/seaweedfs/seaweed-block/core/frontend/durable" ) // --durable-impl defaults to empty (auto): new volumes are walstore, and an // existing volume opens with its on-disk format. func TestBlockvolumeDurableImplDefaultIsAuto(t *testing.T) { f, err := parseFlags(phase150RequiredBlockvolumeArgs()) if err != nil { t.Fatalf("parseFlags: %v", err) } if f.durableImpl != "" { t.Fatalf("durableImpl default=%q, want empty (auto)", f.durableImpl) } } func TestBlockvolumeDurableImplExplicitValues(t *testing.T) { for _, impl := range []string{"walstore"} { args := append(phase150RequiredBlockvolumeArgs(), "--durable-root=/tmp/sw-block", "--durable-impl="+impl) f, err := parseFlags(args) if err != nil { t.Fatalf("--durable-impl=%s: %v", impl, err) } if f.durableImpl != impl { t.Fatalf("durableImpl=%q, want %q", f.durableImpl, impl) } } args := append(phase150RequiredBlockvolumeArgs(), "--durable-impl=bogus") if _, err := parseFlags(args); err == nil { t.Fatal("--durable-impl=bogus accepted") } } // The removed experimental engines' names are refused typed, with the advice // an operator acts on; nothing selects them any more. func TestBlockvolumeRefusesRemovedEngineNames(t *testing.T) { for _, impl := range []string{"smartwal", "parallel-walstore"} { args := append(phase150RequiredBlockvolumeArgs(), "--durable-root=/tmp/sw-block", "--durable-impl="+impl) _, err := parseFlags(args) var removed *durable.RemovedEngineError if !errors.As(err, &removed) || string(removed.Engine) != impl || !strings.Contains(err.Error(), durable.RemovedEngineAdvice) { t.Fatalf("--durable-impl=%s: err=%v, want the typed removed-engine refusal", impl, err) } } }