mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 11:07:31 +01:00
The runtime stores each volume in one content-named layout on the filer: immutable chunks, segments and roots are ordinary filer files, and one HEAD entry per volume carries every conditional commit. A holder claims HEAD under its granted epoch and claim id, cuts in its own session, commits by HEAD generation and position, and is fenced when its identity moves. Catalog, restore, snapshot, retention, cleaning, verify and volume delete run through the layout kernel; the master mints the layout identity, reads HEAD proofs and holds the delete reservation and lease barrier. The legacy store, its intents and its compatibility paths are removed; existing stores are recreated, not converted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
53 lines
1.6 KiB
Go
53 lines
1.6 KiB
Go
package lifecycle
|
|
|
|
import (
|
|
"errors"
|
|
"testing"
|
|
)
|
|
|
|
func TestCreateVolumePersistsV1GeometryAndRejectsChangedReplay(t *testing.T) {
|
|
s, err := OpenFileStore(t.TempDir())
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
spec := VolumeSpec{VolumeID: "v", SizeBytes: 1 << 20, ReplicationFactor: 1}
|
|
first, err := s.CreateVolume(spec)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if first.Spec.BlockSize != 4096 || first.Spec.ChunkBytes != 4<<20 {
|
|
t.Fatalf("default geometry not persisted: %+v", first.Spec)
|
|
}
|
|
if first.StoreReady {
|
|
t.Fatal("new record advertised store readiness before VOLUME and HEAD")
|
|
}
|
|
again, err := s.CreateVolume(spec)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if again.Spec != first.Spec {
|
|
t.Fatalf("replay changed geometry: first=%+v replay=%+v", first.Spec, again.Spec)
|
|
}
|
|
ready, err := s.MarkStoreReady("v", first.Spec.LayoutID)
|
|
if err != nil || !ready.StoreReady {
|
|
t.Fatalf("mark ready: record=%+v err=%v", ready, err)
|
|
}
|
|
if _, err := s.MarkStoreReady("v", "00000000000000000000000000000000"); !errors.Is(err, ErrVolumeConflict) {
|
|
t.Fatalf("foreign layout id changed readiness: %v", err)
|
|
}
|
|
replayed, err := s.CreateVolume(spec)
|
|
if err != nil || !replayed.StoreReady {
|
|
t.Fatalf("ready replay: record=%+v err=%v", replayed, err)
|
|
}
|
|
changed := spec
|
|
changed.BlockSize = 8192
|
|
if _, err := s.CreateVolume(changed); !errors.Is(err, ErrInvalidVolumeSpec) {
|
|
t.Fatalf("unsupported v1 geometry: %v", err)
|
|
}
|
|
changed.BlockSize = 4096
|
|
changed.ChunkBytes = 1 << 20
|
|
if _, err := s.CreateVolume(changed); !errors.Is(err, ErrInvalidVolumeSpec) {
|
|
t.Fatalf("unsupported v1 chunk size: %v", err)
|
|
}
|
|
}
|