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 weed_server
import (
"context"
"strings"
"testing"
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
"github.com/seaweedfs/seaweedfs/weed/util"
)
// A CreateEntry whose context is cancelled before its chunks are compacted must
// fail the request and store nothing, rather than panic in CompactFileChunks.
func TestCreateEntryCancelledContextFailsRequest(t *testing.T) {
store := newRenameTestStore()
f := newRenameTestFiler(t, store)
fs := &FilerServer{
filer: f,
option: &FilerOption{},
entryLockTable: util.NewLockTable[util.FullPath](),
}
ctx, cancel := context.WithCancel(context.Background())
cancel()
_, err := fs.CreateEntry(ctx, &filer_pb.CreateEntryRequest{
Directory: "/test",
SkipCheckParentDirectory: true,
Entry: &filer_pb.Entry{
Name: "obj",
Attributes: &filer_pb.FuseAttributes{Mtime: 1700000000, FileMode: 0644, Inode: 1},
Chunks: []*filer_pb.FileChunk{
{FileId: "1,01", Offset: 0, Size: 100, ModifiedTsNs: 1},
},
},
})
if err == nil || !strings.Contains(err.Error(), "CompactFileChunks: "+context.Canceled.Error()) {
t.Fatalf("err = %v, want CompactFileChunks to fail with context canceled", err)
}
store.mu.Lock()
defer store.mu.Unlock()
if _, found := store.entries["/test/obj"]; found {
t.Fatal("entry was stored despite the failed request")
}
}