SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
package storage
import (
"os"
"testing"
"github.com/seaweedfs/seaweedfs/weed/storage/needle"
"github.com/seaweedfs/seaweedfs/weed/storage/super_block"
)
// A directory occupying the .dat path fails open even as root; load must
// return the error rather than crash inside backend.NewDiskFile.
func TestLoad_DatOpenFail_NoNilPanic(t *testing.T) {
dir := t.TempDir()
v, err := NewVolume(dir, dir, "", 1, NeedleMapInMemory, &super_block.ReplicaPlacement{}, &needle.TTL{}, 0, needle.GetCurrentVersion(), 0, 0)
if err != nil {
t.Fatalf("create volume: %v", err)
}
v.Close()
datPath := VolumeFileName(dir, "", 1) + ".dat"
if err := os.Remove(datPath); err != nil {
t.Fatalf("remove .dat: %v", err)
}
if err := os.Mkdir(datPath, 0755); err != nil {
t.Fatalf("mkdir .dat: %v", err)
}
v2, err := NewVolume(dir, dir, "", 1, NeedleMapInMemory, &super_block.ReplicaPlacement{}, &needle.TTL{}, 0, needle.GetCurrentVersion(), 0, 0)
if err == nil {
v2.Close()
t.Fatal("expected error when .dat cannot be opened, got nil")
}
}