Files
upstream-seaweedfs/weed/storage/store_ec_phantom_dat_test.go
upstream-mirror 89f5be005d
Some checks failed
go: build dev binaries / cleanup (push) Successful in 4s
Codespell / Check for spelling errors (push) Failing after 3s
docker: build dev containers / build-rust-binaries (amd64, x86_64-unknown-linux-musl) (push) Failing after 3s
docker: build dev containers / build-dev-containers (push) Has been skipped
docker: build dev containers / build-rust-binaries (arm64, true, aarch64-unknown-linux-musl) (push) Failing after 3s
End to End / FUSE Mount (push) Failing after 2s
EC Integration Tests / EC Integration Tests (push) Failing after 30s
FUSE DLM Integration Tests / FUSE DLM Integration Tests (push) Failing after 3s
FUSE Volume Server Failover Tests / FUSE Volume Server Failover (push) Failing after 3s
FUSE Integration Tests / FUSE Integration Testing (push) Failing after 2s
FUSE P2P Peer Chunk Sharing Integration Tests / FUSE P2P Peer Chunk Sharing (push) Failing after 3s
go: build binary / Go Vet (push) Failing after 2s
go: build binary / Go Vet 32-bit (push) Failing after 3s
go: build binary / Build (push) Failing after 4s
go: build binary / Build cross-platform (freebsd/amd64) (push) Failing after 3s
go: build binary / Build cross-platform (windows/amd64) (push) Failing after 3s
go: build binary / Build cross-platform (darwin/arm64) (push) Failing after 3s
go: build binary / Build cross-platform (windows/arm64) (push) Failing after 3s
go: build binary / Test (push) Failing after 2s
go: build binary / Test 32-bit (push) Failing after 3s
helm: lint and test charts / lint-test (push) Failing after 3s
Java Client Integration Tests / Java Integration Tests (11) (push) Failing after 3s
Java Client Integration Tests / Java Integration Tests (17) (push) Failing after 3s
go: build dev binaries / build_dev_linux_windows (amd64, linux) (push) Failing after 2s
go: build dev binaries / build_dev_linux_windows (amd64, windows) (push) Failing after 3s
go: build dev binaries / build_dev_darwin (amd64, darwin) (push) Has been skipped
go: build dev binaries / build_dev_darwin (arm64, darwin) (push) Has been skipped
Java Client Unit Tests / Java Unit Tests (11) (push) Failing after 3s
Java Client Unit Tests / Java Unit Tests (17) (push) Failing after 2s
Java Client Unit Tests / Java Unit Tests (21) (push) Failing after 3s
Java Client Unit Tests / Java Unit Tests (8) (push) Failing after 3s
Kafka Quick Test (Load Test with Schema Registry) / Kafka Client Load Test (Quick) (push) Failing after 3s
Kafka Gateway Tests / Kafka Unit Tests (unit-tests-1) (push) Failing after 11s
Kafka Gateway Tests / Kafka Integration Tests (Critical) (integration-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka End-to-End Tests (with SMQ) (e2e-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka Consumer Group Tests (Highly Isolated) (consumer-group-1) (push) Failing after 2s
Kafka Gateway Tests / Kafka Client Compatibility (with SMQ) (client-compat-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka SMQ Integration Tests (Full Stack) (smq-integration-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka Protocol Tests (Isolated) (protocol-1) (push) Failing after 3s
KMS Tests / KMS Provider Integration Tests (push) Failing after 2s
KMS Tests / S3 KMS End-to-End Tests (push) Failing after 3s
Master Cold Start Tests / Master Cold Start Tests (push) Failing after 4s
Metadata Subscribe Integration Tests / Metadata Subscribe Integration Tests (push) Failing after 3s
Multi-Master Tests / Multi-Master Failover Tests (push) Failing after 3s
Performance / CPU and Heap Profile (push) Failing after 2s
Performance / S3 Read/Write Benchmark (rust volume) (push) Failing after 3s
pjdfstest POSIX Compliance / pjdfstest (push) Failing after 2s
Plugin Worker Integration Tests / Plugin Worker: erasure_coding (push) Failing after 3s
Plugin Worker Integration Tests / Plugin Worker: vacuum (push) Failing after 3s
Rust Volume Server Tests / Rust Integration Tests (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (grpc - Shard 1) (push) Failing after 2s
Rust Volume Server Tests / Go Tests with Rust Volume (http - Shard 1) (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (grpc - Shard 2) (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (http - Shard 2) (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (grpc - Shard 3) (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Distributed Tests (push) Failing after 2s
S3 IAM Integration Tests / S3 IAM Performance Tests (push) Failing after 3s
Performance / Throughput Benchmark (go volume) (push) Failing after 3s
Performance / Throughput Benchmark (rust volume) (push) Failing after 2s
Performance / S3 Read/Write Benchmark (go volume) (push) Failing after 3s
Plugin Worker Integration Tests / Plugin Worker: volume_balance (push) Failing after 3s
PostgreSQL Gateway Tests / PostgreSQL Basic Tests (push) Failing after 3s
Rust Volume Server Tests / Rust Unit Tests (push) Failing after 2s
Rust Volume Server Tests / Go Tests with Rust Volume (http - Shard 3) (push) Failing after 3s
Rust Plugin Worker Tests / Rust Plugin Worker Build and Unit Tests (push) Failing after 3s
rust: build dev volume server binaries / cleanup (push) Successful in 3s
S3 ETag and ACL Tests / S3 ETag + ACL Integration Tests (push) Failing after 3s
S3 IAM Integration Tests / IAM Unit Tests (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Integration Tests (advanced) (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Integration Tests (basic) (push) Failing after 2s
S3 IAM Integration Tests / S3 IAM Integration Tests (group) (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Integration Tests (policy-enforcement) (push) Failing after 2s
S3 IAM Integration Tests / S3 IAM Integration Tests (sts) (push) Failing after 4s
S3 Keycloak Integration Tests / S3 Keycloak Integration Tests (push) Failing after 3s
S3 PyArrow Parquet Tests / PyArrow Parquet Tests (Python 3.11) (push) Failing after 3s
S3 PyArrow Parquet Tests / Go Unit Tests (Implicit Directory) (push) Has been cancelled
S3 PyArrow Parquet Tests / PyArrow Parquet Tests (Python 3.12) (push) Has been cancelled
rust: build dev volume server binaries / build-rust-volume-dev-darwin (darwin-amd64, x86_64-apple-darwin) (push) Has been cancelled
rust: build dev volume server binaries / build-rust-volume-dev-darwin (darwin-arm64, aarch64-apple-darwin) (push) Has been cancelled
rust: build dev volume server binaries / build-rust-volume-dev-linux (linux-amd64, x86_64-unknown-linux-gnu) (push) Has been cancelled
S3 PyArrow Parquet Tests / PyArrow Parquet Tests (Python 3.9) (push) Has been cancelled
S3 Proxy Signature Tests / S3 Proxy Signature Verification Tests (push) Has been cancelled
S3 SDK V2 Route Disambiguation Tests / S3 SDK V2 Routing Tests (push) Has been cancelled
S3 SSE Tests / S3 SSE Integration Tests (quick) (push) Has been cancelled
S3 SSE Tests / S3 SSE Compatibility Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Metadata Persistence Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Copy Operations Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Multipart Upload Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Performance Test (push) Has been cancelled
S3 SSE Tests / S3 Volume Encryption Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Integration Tests (comprehensive) (push) Has been cancelled
Spark Integration Tests / Spark Integration Tests (push) Failing after 2s
Telemetry Integration Tests / telemetry-integration-test (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (grpc - Shard 1) (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (http - Shard 1) (push) Failing after 3s
Ceph S3 tests / Basic S3 tests (KV store) (push) Has been cancelled
Ceph S3 tests / S3 Versioning & Object Lock tests (push) Has been cancelled
S3 Policy Integration Tests / S3 Policy Unit Tests (push) Failing after 3s
Ceph S3 tests / S3 CORS tests (push) Has been cancelled
Ceph S3 tests / SeaweedFS Custom S3 Copy tests (push) Has been cancelled
Ceph S3 tests / Basic S3 tests (SQL store) (push) Has been cancelled
test s3 over https using aws-cli / awscli-tests (push) Has been cancelled
TLS Rotation Integration Tests / TLS Rotation Integration Tests (push) Has been cancelled
Vacuum Integration Tests / Vacuum Integration Tests (push) Has been cancelled
S3 Policy Integration Tests / S3 Policy Variables Integration Tests (push) Failing after 3s
S3 Policy Integration Tests / S3 Policy Enforcement Integration Tests (advanced-policy) (push) Failing after 3s
S3 Policy Integration Tests / S3 Policy Enforcement Integration Tests (basic-policy) (push) Failing after 2s
S3 Policy Integration Tests / S3 Policy Enforcement Integration Tests (contextual-policy) (push) Failing after 4s
S3 Policy Integration Tests / Trusted Proxy Detection Tests (push) Failing after 2s
S3 Policy Integration Tests / S3 Policy Shell Integration Tests (push) Failing after 3s
Samba on FUSE Integration / samba-integration (push) Failing after 2s
SFTP Integration Tests / SFTP Integration Testing (push) Failing after 3s
terraform: validate and test modules / fmt, validate, plan-level tests (push) Failing after 3s
terraform: validate and test modules / local cluster smoke test (real weed) (push) Failing after 2s
Volume Server Integration Tests / Volume Server Integration Tests (grpc - Shard 3) (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (grpc - Shard 2) (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (http - Shard 2) (push) Failing after 2s
Volume Server Integration Tests / Volume Server Integration Tests (http - Shard 3) (push) Failing after 5s
mount: windows conformance / WinFsp conformance (push) Has been cancelled
mount: windows / Mount on Windows (push) Has been cancelled
snapshot of https://github.com/seaweedfs/seaweedfs.git (master, 2026-09-16; blobs > 131072B omitted)
2026-09-16 03:23:42 +05:00

386 lines
12 KiB
Go

package storage
import (
"os"
"path/filepath"
"testing"
"github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb"
"github.com/seaweedfs/seaweedfs/weed/stats"
"github.com/seaweedfs/seaweedfs/weed/storage/erasure_coding"
"github.com/seaweedfs/seaweedfs/weed/storage/needle"
"github.com/seaweedfs/seaweedfs/weed/storage/super_block"
"github.com/seaweedfs/seaweedfs/weed/storage/types"
"github.com/seaweedfs/seaweedfs/weed/storage/volume_info"
"github.com/seaweedfs/seaweedfs/weed/util"
)
// TestLoneVifDoesNotCreatePhantomDat: a lone .vif whose .ecx is on a
// sibling disk must not make loadExistingVolume create a phantom 8-byte
// .dat, which the sibling-.dat prune would then use to delete the real EC shards
// on the sibling. The same-disk hasEcxFile() guard misses this split.
func TestLoneVifDoesNotCreatePhantomDat(t *testing.T) {
tempDir := t.TempDir()
dir0 := filepath.Join(tempDir, "data1")
dir1 := filepath.Join(tempDir, "data2")
for _, d := range []string{dir0, dir1} {
if err := os.MkdirAll(d, 0o755); err != nil {
t.Fatalf("mkdir %s: %v", d, err)
}
}
collection := "warp-loadtest"
vid := needle.VolumeId(57)
const dataShards, parityShards = 10, 4
const datSize int64 = 10 * 1024 * 1024
expectedShardSize := calculateExpectedShardSize(datSize, dataShards)
// dir0: a self-contained but partial (2 < 10) EC volume.
base0 := erasure_coding.EcShardFileName(collection, dir0, int(vid))
for _, sid := range []int{2, 4} {
f, err := os.Create(base0 + erasure_coding.ToExt(sid))
if err != nil {
t.Fatalf("create shard %d: %v", sid, err)
}
if err := f.Truncate(expectedShardSize); err != nil {
f.Close()
t.Fatalf("truncate shard %d: %v", sid, err)
}
if err := f.Close(); err != nil {
t.Fatalf("close shard %d: %v", sid, err)
}
}
if err := os.WriteFile(base0+".ecx", make([]byte, 20), 0o644); err != nil {
t.Fatalf("write .ecx: %v", err)
}
if err := os.WriteFile(base0+".ecj", nil, 0o644); err != nil {
t.Fatalf("write .ecj: %v", err)
}
// DatFileSize 0 mirrors the production .vif that triggered the bug and
// makes the prune's credibility gate fall back to the superblock size.
vif := &volume_server_pb.VolumeInfo{
Version: uint32(needle.Version3),
EcShardConfig: &volume_server_pb.EcShardConfig{
DataShards: dataShards,
ParityShards: parityShards,
},
}
if err := volume_info.SaveVolumeInfo(base0+".vif", vif); err != nil {
t.Fatalf("save .vif dir0: %v", err)
}
// dir1: ONLY the mirrored .vif — no .ecx, no shard, no .dat.
base1 := erasure_coding.EcShardFileName(collection, dir1, int(vid))
if err := volume_info.SaveVolumeInfo(base1+".vif", vif); err != nil {
t.Fatalf("save .vif dir1: %v", err)
}
diskIOProbeConfig := stats.DefaultDiskIOProbeConfig()
store := NewStore(nil, "localhost", 8080, 18080, "http://localhost:8080", "store-id",
[]string{dir0, dir1},
[]int32{100, 100},
[]util.MinFreeSpace{{}, {}},
"",
NeedleMapInMemory,
[]types.DiskType{types.HardDriveType, types.HardDriveType},
nil,
3,
diskIOProbeConfig,
)
done := make(chan struct{})
go func() {
for {
select {
case <-store.NewVolumesChan:
case <-store.NewEcShardsChan:
case <-store.DeletedVolumesChan:
case <-store.DeletedEcShardsChan:
case <-store.StateUpdateChan:
case <-done:
return
}
}
}()
t.Cleanup(func() {
store.Close()
close(done)
})
// Fix A: the lone .vif on dir1 must not have spawned a phantom .dat.
if util.FileExists(base1 + ".dat") {
t.Errorf("phantom .dat was created on the lone-.vif disk %s", dir1)
}
// The real EC shards on dir0 must survive: with no phantom .dat, the
// sibling-.dat prune finds no .dat owner and deletes nothing.
loc0 := store.Locations[0]
for _, sid := range []erasure_coding.ShardId{2, 4} {
if _, found := loc0.FindEcShard(vid, sid); !found {
t.Errorf("EC shard %d on dir0 was deleted", sid)
}
if !util.FileExists(base0 + erasure_coding.ToExt(int(sid))) {
t.Errorf("EC shard file %d on dir0 was removed from disk", sid)
}
}
}
// TestEmptyEcDatStubIsSwept: an empty .dat (<= a superblock, i.e. zero needles)
// for an EC volume is a leftover stub from the pre-fix loader; the loader must
// sweep it on startup, not load it as a phantom empty volume. (On Rust this
// also unblocks the duplicate-vid startup check; Go loads each disk
// independently and does not crash, but the phantom must still go.)
func TestEmptyEcDatStubIsSwept(t *testing.T) {
tempDir := t.TempDir()
dir0 := filepath.Join(tempDir, "data1")
dir1 := filepath.Join(tempDir, "data2")
for _, d := range []string{dir0, dir1} {
if err := os.MkdirAll(d, 0o755); err != nil {
t.Fatalf("mkdir %s: %v", d, err)
}
}
collection := "warp-cal"
vid := needle.VolumeId(41)
// A real (loadable) but empty superblock: without the sweep it loads as a
// phantom empty volume.
stub := (&super_block.SuperBlock{
Version: needle.Version3,
ReplicaPlacement: &super_block.ReplicaPlacement{},
Ttl: &needle.TTL{},
}).Bytes()
for _, d := range []string{dir0, dir1} {
base := erasure_coding.EcShardFileName(collection, d, int(vid))
if err := os.WriteFile(base+".dat", stub, 0o644); err != nil {
t.Fatalf("write stub .dat: %v", err)
}
if err := volume_info.SaveVolumeInfo(base+".vif", &volume_server_pb.VolumeInfo{
Version: uint32(needle.Version3),
EcShardConfig: &volume_server_pb.EcShardConfig{DataShards: 10, ParityShards: 4},
}); err != nil {
t.Fatalf("save .vif: %v", err)
}
}
diskIOProbeConfig := stats.DefaultDiskIOProbeConfig()
store := NewStore(nil, "localhost", 8080, 18080, "http://localhost:8080", "store-id",
[]string{dir0, dir1},
[]int32{100, 100},
[]util.MinFreeSpace{{}, {}},
"",
NeedleMapInMemory,
[]types.DiskType{types.HardDriveType, types.HardDriveType},
nil,
3,
diskIOProbeConfig,
)
done := make(chan struct{})
go func() {
for {
select {
case <-store.NewVolumesChan:
case <-store.NewEcShardsChan:
case <-store.DeletedVolumesChan:
case <-store.DeletedEcShardsChan:
case <-store.StateUpdateChan:
case <-done:
return
}
}
}()
t.Cleanup(func() {
store.Close()
close(done)
})
if store.findVolume(vid) != nil {
t.Errorf("empty EC .dat stub was loaded as a phantom volume %d", vid)
}
for _, d := range []string{dir0, dir1} {
if util.FileExists(erasure_coding.EcShardFileName(collection, d, int(vid)) + ".dat") {
t.Errorf("empty .dat stub on %s was not removed", d)
}
}
}
// TestRemoveEmptyEcDatStubFindsVifInIdxDir: when -dir.idx is configured the EC
// .vif may live in the idx directory; removeEmptyEcDatStub must look there too,
// not only in the data dir. Calls the helper directly (the dir scan only
// discovers volumes via a .idx/.vif in the data dir, which a separate idx dir
// sidesteps).
func TestRemoveEmptyEcDatStubFindsVifInIdxDir(t *testing.T) {
dataDir := t.TempDir()
idxDir := t.TempDir()
loc := &DiskLocation{
Directory: dataDir,
DirectoryUuid: "test-uuid",
IdxDirectory: idxDir,
DiskType: types.HddType,
MaxVolumeCount: 100,
OriginalMaxVolumeCount: 100,
MinFreeSpace: util.MinFreeSpace{Type: util.AsPercent, Percent: 1, Raw: "1"},
}
const volumeName = "warp-cal_42"
stub := (&super_block.SuperBlock{
Version: needle.Version3,
ReplicaPlacement: &super_block.ReplicaPlacement{},
Ttl: &needle.TTL{},
}).Bytes()
if err := os.WriteFile(dataDir+"/"+volumeName+".dat", stub, 0o644); err != nil {
t.Fatalf("write stub .dat: %v", err)
}
// EC .vif lives in the idx dir, not next to the .dat.
if err := volume_info.SaveVolumeInfo(idxDir+"/"+volumeName+".vif", &volume_server_pb.VolumeInfo{
Version: uint32(needle.Version3),
EcShardConfig: &volume_server_pb.EcShardConfig{DataShards: 10, ParityShards: 4},
}); err != nil {
t.Fatalf("save .vif: %v", err)
}
if !loc.removeEmptyEcDatStub(volumeName, needle.VolumeId(42), "warp-cal") {
t.Fatal("stub with EC .vif in the idx dir should be removed")
}
if util.FileExists(dataDir + "/" + volumeName + ".dat") {
t.Error(".dat stub was not removed")
}
}
// startEcTestStore starts a single-disk store over dir and drains its
// notification channels until cleanup.
func startEcTestStore(t *testing.T, dir string) *Store {
t.Helper()
store := NewStore(nil, "localhost", 8080, 18080, "http://localhost:8080", "store-id",
[]string{dir},
[]int32{100},
[]util.MinFreeSpace{{}},
"",
NeedleMapInMemory,
[]types.DiskType{types.HardDriveType},
nil,
3,
stats.DefaultDiskIOProbeConfig(),
)
done := make(chan struct{})
go func() {
for {
select {
case <-store.NewVolumesChan:
case <-store.NewEcShardsChan:
case <-store.DeletedVolumesChan:
case <-store.DeletedEcShardsChan:
case <-store.StateUpdateChan:
case <-done:
return
}
}
}()
t.Cleanup(func() {
store.Close()
close(done)
})
return store
}
// writeEcShardFixture lays down .ecx, .ecj, and the given shards for a
// distributed EC volume in dir, each shard truncated to shardSize.
func writeEcShardFixture(t *testing.T, base string, shardIds []int, shardSize int64) {
t.Helper()
for _, sid := range shardIds {
f, err := os.Create(base + erasure_coding.ToExt(sid))
if err != nil {
t.Fatalf("create shard %d: %v", sid, err)
}
if err := f.Truncate(shardSize); err != nil {
f.Close()
t.Fatalf("truncate shard %d: %v", sid, err)
}
if err := f.Close(); err != nil {
t.Fatalf("close shard %d: %v", sid, err)
}
}
if err := os.WriteFile(base+".ecx", make([]byte, 20), 0o644); err != nil {
t.Fatalf("write .ecx: %v", err)
}
if err := os.WriteFile(base+".ecj", nil, 0o644); err != nil {
t.Fatalf("write .ecj: %v", err)
}
}
// TestEmptyDatStubNextToEcxDoesNotDeleteShards: a disk holding a few local
// shards of a healthy distributed EC volume plus a leftover empty .dat stub.
// The stub used to make startup classify the volume as an interrupted local
// encode (fewer than dataShards local shards) and delete the only copies of
// those shards. The stub must be swept and the shards must load.
func TestEmptyDatStubNextToEcxDoesNotDeleteShards(t *testing.T) {
dir := t.TempDir()
collection := "warp-rec"
vid := needle.VolumeId(87)
base := erasure_coding.EcShardFileName(collection, dir, int(vid))
shardIds := []int{0, 5}
writeEcShardFixture(t, base, shardIds, int64(erasure_coding.ErasureCodingSmallBlockSize))
// Zero-byte stub .dat: the phantom left by the pre-fix loader.
if err := os.WriteFile(base+".dat", nil, 0o644); err != nil {
t.Fatalf("write stub .dat: %v", err)
}
if err := volume_info.SaveVolumeInfo(base+".vif", &volume_server_pb.VolumeInfo{
Version: uint32(needle.Version3),
EcShardConfig: &volume_server_pb.EcShardConfig{DataShards: 10, ParityShards: 4},
}); err != nil {
t.Fatalf("save .vif: %v", err)
}
store := startEcTestStore(t, dir)
loc := store.Locations[0]
for _, sid := range shardIds {
if !util.FileExists(base + erasure_coding.ToExt(sid)) {
t.Errorf("EC shard file %d was deleted", sid)
}
if _, found := loc.FindEcShard(vid, erasure_coding.ShardId(sid)); !found {
t.Errorf("EC shard %d was not loaded", sid)
}
}
if !util.FileExists(base + ".ecx") {
t.Error(".ecx was deleted")
}
if util.FileExists(base + ".dat") {
t.Error("empty .dat stub was not swept")
}
if store.findVolume(vid) != nil {
t.Errorf("stub was loaded as a phantom volume %d", vid)
}
}
// TestEmptyDatWithoutVifDoesNotDeleteShards: same shard-holding disk but the
// stub has no .vif at all, so the sweep has no EC evidence and must leave it.
// The empty .dat still must not count as an encode source: the shards survive
// and load as a distributed EC volume.
func TestEmptyDatWithoutVifDoesNotDeleteShards(t *testing.T) {
dir := t.TempDir()
collection := "warp-rec"
vid := needle.VolumeId(88)
base := erasure_coding.EcShardFileName(collection, dir, int(vid))
shardIds := []int{1, 7}
writeEcShardFixture(t, base, shardIds, int64(erasure_coding.ErasureCodingSmallBlockSize))
if err := os.WriteFile(base+".dat", nil, 0o644); err != nil {
t.Fatalf("write stub .dat: %v", err)
}
store := startEcTestStore(t, dir)
loc := store.Locations[0]
for _, sid := range shardIds {
if !util.FileExists(base + erasure_coding.ToExt(sid)) {
t.Errorf("EC shard file %d was deleted", sid)
}
if _, found := loc.FindEcShard(vid, erasure_coding.ShardId(sid)); !found {
t.Errorf("EC shard %d was not loaded", sid)
}
}
if store.findVolume(vid) != nil {
t.Errorf("stub was loaded as a phantom volume %d", vid)
}
}